Chombo + EB + MF  3.2
NewCoordSys.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 _NEWCOORDSYS_H_
12 #define _NEWCOORDSYS_H_
13 
14 #include "REAL.H"
15 #include "RealVect.H"
16 #include "FArrayBox.H"
17 #include "FluxBox.H"
18 #include "ProblemDomain.H"
19 #include "VectorTransformation.H"
20 
21 #include "NamespaceHeader.H"
22 
23 /// Virtual base class encapsulating mapped-grid coordinate systems
24 /**
25  The CoordSys class is a pure-virtual base class providing an API
26  for performing operations in a mapped grid coordinate space.
27  Implementations of specific coordinate systems will be provided by
28  derived classes.
29 */
31 {
32 public:
33  /// default constructor
35  : m_time(0.)
36  {
37  }
38 
39  /**
40  Destructor.
41  */
42  virtual ~NewCoordSys()
43  {;}
44 
45  /// given coordinate in mapped space, return its location in real space
46  virtual RealVect realCoord(const RealVect& a_Xi) const = 0;
47 
48  /// given coordinate in real space, return its location in the mapped space
49  virtual RealVect mappedCoord(const RealVect& a_x) const = 0;
50 
51  /// given coordinates in mapped space, return locations in real space
52  virtual void realCoord(FArrayBox& a_x, const FArrayBox& a_Xi,
53  const Box& a_box) const;
54 
55  /// given coordinate in real space, return its location in the mapped space
56  virtual void mappedCoord(FArrayBox& a_Xi, const FArrayBox& a_x,
57  const Box& a_box) const;
58 
59  /// given indices in a_box, return centers of cells (or of faces, or of edges) in mapped coordinates. The function does the right thing based on the centering of a_box, which must be the same centering as a_Xi.
60  virtual void getCenterMappedCoordinates(FArrayBox& a_Xi,
61  const Box& a_box) const;
62 
63  /// given indices, return centers of cells in mapped coordinates
64  virtual RealVect centerMappedCoordinates(const IntVect& a_iv) const;
65 
66  /// return Cartesian XYZ locations of nodes
67  /** nodeCoords should have dimension returned by dimension()
68  */
69  virtual void getNodeRealCoordinates(FArrayBox& a_nodeCoords,
70  const Box& a_box) const =0;
71 
72 
73  /// note that a_Xi is in mapped space.
74  virtual Real dXdXi(const RealVect& a_Xi,
75  int a_dirX,
76  int a_dirXi) const = 0;
77 
78  /// note that a_Xi is in mapped space.
79  /** fills the destComp component of a_dxdXi
80  with the derivative of x w/ respect to Xi
81  in the dirX direction
82  Note that the default implementation of this in
83  FourthOrderCoordSys class throws an error, since there is no
84  way to get real=space coordinate x from index location except in
85  the derived class..
86  (default implementation is there in case derived class doesn't
87  provide it)
88  */
89  virtual void dXdXi(FArrayBox& a_dxdXi,
90  const FArrayBox& a_Xi,
91  int a_destComp,
92  int a_dirX,
93  int a_dirXi,
94  const Box& a_box) const;
95 
96 
97  /// returns number of components in the metric term matrix (N)
98  virtual int getNumN() const = 0;
99 
100  /// index function into face-centered metric terms
101  /** returns which component of the face-centered metric term in
102  which N^row_col is stored
103  */
104  virtual int getNcomponent(const int a_row, const int a_col) const = 0;
105 
106 
107  /// returns dimensionality of the space
108  /**
109  The dimensionality of the space may not be SpaceDim if, for example
110  we're computing on a manifold. One example of this is the
111  surface-of-a-sphere mapping, which is a 2D surface in a 3D space.
112  For that case, dimension() would return 3 even though SpaceDim is 2.
113  Default implementation returns SpaceDim.
114  */
115  virtual int dimension() const
116  {
117  return SpaceDim;
118  }
119 
120  /// computes cell volumes
121  /**
122  Return cell volume in a_vol on cells of a_box,
123  using a_N from getN() defined on a_box grown by 1.
124  */
125  virtual void cellVol(FArrayBox& a_vol,
126  const FluxBox& a_N,
127  const Box& a_box) const = 0;
128 
129  /// computes integral of N over each face of a_box
130  virtual void getN(FluxBox& a_N, const Box& a_box) const = 0;
131 
132  /// computes cell-averaged J
133  virtual void getAvgJ(FArrayBox& a_avgJ, const Box& a_box) const = 0;
134 
135 
136  /// computes face-averaged 1/J
137  virtual void getAvgJinverse(FluxBox& a_avgJinverse,
138  const Box& a_box) const = 0;
139  /// Jacobian evaluated at location Xi in mapped space
140  virtual Real pointwiseJ(const RealVect& a_Xi) const = 0;
141 
142  /// Jacobian evaluated at locations Xi in mapped space
143  virtual void pointwiseJ(FArrayBox& a_J,
144  const FArrayBox& a_Xi,
145  const Box& a_box) const;
146 
147  /// returns integral of divergence over mapped-grid cells
148  virtual void computeDivergence(FArrayBox& a_divF,
149  const FluxBox& a_F,
150  const FluxBox& a_N,
151  const Box& a_box,
152  Interval& divInterval) const;
153 
154  /// computes 4th-order average of product = N^T*F
155  /** if a_fourthOrder is false, then only do a second-order dot product
156  aFforGrad is the F used to compute grad_perp(F);
157  returns results in a_product on a_box;
158  both a_FforGrad and a_N (from getN()) must be defined on a_box grown by 1.
159  */
160  virtual void computeMetricTermProductAverage(FluxBox& a_product,
161  const FluxBox& a_F,
162  const FluxBox& a_N,
163  const FluxBox& a_FforGrad,
164  const Box& a_box,
165  bool a_fourthOrder=true) const =0;
166 
167 
168  /// computes 4th-order average of product = N^T*F
169  /** if a_fourthOrder is false, then only do a second-order dot product;
170  returns results in a_product on a_box;
171  both a_F and a_N (from getN()) must be defined on a_box grown by 1.
172  */
173  virtual void computeMetricTermProductAverage(FluxBox& a_product,
174  const FluxBox& a_F,
175  const FluxBox& a_N,
176  const Box& a_box,
177  bool a_fourthOrder=true) const;
178 
179  /// return matrix that transforms vector components from mapped space to real space at point a_Xi in mapped space
181 
182  /// return matrix that transforms vector components from real space to mapped space at point a_Xi in mapped space
184 
185  /// return matrix that transforms vector components from mapped space to real space at center of cell a_iv
187 
188  /// return matrix that transforms vector components from real space to mapped space at center of cell a_iv
190 
191  /// transform a FAB of SpaceDim-vectors from mapped-coordinate basis to real-coordinate basis at cell centers
192  virtual void vectorTransformMappedToRealCenterFab(FArrayBox& a_vectorFab) const;
193 
194  /// transform a FAB of SpaceDim-vectors from mapped-coordinate basis to real-coordinate basis, averaged over cells
195  virtual void vectorTransformMappedToRealAvgFab(FArrayBox& a_vectorFab,
196  const FArrayBox& a_gradVectorFab) const;
197 
198  /// transform a FAB of SpaceDim-vectors from real-coordinate basis to mapped-coordinate basis at cell centers
199  virtual void vectorTransformRealToMappedCenterFab(FArrayBox& a_vectorFab) const;
200 
201  /// transform a FAB of SpaceDim-vectors from real-coordinate basis to mapped-coordinate basis, averaged over cells
202  virtual void vectorTransformRealToMappedAvgFab(FArrayBox& a_vectorFab,
203  const FArrayBox& a_gradVectorFab) const;
204 
205  /// access function to simplify things -- returns mapped-space cell spacing
206  virtual const RealVect& dx() const =0;
207 
208  /// Set time for moving grids
209  virtual void setTime(const Real& a_time) const;
210 
211 protected:
212 
213  /// internal function to transform a FAB of SpaceDim-vectors from one basis to another, averaged over cells, given BaseFab of vector transformations at cell centers
214  virtual void vectorTransformInternalAvgFab(FArrayBox& a_vectorFab,
215  const FArrayBox& a_gradVectorFab,
216  const BaseFab<VectorTransformation>& a_tfmCenterFab) const;
217 
218  mutable Real m_time; ///< Const is already well entrenched
219 };
220 
221 
222 /*******************************************************************************
223  *
224  * Class NewCoordSys: inline member definitions
225  *
226  ******************************************************************************/
227 
228 // Set time for moving grids
229 inline void
230 NewCoordSys::setTime(const Real& a_time) const
231 {
232  m_time = a_time;
233 }
234 
235 /// pure-virtual base class defining factory interface for CoordSys
236 class
238 {
239 
240 
241 public:
242 
244  {
245  }
246 
248  {
249  }
250 
251  virtual NewCoordSys* getCoordSys(const ProblemDomain& levelDomain,
252  const RealVect& a_dx) const = 0;
253 };
254 
255 #include "NamespaceFooter.H"
256 
257 #endif
virtual VectorTransformation vectorTransformationRealToMapped(const RealVect &a_Xi) const
return matrix that transforms vector components from real space to mapped space at point a_Xi in mapp...
virtual void vectorTransformRealToMappedCenterFab(FArrayBox &a_vectorFab) const
transform a FAB of SpaceDim-vectors from real-coordinate basis to mapped-coordinate basis at cell cen...
virtual VectorTransformation vectorTransformationMappedToRealCenter(const IntVect &a_iv) const
return matrix that transforms vector components from mapped space to real space at center of cell a_i...
virtual void vectorTransformMappedToRealAvgFab(FArrayBox &a_vectorFab, const FArrayBox &a_gradVectorFab) const
transform a FAB of SpaceDim-vectors from mapped-coordinate basis to real-coordinate basis...
A class to facilitate interaction with physical boundary conditions.
Definition: ProblemDomain.H:141
virtual ~NewCoordSysFactory()
Definition: NewCoordSys.H:247
NewCoordSysFactory()
Definition: NewCoordSys.H:243
Class to describe transformation of SpaceDim-vectors, typically from one block to another...
Definition: VectorTransformation.H:23
virtual void setTime(const Real &a_time) const
Set time for moving grids.
Definition: NewCoordSys.H:230
virtual VectorTransformation vectorTransformationMappedToReal(const RealVect &a_Xi) const
return matrix that transforms vector components from mapped space to real space at point a_Xi in mapp...
virtual const RealVect & dx() const =0
access function to simplify things – returns mapped-space cell spacing
virtual int getNcomponent(const int a_row, const int a_col) const =0
index function into face-centered metric terms
const int SpaceDim
Definition: SPACE.H:38
virtual ~NewCoordSys()
Definition: NewCoordSys.H:42
virtual void getCenterMappedCoordinates(FArrayBox &a_Xi, const Box &a_box) const
given indices in a_box, return centers of cells (or of faces, or of edges) in mapped coordinates...
A FArrayBox-like container for face-centered fluxes.
Definition: FluxBox.H:22
Real m_time
Const is already well entrenched.
Definition: NewCoordSys.H:218
virtual RealVect mappedCoord(const RealVect &a_x) const =0
given coordinate in real space, return its location in the mapped space
virtual Real pointwiseJ(const RealVect &a_Xi) const =0
Jacobian evaluated at location Xi in mapped space.
Structure for passing component ranges in code.
Definition: Interval.H:23
NewCoordSys()
default constructor
Definition: NewCoordSys.H:34
virtual int getNumN() const =0
returns number of components in the metric term matrix (N)
virtual RealVect realCoord(const RealVect &a_Xi) const =0
given coordinate in mapped space, return its location in real space
pure-virtual base class defining factory interface for CoordSys
Definition: NewCoordSys.H:236
double Real
Definition: REAL.H:33
virtual void getAvgJ(FArrayBox &a_avgJ, const Box &a_box) const =0
computes cell-averaged J
virtual void getNodeRealCoordinates(FArrayBox &a_nodeCoords, const Box &a_box) const =0
return Cartesian XYZ locations of nodes
virtual void vectorTransformMappedToRealCenterFab(FArrayBox &a_vectorFab) const
transform a FAB of SpaceDim-vectors from mapped-coordinate basis to real-coordinate basis at cell cen...
virtual void computeDivergence(FArrayBox &a_divF, const FluxBox &a_F, const FluxBox &a_N, const Box &a_box, Interval &divInterval) const
returns integral of divergence over mapped-grid cells
virtual void getAvgJinverse(FluxBox &a_avgJinverse, const Box &a_box) const =0
computes face-averaged 1/J
virtual VectorTransformation vectorTransformationRealToMappedCenter(const IntVect &a_iv) const
return matrix that transforms vector components from real space to mapped space at center of cell a_i...
virtual void vectorTransformInternalAvgFab(FArrayBox &a_vectorFab, const FArrayBox &a_gradVectorFab, const BaseFab< VectorTransformation > &a_tfmCenterFab) const
internal function to transform a FAB of SpaceDim-vectors from one basis to another, averaged over cells, given BaseFab of vector transformations at cell centers
A Rectangular Domain on an Integer Lattice.
Definition: Box.H:469
A Real vector in SpaceDim-dimensional space.
Definition: RealVect.H:41
virtual int dimension() const
returns dimensionality of the space
Definition: NewCoordSys.H:115
virtual void cellVol(FArrayBox &a_vol, const FluxBox &a_N, const Box &a_box) const =0
computes cell volumes
An integer Vector in SpaceDim-dimensional space.
Definition: CHArray.H:42
Definition: FArrayBox.H:45
virtual RealVect centerMappedCoordinates(const IntVect &a_iv) const
given indices, return centers of cells in mapped coordinates
virtual Real dXdXi(const RealVect &a_Xi, int a_dirX, int a_dirXi) const =0
note that a_Xi is in mapped space.
virtual void computeMetricTermProductAverage(FluxBox &a_product, const FluxBox &a_F, const FluxBox &a_N, const FluxBox &a_FforGrad, const Box &a_box, bool a_fourthOrder=true) const =0
computes 4th-order average of product = N^T*F
Virtual base class encapsulating mapped-grid coordinate systems.
Definition: NewCoordSys.H:30
virtual void vectorTransformRealToMappedAvgFab(FArrayBox &a_vectorFab, const FArrayBox &a_gradVectorFab) const
transform a FAB of SpaceDim-vectors from real-coordinate basis to mapped-coordinate basis...
virtual void getN(FluxBox &a_N, const Box &a_box) const =0
computes integral of N over each face of a_box