[petsc-users] Regarding FormFunction in the SNES class

Matthew Knepley knepley at gmail.com
Wed Oct 7 17:32:02 CDT 2020


On Wed, Oct 7, 2020 at 4:26 PM Barry Smith <bsmith at petsc.dev> wrote:

>
>
> > On Oct 7, 2020, at 1:41 PM, baikadi pranay <pranayreddy865 at gmail.com>
> wrote:
> >
> > Hello,
> > I have a few questions regarding FormFunction when using the SNES
> solvers. I am using Fortran90.
> >
> > 1) I went through the example (ex1f.F90) provided in the documentation
> that uses Newton method to solve a two-variable system. In the subroutine
> FormFunction, the first argument is an input vector (x). However in the
> code, no attributes are specified saying that it is an input argument for
> the subroutine (i.e. intent attribute is not specified). Is this
> automatically taken care of or should I be defining the intent attribute in
> my code ?
>
>   We don't currently provide attributes for our Fortran stubs, so it is
> best if you do not mark them in your subroutines.
>
>   Yes the x is input only and the f is output only.
>

Are you certain? We do not change the f pointer, you change the data hiding
inside.

   Matt


> > Also, should I use the "allocatable" attribute when defining the vector
> x?
>
>    I am pretty sure no.
>
> > Please comment similarly on the output vector f as well.
> > 2) Should the ctx argument of the subroutine FormFunction be defined as
> "PETSC_NULL_INTEGER"?
>
>    The context is how you convey additional information into
> FormFunction(). Should you choose to not use it then in your function you
> can declare it as a integer and simply not use it. If you are calling your
> FormFunction() from Fortran then just pass a meaningless integer as that
> argument.  PETSC_NULL_INTEGER is for call PETSc functions that take integer
> array arguments that you are not supplying.
>
>   Barry
>
>
>
> >
> > Please let me know if you need any further information.
> >
> > Thank you.
> > Best Regards,
> > Pranay.
>
>

-- 
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

https://www.cse.buffalo.edu/~knepley/ <http://www.cse.buffalo.edu/~knepley/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20201007/9a5e5d57/attachment.html>


More information about the petsc-users mailing list