ABLATE Source Documentation  0.12.34
faceInterpolant.hpp
1 #ifndef ABLATELIBRARY_FACEINTERPOLANT_HPP
2 #define ABLATELIBRARY_FACEINTERPOLANT_HPP
3 
4 #include <memory>
5 #include "domain/range.hpp"
6 #include "domain/subDomain.hpp"
7 #include "stencils/stencil.hpp"
8 
9 namespace ablate::finiteVolume {
10 
12  private:
14  std::shared_ptr<ablate::domain::SubDomain> subDomain;
15 
17  PetscInt solTotalSize = 0;
18 
20  PetscInt auxTotalSize = 0;
21 
23  PetscInt globalFaceStart = -1;
24 
28  DM faceSolutionDm = nullptr;
29 
33  DM faceSolutionGradDm = nullptr;
34 
38  DM faceAuxDm = nullptr;
39 
43  DM faceAuxGradDm = nullptr;
44 
51  static void CreateFaceDm(PetscInt totalDim, DM dm, DM& newDm);
52 
56  std::vector<stencil::Stencil> stencils;
57 
58  template <class I, class T>
59  static inline void AddToArray(I size, const T* input, T* sum, T factor) {
60  for (I d = 0; d < size; d++) {
61  sum[d] += factor * input[d];
62  }
63  }
64 
65  public:
72  FaceInterpolant(const std::shared_ptr<ablate::domain::SubDomain>& subDomain, const std::shared_ptr<domain::Region> solverRegion, Vec faceGeomVec, Vec cellGeomVec);
73  ~FaceInterpolant();
74 
78  using ContinuousFluxFunction = PetscErrorCode (*)(PetscInt dim, const PetscFVFaceGeom* fg, const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar field[], const PetscScalar grad[],
79  const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar aux[], const PetscScalar gradAux[], PetscScalar flux[], void* ctx);
80 
85  ContinuousFluxFunction function;
86  void* context;
87 
88  PetscInt field;
89  std::vector<PetscInt> inputFields;
90  std::vector<PetscInt> auxFields;
91  };
92 
99  void ComputeRHS(PetscReal time, Vec locXVec, Vec locAuxVec, Vec locFVec, const std::shared_ptr<domain::Region>& solverRegion,
100  std::vector<FaceInterpolant::ContinuousFluxFunctionDescription>& rhsFunctions, const ablate::domain::Range& faceRange, Vec cellGeomVec, Vec faceGeomVec);
101 
111  void GetInterpolatedFaceVectors(Vec solutionVec, Vec auxVec, Vec& faceSolutionVec, Vec& faceAuxVec, Vec& faceSolutionGradVec, Vec& faceAuxGradVec);
112 
122  void RestoreInterpolatedFaceVectors(Vec solutionVec, Vec auxVec, Vec& faceSolutionVec, Vec& faceAuxVec, Vec& faceSolutionGradVec, Vec& faceAuxGradVec);
123 };
124 
125 } // namespace ablate::finiteVolume
126 #endif // ABLATELIBRARY_FACEINTERPOLANT_HPP
Definition: faceInterpolant.hpp:11
FaceInterpolant(const std::shared_ptr< ablate::domain::SubDomain > &subDomain, const std::shared_ptr< domain::Region > solverRegion, Vec faceGeomVec, Vec cellGeomVec)
Definition: faceInterpolant.cpp:7
void GetInterpolatedFaceVectors(Vec solutionVec, Vec auxVec, Vec &faceSolutionVec, Vec &faceAuxVec, Vec &faceSolutionGradVec, Vec &faceAuxGradVec)
Definition: faceInterpolant.cpp:109
void RestoreInterpolatedFaceVectors(Vec solutionVec, Vec auxVec, Vec &faceSolutionVec, Vec &faceAuxVec, Vec &faceSolutionGradVec, Vec &faceAuxGradVec)
Definition: faceInterpolant.cpp:251
void ComputeRHS(PetscReal time, Vec locXVec, Vec locAuxVec, Vec locFVec, const std::shared_ptr< domain::Region > &solverRegion, std::vector< FaceInterpolant::ContinuousFluxFunctionDescription > &rhsFunctions, const ablate::domain::Range &faceRange, Vec cellGeomVec, Vec faceGeomVec)
Definition: faceInterpolant.cpp:262
PetscErrorCode(*)(PetscInt dim, const PetscFVFaceGeom *fg, const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar field[], const PetscScalar grad[], const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar aux[], const PetscScalar gradAux[], PetscScalar flux[], void *ctx) ContinuousFluxFunction
Definition: faceInterpolant.hpp:79
Definition: range.hpp:11