xref: /petsc/include/petsc/private/petscfvimpl.h (revision 1ceb14c030f320ad962f864c6f8de98a26bbbaf7)
1 #if !defined(_PETSCFVIMPL_H)
2 #define _PETSCFVIMPL_H
3 
4 #include <petscfv.h>
5 #include <petsc/private/petscimpl.h>
6 
7 PETSC_EXTERN PetscBool PetscLimiterRegisterAllCalled;
8 PETSC_EXTERN PetscBool PetscFVRegisterAllCalled;
9 PETSC_EXTERN PetscErrorCode PetscLimiterRegisterAll(void);
10 PETSC_EXTERN PetscErrorCode PetscFVRegisterAll(void);
11 
12 typedef struct _PetscLimiterOps *PetscLimiterOps;
13 struct _PetscLimiterOps {
14   PetscErrorCode (*setfromoptions)(PetscLimiter);
15   PetscErrorCode (*setup)(PetscLimiter);
16   PetscErrorCode (*view)(PetscLimiter,PetscViewer);
17   PetscErrorCode (*destroy)(PetscLimiter);
18   PetscErrorCode (*limit)(PetscLimiter, PetscReal, PetscReal *);
19 };
20 
21 struct _p_PetscLimiter {
22   PETSCHEADER(struct _PetscLimiterOps);
23   void           *data;             /* Implementation object */
24 };
25 
26 typedef struct {
27   PetscInt dummy;
28 } PetscLimiter_Sin;
29 
30 typedef struct {
31   PetscInt dummy;
32 } PetscLimiter_Zero;
33 
34 typedef struct {
35   PetscInt dummy;
36 } PetscLimiter_None;
37 
38 typedef struct {
39   PetscInt dummy;
40 } PetscLimiter_Minmod;
41 
42 typedef struct {
43   PetscInt dummy;
44 } PetscLimiter_VanLeer;
45 
46 typedef struct {
47   PetscInt dummy;
48 } PetscLimiter_VanAlbada;
49 
50 typedef struct {
51   PetscInt dummy;
52 } PetscLimiter_Superbee;
53 
54 typedef struct {
55   PetscInt dummy;
56 } PetscLimiter_MC;
57 
58 typedef struct _PetscFVOps *PetscFVOps;
59 struct _PetscFVOps {
60   PetscErrorCode (*setfromoptions)(PetscFV);
61   PetscErrorCode (*setup)(PetscFV);
62   PetscErrorCode (*view)(PetscFV,PetscViewer);
63   PetscErrorCode (*destroy)(PetscFV);
64   PetscErrorCode (*computegradient)(PetscFV, PetscInt, const PetscScalar[], PetscScalar []);
65   PetscErrorCode (*integraterhsfunction)(PetscFV, PetscDS, PetscInt, PetscInt, PetscFVFaceGeom *, PetscReal *, PetscScalar[], PetscScalar[], PetscScalar[], PetscScalar[]);
66 };
67 
68 struct _p_PetscFV {
69   PETSCHEADER(struct _PetscFVOps);
70   void           *data;             /* Implementation object */
71   PetscLimiter    limiter;          /* The slope limiter */
72   PetscDualSpace  dualSpace;        /* The dual space P', usually simple */
73   PetscInt        numComponents;    /* The number of field components */
74   PetscInt        dim;              /* The spatial dimension */
75   PetscBool       computeGradients; /* Flag for gradient computation */
76   PetscScalar    *fluxWork;         /* The work array for flux calculation */
77   PetscQuadrature quadrature;       /* Suitable quadrature on the volume */
78   PetscReal      *B, *D, *H;        /* Tabulation of pseudo-basis and derivatives at quadrature points */
79 };
80 
81 typedef struct {
82   PetscInt cellType;
83 } PetscFV_Upwind;
84 
85 typedef struct {
86   PetscInt     maxFaces, workSize;
87   PetscScalar *B, *Binv, *tau, *work;
88 } PetscFV_LeastSquares;
89 
90 #undef __FUNCT__
91 #define __FUNCT__ "PetscFVInterpolate_Static"
92 PETSC_STATIC_INLINE PetscErrorCode PetscFVInterpolate_Static(PetscFV fv, const PetscScalar x[], PetscInt q, PetscScalar interpolant[])
93 {
94   PetscInt       Nc, fc;
95   PetscErrorCode ierr;
96 
97   PetscFunctionBeginHot;
98   ierr = PetscFVGetNumComponents(fv, &Nc);CHKERRQ(ierr);
99   for (fc = 0; fc < Nc; ++fc) {interpolant[fc] = x[fc];}
100   PetscFunctionReturn(0);
101 }
102 
103 #endif
104