Skip to content

Wrapping PetscDS into petsc4py  #9

@rbeucher

Description

@rbeucher

I am trying to wrap the PetscDS functionalities into Petsc4py by completing the
cython class. The aim is to be be able to reproduce finite element pb such as
the Poisson example (petsc/src/snes/examples/tutorials/ex12.c) and ultimately
a Stokes problem such as in (petsc/src/snes/examples/tutorials/ex12.c).

The main hurdle I am facing is the wrapping of the PetscDSSetResidual (and
PetscDSSetJacobian) function which set the Residual integrand f0 and f1 as
callback functions.

see PETSc doc here

The signature of those callback functions is as follow:

void (*f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
      const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScala
      const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScala
      PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[])

Ideally I would like those functions to be written in python in a way similar to
what has been done for the SNESSetFunction, SNESSetJacobian etc.

It would be great if a pointer to the DS could be added to the list of arguments
passed to the above function.

Another possibility would be to add a void pointer to the argument passed to the
f* function that could be used to provide some context information...

This requires some changes in PETSc itself and I am not sure how we should
proceed. Maybe contact Matt Knepley directly?

I can't see any other way around it and I think this is also going to be a
problem for passing underworld function (whether they are C or python function).
For now julian uses the auxiliar fields on which he casts the required
information... but he still has to write the C function...

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions