Actual source code: petscfvimpl.h

  1: #pragma once

  3: #include <petscfv.h>
  4: #ifdef PETSC_HAVE_LIBCEED
  5: #include <petscfvceed.h>
  6: #endif
  7: #include <petsc/private/petscimpl.h>
  8: #include <petsc/private/dmimpl.h>

 10: PETSC_EXTERN PetscBool      PetscLimiterRegisterAllCalled;
 11: PETSC_EXTERN PetscBool      PetscFVRegisterAllCalled;
 12: PETSC_EXTERN PetscErrorCode PetscLimiterRegisterAll(void);
 13: PETSC_EXTERN PetscErrorCode PetscFVRegisterAll(void);

 15: typedef struct _PetscLimiterOps *PetscLimiterOps;
 16: struct _PetscLimiterOps {
 17:   PetscErrorCode (*setfromoptions)(PetscLimiter);
 18:   PetscErrorCode (*setup)(PetscLimiter);
 19:   PetscErrorCode (*view)(PetscLimiter, PetscViewer);
 20:   PetscErrorCode (*destroy)(PetscLimiter);
 21:   PetscErrorCode (*limit)(PetscLimiter, PetscReal, PetscReal *);
 22: };

 24: struct _p_PetscLimiter {
 25:   PETSCHEADER(struct _PetscLimiterOps);
 26:   void *data; /* Implementation object */
 27: };

 29: typedef struct {
 30:   PetscInt dummy;
 31: } PetscLimiter_Sin;

 33: typedef struct {
 34:   PetscInt dummy;
 35: } PetscLimiter_Zero;

 37: typedef struct {
 38:   PetscInt dummy;
 39: } PetscLimiter_None;

 41: typedef struct {
 42:   PetscInt dummy;
 43: } PetscLimiter_Minmod;

 45: typedef struct {
 46:   PetscInt dummy;
 47: } PetscLimiter_VanLeer;

 49: typedef struct {
 50:   PetscInt dummy;
 51: } PetscLimiter_VanAlbada;

 53: typedef struct {
 54:   PetscInt dummy;
 55: } PetscLimiter_Superbee;

 57: typedef struct {
 58:   PetscInt dummy;
 59: } PetscLimiter_MC;

 61: typedef struct _PetscFVOps *PetscFVOps;
 62: struct _PetscFVOps {
 63:   PetscErrorCode (*setfromoptions)(PetscFV);
 64:   PetscErrorCode (*setup)(PetscFV);
 65:   PetscErrorCode (*view)(PetscFV, PetscViewer);
 66:   PetscErrorCode (*destroy)(PetscFV);
 67:   PetscErrorCode (*computegradient)(PetscFV, PetscInt, const PetscScalar[], PetscScalar[]);
 68:   PetscErrorCode (*integraterhsfunction)(PetscFV, PetscDS, PetscInt, PetscInt, PetscFVFaceGeom *, PetscReal *, PetscScalar[], PetscScalar[], PetscScalar[], PetscScalar[]);
 69: };

 71: struct _p_PetscFV {
 72:   PETSCHEADER(struct _PetscFVOps);
 73:   void           *data;             /* Implementation object */
 74:   PetscLimiter    limiter;          /* The slope limiter */
 75:   PetscDualSpace  dualSpace;        /* The dual space P', usually simple */
 76:   PetscInt        numComponents;    /* The number of field components */
 77:   PetscInt        dim;              /* The spatial dimension */
 78:   PetscBool       computeGradients; /* Flag for gradient computation */
 79:   PetscScalar    *fluxWork;         /* The work array for flux calculation */
 80:   PetscQuadrature quadrature;       /* Suitable quadrature on the volume */
 81:   PetscTabulation T;                /* Tabulation of pseudo-basis and derivatives at quadrature points */
 82:   char          **componentNames;   /* Names of the component fields */
 83: #ifdef PETSC_HAVE_LIBCEED
 84:   Ceed      ceed;      /* The LibCEED context, usually set by the DM */
 85:   CeedBasis ceedBasis; /* Basis for libCEED matching this element */
 86: #endif
 87: };

 89: typedef struct {
 90:   PetscInt cellType;
 91: } PetscFV_Upwind;

 93: typedef struct {
 94:   PetscInt     maxFaces, workSize;
 95:   PetscScalar *B, *Binv, *tau, *work;
 96: } PetscFV_LeastSquares;

 98: static inline PetscErrorCode PetscFVInterpolate_Static(PetscFV fv, const PetscScalar x[], PetscInt q, PetscScalar interpolant[])
 99: {
100:   PetscInt Nc;

102:   PetscFunctionBeginHot;
103:   PetscCall(PetscFVGetNumComponents(fv, &Nc));
104:   PetscCall(PetscArraycpy(interpolant, x, Nc));
105:   PetscFunctionReturn(PETSC_SUCCESS);
106: }