[petsc-users] need more argument in FormFuction in SNESSetFunction
Timothée Nicolas
timothee.nicolas at gmail.com
Fri Mar 25 23:43:14 CDT 2016
Hi,
If you want to use other arrays, you can either put them in modules and
then "use" the module at the very top of the subroutine, or create a new
type which can contain anything (scalars, integers, arrays but also more
complex PETSc objects), and put an instance of this type in the place of
your dummy array.
For instance
module types
type levelcontext
#include "petsc/finclude/petscdmdef.h"
DM :: da
PetscScalar :: MyArray(10)
end type levelcontext
end module types
and then in your main you can do
use types
type(levelcontext) :: ctx
Finally you call SNESSetFunction as
CALL SNESSetFunction(snes,r,FormFunction,ctx,ierr)
Inside SNESSetFunction you can then access your array or your DMDA as
ctx%MyArray, ctx%da etc etc.
Also, in principle I think you should set the context ctx of SNES with
call SNESSetApplicationContext(snes,ctx,ierr)
Best
Timothée
2016-03-26 13:21 GMT+09:00 Josh Lo <ysjosh.lo at gmail.com>:
> Hi,
>
> I am trying to SNES with Fortran.
> In FormFunction in SNESSetFuction, i need to call other subroutine and
> many array to calculate F(x), but seems like SNESSetFunction only allows
> one user-defined array as input argument, say, "dummy" in the next line.
>
> CALL SNESSetFunction(snes,r,FormFunction,dummy,ierr)
>
> How can I pass more than one array through SNESSetFunction to FormFunction?
>
> I am a beginner for PETSc, so the question maybe naive.
>
> Thanks,
> Lo
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20160326/e691753f/attachment.html>
More information about the petsc-users
mailing list