Chombo + EB + MF  3.2
FourthOrderCoordSys.H
Go to the documentation of this file.
1 #ifdef CH_LANG_CC
2 /*
3  * _______ __
4  * / ___/ / ___ __ _ / / ___
5  * / /__/ _ \/ _ \/ V \/ _ \/ _ \
6  * \___/_//_/\___/_/_/_/_.__/\___/
7  * Please refer to Copyright.txt, in Chombo's root directory.
8  */
9 #endif
10 
11 #ifndef _FOURTHORDERCOORDSYS_H_
12 #define _FOURTHORDERCOORDSYS_H_
13 
14 #include "REAL.H"
15 #include "DisjointBoxLayout.H"
16 #include "RealVect.H"
17 #include "IntVect.H"
18 #include "LevelData.H"
19 #include "FArrayBox.H"
20 #include "FluxBox.H"
21 #include "Vector.H"
22 #include "LoHiSide.H"
23 #include "CoordSys.H"
24 #include "EdgeQuadrature.H"
25 #include "MayDay.H"
26 #include "NamespaceHeader.H"
27 
28 /// Virtual base class encapsulating fourth-order CoordSys
29 /**
30  The FourthOrderCoordSys class extends the CoordSys base class by
31  providing API elements and implementation details specific to
32  fourth-order discretizaitions.
33  Implementations of specific coordinate systems will be provided by
34  derived classes.
35 */
36 class FourthOrderCoordSys : public CoordSys<FArrayBox, FluxBox>
37 {
38 public:
39  /// default constructor
41 
42  /**
43  Destructor.
44  */
45  virtual ~FourthOrderCoordSys();
46 
47 
48  /// this define should probably be called from the derived-class define
49  virtual void define(const DisjointBoxLayout& a_grids,
50  const ProblemDomain& a_domain,
51  const RealVect& a_cellSpacing,
52  const IntVect& a_ghostVect);
53 
54  virtual void regrid(const DisjointBoxLayout& a_newGrids) = 0;
55 
56  virtual RealVect realCoord(const RealVect& a_Xi) const = 0;
57 
58  virtual RealVect mappedCoord(const RealVect& a_x) const = 0;
59 
60  // default implementation just uses
61  virtual void realCoord(FArrayBox& a_x, const FArrayBox& a_Xi) const;
62 
63  virtual void mappedCoord(FArrayBox& a_Xi, const FArrayBox& a_x) const;
64 
65 
66  virtual Real pointwiseJ(const RealVect& a_X) const;
67 
68  /// Jacobian evaluated at index locations of a_J
69  virtual void pointwiseJ(FArrayBox& a_J) const;
70 
71  virtual void pointwiseJ(FArrayBox& a_J, const FArrayBox& a_Xi) const;
72 
73  virtual void mappedGridDivergence(LevelData<FArrayBox>& a_divF,
74  const LevelData<FluxBox>& a_F) const;
75 
76  virtual void simpleDivergence(LevelData<FArrayBox>& a_divF,
77  const LevelData<FluxBox>& a_F) const;
78 
79  virtual void setQuadrature(const EdgeQuadrature* a_quadrature);
80 
81  /// reuturns reference to face-averaged N
82  virtual const LevelData<FluxBox>& getFaceMetricTerms() const;
83 
84  /// returns reference to tangential gradients of N
85  virtual const LevelData<FluxBox>& getTanGranNTerms() const
86  {
87  return m_tanGradNTerms;
88  }
89 
90  virtual int tanGradComp(const int a_faceDir, const int a_tanDir,
91  const int a_comp) const;
92 
93  virtual const LevelData<FArrayBox>& getCellVolumes() const;
94 
95  /// returns fourth-order averaged cell-centered J
96  virtual const LevelData<FArrayBox>& getJ() const;
97 
98  /// returns fourth-order averaged face-centered 1/J
99  virtual const LevelData<FluxBox>& getJInverse() const;
100 
101  /// returns fourth-order averaged face-centered N/J
102  virtual const LevelData<FluxBox>& getNJinverse() const;
103 
104 
105  virtual void computeTangentialGrad(LevelData<FluxBox>& a_gradPhi,
106  const LevelData<FluxBox>& a_phiFace) const;
107 
108 
109  /// helper function
110  /** given face-centered phi, increment with Laplacian(phi) correction
111  in place to compute 4th-order face averages of phi
112  */
113 // virtual void fourthOrderAverage(LevelData<FluxBox>& a_phi) const;
114 
115 
116  /// computes 4th-order average of product = F*G
117  virtual void computeProductAverage(LevelData<FluxBox>& a_product,
118  const LevelData<FluxBox>& a_F,
119  const LevelData<FluxBox>& a_G,
120  bool a_fourthOrder = true) const;
121 
122 
123  /// computes 4th-order average of product = N^T*F
124  /** if a_fourthOrder is false, then only do a second-order dot product
125  */
126  virtual void computeMetricTermProductAverage(LevelData<FluxBox>& a_product,
127  const LevelData<FluxBox>& a_F,
128  bool a_fourthOrder=true) const;
129 
130  /// index function into face-centered metric terms
131  /** returns which component of the face-centered metric term in
132  which N^row_col is stored
133  */
134  static inline int getMetricTermComponent(const int a_row, const int a_col)
135  {
136  return (SpaceDim*a_col) + a_row;
137  }
138 
139  /// note that a_X is in real (not mapped) space.
140  virtual Real dXdXi(const RealVect& a_X, int a_dirX,
141  int a_dirXi) const = 0;
142 
143  /// note that a_X is in real (not mapped) space.
144  /** fills the destComp component of a_dxdXi
145  with the derivative of x w/ respect to Xi
146  in the dirX direction
147  Note that the default implementation of this in
148  FourthOrderCoordSys class throws an error, since there is no
149  way to get real=space coordinate x from index location except in
150  the derived class..
151  (default implementation is there in case derived class doesn't
152  provide it)
153  */
154  virtual void dXdXi(FArrayBox& a_dxdXi,
155  const FArrayBox& a_X,
156  int a_destComp,
157  int a_dirX,
158  int a_dirXi) const;
159 
160  /// which component directions to use when computing cell volumes
162 
163  /// access function to simplify things -- returns mapped-space cell spacing
164  const RealVect& dx() const
165  {
166  return m_dx;
167  }
168 
169  /// access function, returns mapped-space problem domain
170  const ProblemDomain& domain() const
171  {
172  return m_domain;
173  }
174 
175  /// access function -- returns const reference to grids
176  const DisjointBoxLayout& grids() const
177  {
178  return m_grids;
179  }
180 
181  /// access function -- returns const reference to number of ghost cells
182  const IntVect& ghostVect() const
183  {
184  return m_ghostVect;
185  }
186 
187 protected:
188 
190 
192 
194 
196 
198 
200 
202 
204 
206 
208 
210 
211  /// note that a_X is in real (not mapped) space.
212  virtual Real getN(const RealVect& a_X, int a_s, int a_d, int a_d1) const;
213 
214  /// note that a_X is in real (not mapped) space.
215  virtual Real getNMatrixEntry(const RealVect& a_X,
216  int a_s, int a_d, int a_d1,
217  int a_row, int a_column) const;
218 
219 
220  virtual void defineFaceMetricTerms(LevelData<FluxBox>& a_faceMetricTerms);
221 
222  virtual void incrementFaceMetricWithEdgeTerm(FArrayBox& a_faceMetrics,
223  int a_faceDir,
224  int a_edgeDir,
225  const Side::LoHiSide& a_side);
226 
227  virtual void computeTransverseFaceMetric(FArrayBox& a_faceMetrics,
228  int a_faceDir,
229  int a_dDir);
230 
231  virtual void computeCellVolumes(LevelData<FArrayBox>& a_cellVolumes);
232 
233  virtual void computeJ(LevelData<FArrayBox>& a_J);
234 
235  virtual void computeJinverse(LevelData<FluxBox>& a_Jinverse);
236 
237  virtual void computeNJinverse(LevelData<FluxBox>& a_NJinverse);
238 };
239 
240 #include "NamespaceFooter.H"
241 
242 #endif
243 
virtual void setQuadrature(const EdgeQuadrature *a_quadrature)
LevelData< FArrayBox > m_cellVolumes
Definition: FourthOrderCoordSys.H:201
EdgeQuadrature * m_quadraturePtr
Definition: FourthOrderCoordSys.H:209
virtual Real dXdXi(const RealVect &a_X, int a_dirX, int a_dirXi) const =0
note that a_X is in real (not mapped) space.
virtual ~FourthOrderCoordSys()
virtual RealVect realCoord(const RealVect &a_Xi) const =0
given coordinate in mapped space, return its location in real space
virtual Real getN(const RealVect &a_X, int a_s, int a_d, int a_d1) const
note that a_X is in real (not mapped) space.
virtual void simpleDivergence(LevelData< FArrayBox > &a_divF, const LevelData< FluxBox > &a_F) const
A class to facilitate interaction with physical boundary conditions.
Definition: ProblemDomain.H:141
ProblemDomain m_domain
Definition: FourthOrderCoordSys.H:193
RealVect m_dx
Definition: FourthOrderCoordSys.H:191
virtual void incrementFaceMetricWithEdgeTerm(FArrayBox &a_faceMetrics, int a_faceDir, int a_edgeDir, const Side::LoHiSide &a_side)
const DisjointBoxLayout & grids() const
access function – returns const reference to grids
Definition: FourthOrderCoordSys.H:176
virtual void computeCellVolumes(LevelData< FArrayBox > &a_cellVolumes)
virtual void computeProductAverage(LevelData< FluxBox > &a_product, const LevelData< FluxBox > &a_F, const LevelData< FluxBox > &a_G, bool a_fourthOrder=true) const
helper function
Virtual base class encapsulating fourth-order CoordSys.
Definition: FourthOrderCoordSys.H:36
virtual Real pointwiseJ(const RealVect &a_X) const
Jacobian evaluated at location X in real space.
virtual int tanGradComp(const int a_faceDir, const int a_tanDir, const int a_comp) const
virtual void computeMetricTermProductAverage(LevelData< FluxBox > &a_product, const LevelData< FluxBox > &a_F, bool a_fourthOrder=true) const
computes 4th-order average of product = N^T*F
const int SpaceDim
Definition: SPACE.H:38
const RealVect & dx() const
access function to simplify things – returns mapped-space cell spacing
Definition: FourthOrderCoordSys.H:164
virtual const LevelData< FluxBox > & getTanGranNTerms() const
returns reference to tangential gradients of N
Definition: FourthOrderCoordSys.H:85
const ProblemDomain & domain() const
access function, returns mapped-space problem domain
Definition: FourthOrderCoordSys.H:170
LevelData< FluxBox > m_NinverseJ
Definition: FourthOrderCoordSys.H:207
virtual const LevelData< FArrayBox > & getJ() const
returns fourth-order averaged cell-centered J
virtual void defineFaceMetricTerms(LevelData< FluxBox > &a_faceMetricTerms)
IntVect m_ghostVect
Definition: FourthOrderCoordSys.H:195
Structure for passing component ranges in code.
Definition: Interval.H:23
virtual const LevelData< FluxBox > & getFaceMetricTerms() const
reuturns reference to face-averaged N
LevelData< FluxBox > m_tanGradNTerms
Definition: FourthOrderCoordSys.H:199
FourthOrderCoordSys()
default constructor
DisjointBoxLayout m_grids
Definition: FourthOrderCoordSys.H:189
LevelData< FArrayBox > m_J
Definition: FourthOrderCoordSys.H:203
double Real
Definition: REAL.H:33
Virtual base class encapsulating mapped-grid coordinate systems.
Definition: CoordSys.H:27
LevelData< FluxBox > m_JInverse
Definition: FourthOrderCoordSys.H:205
A BoxLayout that has a concept of disjointedness.
Definition: DisjointBoxLayout.H:30
virtual void computeTransverseFaceMetric(FArrayBox &a_faceMetrics, int a_faceDir, int a_dDir)
LoHiSide
Definition: LoHiSide.H:27
virtual RealVect mappedCoord(const RealVect &a_x) const =0
given coordinate in real space, return its location in the mapped space
virtual void computeJinverse(LevelData< FluxBox > &a_Jinverse)
A Real vector in SpaceDim-dimensional space.
Definition: RealVect.H:41
virtual void computeTangentialGrad(LevelData< FluxBox > &a_gradPhi, const LevelData< FluxBox > &a_phiFace) const
virtual void define(const DisjointBoxLayout &a_grids, const ProblemDomain &a_domain, const RealVect &a_cellSpacing, const IntVect &a_ghostVect)
this define should probably be called from the derived-class define
virtual const LevelData< FArrayBox > & getCellVolumes() const
virtual const LevelData< FluxBox > & getNJinverse() const
returns fourth-order averaged face-centered N/J
const IntVect & ghostVect() const
access function – returns const reference to number of ghost cells
Definition: FourthOrderCoordSys.H:182
An integer Vector in SpaceDim-dimensional space.
Definition: CHArray.H:42
Definition: FArrayBox.H:45
virtual void regrid(const DisjointBoxLayout &a_newGrids)=0
static int getMetricTermComponent(const int a_row, const int a_col)
index function into face-centered metric terms
Definition: FourthOrderCoordSys.H:134
virtual Real getNMatrixEntry(const RealVect &a_X, int a_s, int a_d, int a_d1, int a_row, int a_column) const
note that a_X is in real (not mapped) space.
virtual void mappedGridDivergence(LevelData< FArrayBox > &a_divF, const LevelData< FluxBox > &a_F) const
returns integral of divergence over mapped-grid cells
virtual const LevelData< FluxBox > & getJInverse() const
returns fourth-order averaged face-centered 1/J
virtual void computeJ(LevelData< FArrayBox > &a_J)
Interval m_volInterval
which component directions to use when computing cell volumes
Definition: FourthOrderCoordSys.H:161
Virtual base class for defining edge-based quadratures.
Definition: EdgeQuadrature.H:37
virtual void computeNJinverse(LevelData< FluxBox > &a_NJinverse)
LevelData< FluxBox > m_faceMetricTerms
Definition: FourthOrderCoordSys.H:197