Date: 2026-07-30T21:13:58+00:00

Actual source code: petscdmfield.h

      1: #pragma once

      3: #include <petscdm.h>
      4: #include <petscdt.h>
      5: #include <petscfe.h>

      7: /* SUBMANSEC = DM */

      9: PETSC_EXTERN PetscErrorCode DMFieldInitializePackage(void);
     10: PETSC_EXTERN PetscErrorCode DMFieldFinalizePackage(void);

     12: PETSC_EXTERN PetscClassId DMFIELD_CLASSID;

     14: /*J
     15:   DMFieldType - String with the name of a `DMField` implementation

     17:   Values:
     18: + `DMFIELDDA`    - a field defined only by its values at the corners of a `DMDA`
     19: . `DMFIELDDS`    - a field defined by a discretization over a mesh set with `DMSetField()`
     20: - `DMFIELDSHELL` - a field defined by arbitrary callbacks

     22:   Level: intermediate

     24: .seealso: [](ch_dmbase), `DMField`, `DMFieldSetType()`, `DMFieldGetType()`, `DMFieldRegister()`
     25: J*/
     26: typedef const char *DMFieldType;
     27: #define DMFIELDDA    "da"
     28: #define DMFIELDDS    "ds"
     29: #define DMFIELDSHELL "shell"

     31: PETSC_EXTERN PetscFunctionList DMFieldList;
     32: PETSC_EXTERN PetscErrorCode    DMFieldSetType(DMField, DMFieldType);
     33: PETSC_EXTERN PetscErrorCode    DMFieldGetType(DMField, DMFieldType *);
     34: PETSC_EXTERN PetscErrorCode    DMFieldRegister(const char[], PetscErrorCode (*)(DMField));

     36: /*E
     37:    DMFieldContinuity - Indicates the smallest mesh entity across which a `DMField` is continuous; equivalently, the largest entity at which the field may be discontinuous

     39:    Values:
     40: +   `DMFIELD_VERTEX` - continuous across vertices (i.e., everywhere on the mesh; standard $H^1$ finite elements)
     41: .   `DMFIELD_EDGE`   - continuous across edges, but may jump at vertices
     42: .   `DMFIELD_FACET`  - continuous across facets (faces in 3D, edges in 2D); may jump at lower-dimensional points
     43: -   `DMFIELD_CELL`   - field is defined per cell, with no continuity between adjacent cells (cell-centered finite volume)

     45:    Level: intermediate

     47: .seealso: `DMField`, `DMFieldCreateShell()`, `DMFieldEvaluate()`, `DMFieldEvaluateFE()`, `DMFieldEvaluateFV()`
     48: E*/
     49: typedef enum {
     50:   DMFIELD_VERTEX,
     51:   DMFIELD_EDGE,
     52:   DMFIELD_FACET,
     53:   DMFIELD_CELL
     54: } DMFieldContinuity;
     55: PETSC_EXTERN const char *const DMFieldContinuities[];

     57: PETSC_EXTERN PetscErrorCode DMFieldDestroy(DMField *);
     58: PETSC_EXTERN PetscErrorCode DMFieldView(DMField, PetscViewer);

     60: PETSC_EXTERN PetscErrorCode DMFieldGetDM(DMField, DM *);
     61: PETSC_EXTERN PetscErrorCode DMFieldGetNumComponents(DMField, PetscInt *);

     63: PETSC_EXTERN PetscErrorCode DMFieldEvaluate(DMField, Vec, PetscDataType, void *, void *, void *);
     64: PETSC_EXTERN PetscErrorCode DMFieldEvaluateFE(DMField, IS, PetscQuadrature, PetscDataType, void *, void *, void *);
     65: PETSC_EXTERN PetscErrorCode DMFieldEvaluateFV(DMField, IS, PetscDataType, void *, void *, void *);
     66: PETSC_EXTERN PetscErrorCode DMFieldCreateFEGeom(DMField, IS, PetscQuadrature, PetscFEGeomMode, PetscFEGeom **);

     68: PETSC_EXTERN PetscErrorCode DMFieldCreateDefaultQuadrature(DMField, IS, PetscQuadrature *);
     69: PETSC_EXTERN PetscErrorCode DMFieldCreateDefaultFaceQuadrature(DMField, IS, PetscQuadrature *);

     71: PETSC_EXTERN PetscErrorCode DMFieldGetDegree(DMField, IS, PetscInt *, PetscInt *);

     73: PETSC_EXTERN PetscErrorCode DMFieldCreateDA(DM, PetscInt, const PetscScalar *, DMField *);
     74: PETSC_EXTERN PetscErrorCode DMFieldCreateDS(DM, PetscInt, Vec, DMField *);
     75: PETSC_EXTERN PetscErrorCode DMFieldCreateDSWithDG(DM, DM, PetscInt, Vec, Vec, DMField *);

     77: PETSC_EXTERN PetscErrorCode DMFieldCreateShell(DM, PetscInt, DMFieldContinuity, PetscCtx, DMField *);
     78: PETSC_EXTERN PetscErrorCode DMFieldShellSetDestroy(DMField, PetscErrorCode (*)(DMField));
     79: PETSC_EXTERN PetscErrorCode DMFieldShellGetContext(DMField, PetscCtxRt);
     80: PETSC_EXTERN PetscErrorCode DMFieldShellSetEvaluate(DMField, PetscErrorCode (*)(DMField, Vec, PetscDataType, void *, void *, void *));
     81: PETSC_EXTERN PetscErrorCode DMFieldShellSetEvaluateFE(DMField, PetscErrorCode (*)(DMField, IS, PetscQuadrature, PetscDataType, void *, void *, void *));
     82: PETSC_EXTERN PetscErrorCode DMFieldShellEvaluateFEDefault(DMField, IS, PetscQuadrature, PetscDataType, void *, void *, void *);
     83: PETSC_EXTERN PetscErrorCode DMFieldShellSetEvaluateFV(DMField, PetscErrorCode (*)(DMField, IS, PetscDataType, void *, void *, void *));
     84: PETSC_EXTERN PetscErrorCode DMFieldShellEvaluateFVDefault(DMField, IS, PetscDataType, void *, void *, void *);
     85: PETSC_EXTERN PetscErrorCode DMFieldShellSetGetDegree(DMField, PetscErrorCode (*)(DMField, IS, PetscInt *, PetscInt *));
     86: PETSC_EXTERN PetscErrorCode DMFieldShellSetCreateDefaultQuadrature(DMField, PetscErrorCode (*)(DMField, IS, PetscQuadrature *));