ABLATE Source Documentation  0.12.33
cellInterpolant.hpp
1 #ifndef ABLATELIBRARY_CELLINTERPOLANT_HPP
2 #define ABLATELIBRARY_CELLINTERPOLANT_HPP
3 
4 #include <petsc.h>
5 #include <vector>
6 #include "domain/range.hpp"
7 #include "domain/region.hpp"
8 #include "domain/subDomain.hpp"
9 namespace ablate::finiteVolume {
10 
12  public:
16  using DiscontinuousFluxFunction = PetscErrorCode (*)(PetscInt dim, const PetscFVFaceGeom* fg, const PetscInt uOff[], const PetscScalar fieldL[], const PetscScalar fieldR[], const PetscInt aOff[],
17  const PetscScalar auxL[], const PetscScalar auxR[], PetscScalar flux[], void* ctx);
18 
22  using PointFunction = PetscErrorCode (*)(PetscInt dim, PetscReal time, const PetscFVCellGeom* cg, const PetscInt uOff[], const PetscScalar u[], const PetscInt aOff[], const PetscScalar a[],
23  PetscScalar f[], void* ctx);
24 
27  void* context;
28 
29  PetscInt field;
30  std::vector<PetscInt> inputFields;
31  std::vector<PetscInt> auxFields;
32  };
33 
38  PointFunction function;
39  void* context;
40 
41  std::vector<PetscInt> fields;
42  std::vector<PetscInt> inputFields;
43  std::vector<PetscInt> auxFields;
44  };
45 
46  private:
48  std::shared_ptr<ablate::domain::SubDomain> subDomain;
49 
51  std::vector<DM> gradientCellDms;
52 
56  void ComputeFluxSourceTerms(DM dm, PetscDS ds, PetscInt totDim, const PetscScalar* xArray, DM dmAux, PetscDS dsAux, PetscInt totDimAux, const PetscScalar* auxArray, DM faceDM,
57  const PetscScalar* faceGeomArray, DM cellDM, const PetscScalar* cellGeomArray, std::vector<DM>& dmGrads, std::vector<const PetscScalar*>& locGradArrays,
58  PetscScalar* locFArray, const std::shared_ptr<domain::Region>& solverRegion, std::vector<CellInterpolant::DiscontinuousFluxFunctionDescription>& rhsFunctions,
59  const ablate::domain::Range& faceRange, const ablate::domain::Range& cellRange);
60 
64  void ProjectToFace(const std::vector<domain::Field>& fields, PetscDS ds, const PetscFVFaceGeom& faceGeom, PetscInt cellId, const PetscFVCellGeom& cellGeom, DM dm, const PetscScalar* xArray,
65  const std::vector<DM>& dmGrads, const std::vector<const PetscScalar*>& gradArrays, PetscScalar* u, PetscScalar* grad, bool projectField = true);
66 
78  void ComputeFieldGradients(const domain::Field& field, Vec xLocalVec, Vec& gradLocVec, DM& dmGrad, Vec cellGeomVec, Vec faceGeomVec, const ablate::domain::Range& faceRange,
79  const ablate::domain::Range& cellRange);
80 
92  static PetscErrorCode ComputeGradientFVM(DM dm, DMLabel regionLabel, PetscInt regionValue, PetscFV fvm, Vec faceGeometry, Vec cellGeometry, DM* dmGrad);
93 
94  public:
102  CellInterpolant(std::shared_ptr<ablate::domain::SubDomain> subDomain, const std::shared_ptr<domain::Region>& solverRegion, Vec faceGeomVec, Vec cellGeomVec);
103  ~CellInterpolant();
104 
111  void ComputeRHS(PetscReal time, Vec locXVec, Vec locAuxVec, Vec locFVec, const std::shared_ptr<domain::Region>& solverRegion,
112  std::vector<CellInterpolant::DiscontinuousFluxFunctionDescription>& rhsFunctions, const ablate::domain::Range& faceRange, const ablate::domain::Range& cellRange, Vec cellGeomVec,
113  Vec faceGeomVec);
114 
121  void ComputeRHS(PetscReal time, Vec locXVec, Vec locAuxVec, Vec locFVec, const std::shared_ptr<domain::Region>& solverRegion, std::vector<CellInterpolant::PointFunctionDescription>& rhsFunctions,
122  const ablate::domain::Range& cellRange, Vec cellGeomVec);
123 };
124 
125 } // namespace ablate::finiteVolume
126 
127 #endif // ABLATELIBRARY_CELLINTERPOLANT_HPP
Definition: cellInterpolant.hpp:11
PetscErrorCode(*)(PetscInt dim, const PetscFVFaceGeom *fg, const PetscInt uOff[], const PetscScalar fieldL[], const PetscScalar fieldR[], const PetscInt aOff[], const PetscScalar auxL[], const PetscScalar auxR[], PetscScalar flux[], void *ctx) DiscontinuousFluxFunction
Definition: cellInterpolant.hpp:17
PetscErrorCode(*)(PetscInt dim, PetscReal time, const PetscFVCellGeom *cg, const PetscInt uOff[], const PetscScalar u[], const PetscInt aOff[], const PetscScalar a[], PetscScalar f[], void *ctx) PointFunction
Definition: cellInterpolant.hpp:23
CellInterpolant(std::shared_ptr< ablate::domain::SubDomain > subDomain, const std::shared_ptr< domain::Region > &solverRegion, Vec faceGeomVec, Vec cellGeomVec)
Definition: cellInterpolant.cpp:5
void ComputeRHS(PetscReal time, Vec locXVec, Vec locAuxVec, Vec locFVec, const std::shared_ptr< domain::Region > &solverRegion, std::vector< CellInterpolant::DiscontinuousFluxFunctionDescription > &rhsFunctions, const ablate::domain::Range &faceRange, const ablate::domain::Range &cellRange, Vec cellGeomVec, Vec faceGeomVec)
Definition: cellInterpolant.cpp:42
Definition: field.hpp:17
Definition: range.hpp:11