1 /* 2 Objects which encapsulate finite volume spaces and operations 3 */ 4 #if !defined(__PETSCFV_H) 5 #define __PETSCFV_H 6 #include <petscdm.h> 7 #include <petscdt.h> 8 #include <petscfvtypes.h> 9 10 PETSC_EXTERN PetscClassId PETSCLIMITER_CLASSID; 11 12 /*J 13 PetscLimiterType - String with the name of a PETSc finite volume slope limiter 14 15 Level: beginner 16 17 .seealso: PetscLimiterSetType(), PetscLimiter 18 J*/ 19 typedef const char *PetscLimiterType; 20 #define PETSCLIMITERSIN "sin" 21 22 PETSC_EXTERN PetscFunctionList PetscLimiterList; 23 PETSC_EXTERN PetscBool PetscLimiterRegisterAllCalled; 24 PETSC_EXTERN PetscErrorCode PetscLimiterCreate(MPI_Comm, PetscLimiter *); 25 PETSC_EXTERN PetscErrorCode PetscLimiterDestroy(PetscLimiter *); 26 PETSC_EXTERN PetscErrorCode PetscLimiterSetType(PetscLimiter, PetscLimiterType); 27 PETSC_EXTERN PetscErrorCode PetscLimiterGetType(PetscLimiter, PetscLimiterType *); 28 PETSC_EXTERN PetscErrorCode PetscLimiterSetUp(PetscLimiter); 29 PETSC_EXTERN PetscErrorCode PetscLimiterSetFromOptions(PetscLimiter); 30 PETSC_EXTERN PetscErrorCode PetscLimiterViewFromOptions(PetscLimiter, const char[], const char[]); 31 PETSC_EXTERN PetscErrorCode PetscLimiterView(PetscLimiter, PetscViewer); 32 PETSC_EXTERN PetscErrorCode PetscLimiterRegister(const char [], PetscErrorCode (*)(PetscLimiter)); 33 PETSC_EXTERN PetscErrorCode PetscLimiterRegisterAll(void); 34 PETSC_EXTERN PetscErrorCode PetscLimiterRegisterDestroy(void); 35 36 PETSC_EXTERN PetscErrorCode PetscLimiterLimit(PetscLimiter, PetscReal, PetscReal *); 37 38 39 PETSC_EXTERN PetscErrorCode PetscFVInitializePackage(void); 40 41 PETSC_EXTERN PetscClassId PETSCFV_CLASSID; 42 43 /*J 44 PetscFVType - String with the name of a PETSc finite volume discretization 45 46 Level: beginner 47 48 .seealso: PetscFVSetType(), PetscFV 49 J*/ 50 typedef const char *PetscFVType; 51 #define PETSCFVUPWIND "upwind" 52 #define PETSCFVLEASTSQUARES "leastsquares" 53 54 PETSC_EXTERN PetscFunctionList PetscFVList; 55 PETSC_EXTERN PetscBool PetscFVRegisterAllCalled; 56 PETSC_EXTERN PetscErrorCode PetscFVCreate(MPI_Comm, PetscFV *); 57 PETSC_EXTERN PetscErrorCode PetscFVDestroy(PetscFV *); 58 PETSC_EXTERN PetscErrorCode PetscFVSetType(PetscFV, PetscFVType); 59 PETSC_EXTERN PetscErrorCode PetscFVGetType(PetscFV, PetscFVType *); 60 PETSC_EXTERN PetscErrorCode PetscFVSetUp(PetscFV); 61 PETSC_EXTERN PetscErrorCode PetscFVSetFromOptions(PetscFV); 62 PETSC_EXTERN PetscErrorCode PetscFVViewFromOptions(PetscFV, const char[], const char[]); 63 PETSC_EXTERN PetscErrorCode PetscFVView(PetscFV, PetscViewer); 64 PETSC_EXTERN PetscErrorCode PetscFVRegister(const char [], PetscErrorCode (*)(PetscFV)); 65 PETSC_EXTERN PetscErrorCode PetscFVRegisterAll(void); 66 PETSC_EXTERN PetscErrorCode PetscFVRegisterDestroy(void); 67 68 PETSC_EXTERN PetscErrorCode PetscFVSetLimiter(PetscFV, PetscLimiter); 69 PETSC_EXTERN PetscErrorCode PetscFVGetLimiter(PetscFV, PetscLimiter *); 70 PETSC_EXTERN PetscErrorCode PetscFVSetNumComponents(PetscFV, PetscInt); 71 PETSC_EXTERN PetscErrorCode PetscFVGetNumComponents(PetscFV, PetscInt *); 72 PETSC_EXTERN PetscErrorCode PetscFVSetSpatialDimension(PetscFV, PetscInt); 73 PETSC_EXTERN PetscErrorCode PetscFVGetSpatialDimension(PetscFV, PetscInt *); 74 PETSC_EXTERN PetscErrorCode PetscFVSetComputeGradients(PetscFV, PetscBool); 75 PETSC_EXTERN PetscErrorCode PetscFVGetComputeGradients(PetscFV, PetscBool *); 76 77 PETSC_EXTERN PetscErrorCode PetscFVComputeGradient(PetscFV, PetscInt, PetscScalar[], PetscScalar[]); 78 PETSC_EXTERN PetscErrorCode PetscFVIntegrateRHSFunction(PetscFV, PetscInt, PetscInt, PetscFV[], PetscInt, PetscCellGeometry, PetscCellGeometry, PetscScalar[], PetscScalar[], 79 void (*)(const PetscReal[], const PetscReal[], const PetscScalar[], const PetscScalar[], PetscScalar[], void *), 80 PetscScalar[], PetscScalar[], void *); 81 82 PETSC_EXTERN PetscErrorCode PetscFVLeastSquaresSetMaxFaces(PetscFV, PetscInt); 83 84 /* Assuming dim == 3 */ 85 typedef struct { 86 PetscReal normal[3]; /* Area-scaled normals */ 87 PetscReal centroid[3]; /* Location of centroid (quadrature point) */ 88 PetscScalar grad[2][3]; /* Face contribution to gradient in left and right cell */ 89 } FaceGeom; 90 91 typedef struct { 92 PetscReal centroid[3]; 93 PetscReal volume; 94 } CellGeom; 95 96 #endif 97