1 #pragma once
2
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>
9
10 PETSC_EXTERN PetscBool PetscLimiterRegisterAllCalled;
11 PETSC_EXTERN PetscBool PetscFVRegisterAllCalled;
12 PETSC_EXTERN PetscErrorCode PetscLimiterRegisterAll(void);
13 PETSC_EXTERN PetscErrorCode PetscFVRegisterAll(void);
14
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 };
23
24 struct _p_PetscLimiter {
25 PETSCHEADER(struct _PetscLimiterOps);
26 void *data; /* Implementation object */
27 };
28
29 typedef struct {
30 PetscInt dummy;
31 } PetscLimiter_Sin;
32
33 typedef struct {
34 PetscInt dummy;
35 } PetscLimiter_Zero;
36
37 typedef struct {
38 PetscInt dummy;
39 } PetscLimiter_None;
40
41 typedef struct {
42 PetscInt dummy;
43 } PetscLimiter_Minmod;
44
45 typedef struct {
46 PetscInt dummy;
47 } PetscLimiter_VanLeer;
48
49 typedef struct {
50 PetscInt dummy;
51 } PetscLimiter_VanAlbada;
52
53 typedef struct {
54 PetscInt dummy;
55 } PetscLimiter_Superbee;
56
57 typedef struct {
58 PetscInt dummy;
59 } PetscLimiter_MC;
60
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 };
70
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 };
88
89 typedef struct {
90 PetscInt cellType;
91 } PetscFV_Upwind;
92
93 typedef struct {
94 PetscInt maxFaces, workSize;
95 PetscScalar *B, *Binv, *tau, *work;
96 } PetscFV_LeastSquares;
97
PetscFVInterpolate_Static(PetscFV fv,const PetscScalar x[],PetscInt q,PetscScalar interpolant[])98 static inline PetscErrorCode PetscFVInterpolate_Static(PetscFV fv, const PetscScalar x[], PetscInt q, PetscScalar interpolant[])
99 {
100 PetscInt Nc;
101
102 PetscFunctionBeginHot;
103 PetscCall(PetscFVGetNumComponents(fv, &Nc));
104 PetscCall(PetscArraycpy(interpolant, x, Nc));
105 PetscFunctionReturn(PETSC_SUCCESS);
106 }
107