[petsc-users] PetscFECreateDefault in Fortran

Justin Pogacnik j.pogacnik at auckland.ac.nz
Thu Jun 1 18:29:26 CDT 2017


Hi Matt,


​Yes, I was using the QuadratureGetData in the past and the results were good. I wasn't sure why that would have changed recently. Looking at the example (in test directory, not tutorial), it looks like the two interesting pointers are pEC and pES. pEC's target is EC, which is explicitly set. Does pES have no target? In my code, I set (basically the same for q_points as well):

PetscReal, target, dimension(8) :: q_weights

PetscReal, pointer :: pq_weights(:)


then:

pq_weights => q_weights


Then call: PetscQuadratureGetData()

When I try to write the quadrature points and weights to see their output, I get values like NaN, 3.0e-310, etc.


I tried removing the q_weights target (like pES example in the test) and that returns a segfault. I've attached my example if that helps. You can uncomment the QuadratureView() and see that the points and weights are correct.​


Thanks again,


Justin

________________________________
From: Matthew Knepley <knepley at gmail.com>
Sent: Friday, June 2, 2017 9:57 AM
To: Justin Pogacnik
Cc: petsc-users at mcs.anl.gov
Subject: Re: [petsc-users] PetscFECreateDefault in Fortran

On Thu, Jun 1, 2017 at 2:59 PM, Justin Pogacnik <j.pogacnik at auckland.ac.nz<mailto:j.pogacnik at auckland.ac.nz>> wrote:

​All good. Thanks Matt. Will keep an eye out for that update. :)

I have checked, and I was wrong before. I did write the code for PetscQuadratureGet/RestoreData()
in Fortran. Since it uses array arguments, I used F90. Thus you have to use F90 pointers, in the
same style as DMPlexGet/RestoreCone() in this example:

    https://bitbucket.org/petsc/petsc/src/a19fbe4d52f99f875359274419a2d40a87edfba3/src/dm/impls/plex/examples/tutorials/ex1f90.F90?at=master&fileviewer=file-view-default

Let me know if that is not understandable

  Thanks,

    Matt

-Justin

________________________________
From: Matthew Knepley <knepley at gmail.com<mailto:knepley at gmail.com>>
Sent: Friday, June 2, 2017 12:52 AM

To: Justin Pogacnik
Cc: petsc-users at mcs.anl.gov<mailto:petsc-users at mcs.anl.gov>
Subject: Re: [petsc-users] PetscFECreateDefault in Fortran

On Wed, May 31, 2017 at 10:00 PM, Justin Pogacnik <j.pogacnik at auckland.ac.nz<mailto:j.pogacnik at auckland.ac.nz>> wrote:

Thanks Matt! That works perfectly now. I have another question regarding accessing the quadrature information.


When I use PetscFEGetQuadrature(), then PetscQuadratureView(), I see what I expect regarding point locations, weights.


However, when I try to use PetscQuadratureGetData() the pointers seem to point to random memory locations.


The exact line from my test problem is: call PetscQuadratureGetData(quad,q_nc,q_dim,q_num,pq_points,pq_weights,ierr);

where the pq_* are the pointers giving strange output. The q_nc, q_dim, and q_num are all giving what I would expect to see.

You are clearly the first Fortran user interested in this stuff ;) Handling of arrays in Fortran demands some more work
from us. I need to write a wrapper for that function. I will do it as soon as I can.

  Thanks,

    Matt

Happy to send along the file if that helps.


Thanks again,


Justin

________________________________
From: Matthew Knepley <knepley at gmail.com<mailto:knepley at gmail.com>>
Sent: Thursday, June 1, 2017 1:34 AM
To: Justin Pogacnik
Cc: petsc-users at mcs.anl.gov<mailto:petsc-users at mcs.anl.gov>
Subject: Re: [petsc-users] PetscFECreateDefault in Fortran

On Wed, May 31, 2017 at 7:53 AM, Matthew Knepley <knepley at gmail.com<mailto:knepley at gmail.com>> wrote:
On Tue, May 30, 2017 at 10:19 PM, Justin Pogacnik <j.pogacnik at auckland.ac.nz<mailto:j.pogacnik at auckland.ac.nz>> wrote:

Hello,

I'm developing a finite element code in fortran 90. I recently updated my PETSc and am now getting the following error during compile/linking on an existing application:

Undefined symbols for architecture x86_64:

  "_petscfecreatedefault_", referenced from:

      _MAIN__ in fe_test.o

ld: symbol(s) not found for architecture x86_64

collect2: error: ld returned 1 exit status

make: *** [dist/fe_test] Error 1


I'm running Mac OS X Yosemite (10.10.5). I've created a "minimum working example" (attached) that re-creates the problem. It's basically just dm/impls/plex/examples/tutorials/ex3f90, but tries to create a PetscFE object. Everything goes fine and the DM looks like what is expected if PetscFECreateDefault is commented out. Any idea what am I missing?

Yes, I had not made a Fortran binding for this function. I will do it now.

I have merged it to the 'next' branch, and it will be in 'master' soon.

  Thanks,

     Matt

  Thanks,

     Matt

Many thanks!

Justin






--
What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.
-- Norbert Wiener

http://www.caam.rice.edu/~mk51/



--
What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.
-- Norbert Wiener

http://www.caam.rice.edu/~mk51/



--
What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.
-- Norbert Wiener

http://www.caam.rice.edu/~mk51/



--
What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.
-- Norbert Wiener

http://www.caam.rice.edu/~mk51/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20170601/0737b18c/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fe_test.F90
Type: application/octet-stream
Size: 2595 bytes
Desc: fe_test.F90
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20170601/0737b18c/attachment-0001.obj>


More information about the petsc-users mailing list