Chombo + EB + MF  3.2
NewFourthOrderCoordSys.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 _NEWFOURTHORDERCOORDSYS_H_
12 #define _NEWFOURTHORDERCOORDSYS_H_
13 
14 #include "REAL.H"
15 #include "RealVect.H"
16 #include "FArrayBox.H"
17 #include "FluxBox.H"
18 #include "EdgeQuadrature.H"
19 #include "NewCoordSys.H"
20 
21 #include "NamespaceHeader.H"
22 
23 /// Virtual base class encapsulating mapped-grid coordinate systems
24 /**
25  The NewFourthOrderCoordSys class is a pure-virtual base class
26  an API for performing operations in a mapped grid coordinate space.
27  Implementations of specific coordinate systems will be provided by
28  derived classes.
29 
30  The following pure virtual functions of NewCoordSys are defined in
31  NewFourthOrderCoordSys.cpp :
32 
33 
34  virtual void getNodeRealCoordinates(FArrayBox& a_nodeCoords,
35  const Box& a_box) const;
36  // calls virtual RealVect realCoord(const RealVect& a_Xi) const = 0;
37 
38  virtual int getNumN() const
39  {
40  return SpaceDim*SpaceDim;
41  }
42 
43  virtual int getNcomponent(const int a_row, const int a_col) const
44  {return (SpaceDim*a_col) + a_row;}
45 
46  virtual void cellVol(FArrayBox& a_vol,
47  const FluxBox& a_N,
48  const Box& a_box) const;
49  // calls virtual RealVect realCoord(const RealVect& a_Xi) const = 0
50  // on corners, then calls fourthOrderAverageFace and computeDivergence.
51 
52  virtual void getN(FluxBox& a_N, const Box& a_box) const;
53 
54  virtual void getAvgJ(FArrayBox& a_avgJ, const Box& a_box) const;
55  // calls cellVol.
56 
57  virtual void getAvgJinverse(FluxBox& a_avgJinverse,
58  const Box& a_box) const;
59 
60  virtual void pointwiseJ(FArrayBox& a_J,
61  const FArrayBox& a_Xi,
62  const Box& a_box) const;
63  // calls dXdXi.
64 
65  virtual void computeMetricTermProductAverage(FluxBox& a_product,
66  const FluxBox& a_F,
67  const FluxBox& a_N,
68  const FluxBox& a_FforGrad,
69  const Box& a_box,
70  bool a_fourthOrder=true) const;
71 
72  virtual const RealVect& dx() const
73  {
74  return m_dx;
75  }
76 */
78 {
79 public:
80  /// default constructor
82 
83  /**
84  Destructor.
85  */
86  virtual ~NewFourthOrderCoordSys();
87 
88  /// given coordinate in mapped space, return its location in real space
89  virtual RealVect realCoord(const RealVect& a_Xi) const = 0;
90 
91  /// given coordinate in real space, return its location in the mapped space
92  virtual RealVect mappedCoord(const RealVect& a_x) const = 0;
93 
94  /// given coordinates in mapped space, return locations in real space
95  virtual void realCoord(FArrayBox& a_x, const FArrayBox& a_Xi,
96  const Box& a_box) const;
97 
98  /// given coordinate in real space, return its location in the mapped space
99  virtual void mappedCoord(FArrayBox& a_Xi, const FArrayBox& a_x,
100  const Box& a_box) const;
101 
102  /// return Cartesian XYZ locations of nodes
103  /** nodeCoords should have dimension returned by dimension()
104  */
105  virtual void getNodeRealCoordinates(FArrayBox& a_nodeCoords,
106  const Box& a_box) const;
107 
108  /// note that a_Xi is in mapped space.
109  virtual Real dXdXi(const RealVect& a_Xi,
110  int a_dirX,
111  int a_dirXi) const = 0;
112 
113  /// note that a_X is in mapped space.
114  /** fills the destComp component of a_dxdXi
115  with the derivative of x w/ respect to Xi
116  in the dirX direction
117  (default implementation is there in case derived class doesn't
118  provide it)
119  */
120  virtual void dXdXi(FArrayBox& a_dxdXi,
121  const FArrayBox& a_Xi,
122  int a_destComp,
123  int a_dirX,
124  int a_dirXi,
125  const Box& a_box) const;
126 
127 
128  /// returns number of components in the metric term matrix (N)
129  virtual int getNumN() const
130  {
131  return SpaceDim*SpaceDim;
132  }
133 
134  /// index function into face-centered metric terms
135  /** returns which component of the face-centered metric term in
136  which N^row_col is stored.
137  \note
138  <ul>
139  <li> \f$N\f$ is stored in column-major order (fortran).
140  <li> Then using the same format, \f$N^T\f$ is stored in
141  row-major order (C).
142  <li> so (0,x) gives the start of a column of \f$N\f$ and
143  a row of \f$N^T\f$.
144  <li> If you want the computational flux in direction 'd',
145  from the physical flux, 'f', take the scalar product
146  of N(getNcomponent(0, d)) dot f
147  </ul>
148  */
149  virtual int getNcomponent(const int a_row, const int a_col) const
150  {return (SpaceDim*a_col) + a_row;}
151 
152  /// Same as getNcomponent but returns an IntVect for an 'a_col' (direction)
153  static const IntVect& metricsCompDir(const int a_iDir)
154  {
155  static const IntVect metricsComp[SpaceDim] =
156  {
157  D_DECL6(IntVect(D_DECL6(0*SpaceDim + 0, 0*SpaceDim + 1,
158  0*SpaceDim + 2, 0*SpaceDim + 3,
159  0*SpaceDim + 4, 0*SpaceDim + 5)),
160  IntVect(D_DECL6(1*SpaceDim + 0, 1*SpaceDim + 1,
161  1*SpaceDim + 2, 1*SpaceDim + 3,
162  1*SpaceDim + 4, 1*SpaceDim + 5)),
163  IntVect(D_DECL6(2*SpaceDim + 0, 2*SpaceDim + 1,
164  2*SpaceDim + 2, 2*SpaceDim + 3,
165  2*SpaceDim + 4, 2*SpaceDim + 5)),
166  IntVect(D_DECL6(3*SpaceDim + 0, 3*SpaceDim + 1,
167  3*SpaceDim + 2, 3*SpaceDim + 3,
168  3*SpaceDim + 4, 3*SpaceDim + 5)),
169  IntVect(D_DECL6(4*SpaceDim + 0, 4*SpaceDim + 1,
170  4*SpaceDim + 2, 4*SpaceDim + 3,
171  4*SpaceDim + 4, 4*SpaceDim + 5)),
172  IntVect(D_DECL6(5*SpaceDim + 0, 5*SpaceDim + 1,
173  5*SpaceDim + 2, 5*SpaceDim + 3,
174  5*SpaceDim + 4, 5*SpaceDim + 5)))
175  };
176  return metricsComp[a_iDir];
177  }
178 
179  /// computes the volume flux on the faces
180  virtual void volFlux(FluxBox& a_volFlux,
181  const FluxBox& a_Nt,
182  const Box& a_box) const;
183 
184  /// computes cell volumes
185  /**
186  Return cell volume in a_vol on cells of a_box,
187  using a_N from getN() defined on a_box grown by 1.
188  */
189  virtual void cellVol(FArrayBox& a_vol,
190  const FluxBox& a_N,
191  const Box& a_box) const;
192 
193  /// computes integral of N over each face of a_box
194  virtual void getN(FluxBox& a_N, const Box& a_box) const;
195 
196  /// computes cell-averaged J
197  virtual void getAvgJ(FArrayBox& a_avgJ,
198  const FluxBox& a_volFlux,
199  const Box& a_box) const;
200 
201  /// computes cell-averaged J
202  virtual void getAvgJ(FArrayBox& a_avgJ, const Box& a_box) const;
203 
204  /// computes cell-averaged 1/J
205  virtual void getAvgJinverse(FluxBox& a_avgJinverse,
206  const Box& a_box) const;
207 
208  /// computes cell-averaged 1/J, using pre-computed cell-avg J
209  virtual void getAvgJinverse(FluxBox& a_avgJinverse,
210  const FArrayBox& a_avgJ,
211  const Box& a_box) const;
212 
213  /// Jacobian evaluated at location Xi in mapped space
214  virtual Real pointwiseJ(const RealVect& a_Xi) const;
215 
216  /// Jacobian evaluated at locations Xi in mapped space
217  virtual void pointwiseJ(FArrayBox& a_J,
218  const FArrayBox& a_Xi,
219  const Box& a_box) const;
220 
221  /// Computes 4th-order average of product = N^T*F. F can be a flux dyad
222  virtual void computeMetricTermProductAverage(
223  FluxBox& a_product,
224  const FluxBox& a_F,
225  const FluxBox& a_N,
226  const int a_NNumComp,
227  const FluxBox& a_FforGrad,
228  const Box& a_box,
229  bool a_fourthOrder = true,
230  Interval a_varIntervalProduct = Interval(),
231  Interval a_varIntervalF = Interval(),
232  int a_fluxSpaceContiguous = 1,
233  const ProblemDomain *const a_problemDomainPtr = NULL) const;
234 
235  /// computes 4th-order average of product = N^T*F. F is vector of a scalar
236  /** if a_fourthOrder is false, then only do a second-order dot product
237  aFforGrad is the F used to compute grad_perp(F);
238  returns results in a_product on a_box;
239  both a_FforGrad and a_N (from getN()) must be defined on a_box grown by 1.
240  */
241  virtual void computeMetricTermProductAverage(FluxBox& a_product,
242  const FluxBox& a_F,
243  const FluxBox& a_N,
244  const FluxBox& a_FforGrad,
245  const Box& a_box,
246  bool a_fourthOrder=true) const;
247 
248 
249  /// computes 4th-order average of product = N^T*F. F is vector of a scalar
250  /** if a_fourthOrder is false, then only do a second-order dot product;
251  returns results in a_product on a_box;
252  both a_F and a_N (from getN()) must be defined on a_box grown by 1.
253  */
254  virtual void computeMetricTermProductAverage(FluxBox& a_product,
255  const FluxBox& a_F,
256  const FluxBox& a_N,
257  const Box& a_box,
258  bool a_fourthOrder=true) const;
259 
260  /// Computes magnitude of <N^T> on each face
261  // This is not virtual because I don't think it should even be in this class
262  // -- see comments in NewFourthOrderCoordSys.cpp.
263  void magnitudeN(FluxBox& a_NMag,
264  const FluxBox& a_N,
265  const Box& a_box) const;
266 
267  /// given N and Jinverse, computes N/J
268  /** provided for convenience, since the multicomponent N/J product
269  requires a bit of processing to work with the existing
270  fourth-order multiplication function
271  */
272  virtual void computeNJinverse(FluxBox& a_NJinverse,
273  const FluxBox& a_Jinverse,
274  const FluxBox& a_N,
275  const Box& a_cellBox) const;
276 
277 
278  /// access function to simplify things -- returns mapped-space cell spacing
279  virtual const RealVect& dx() const
280  {
281  return m_dx;
282  }
283 
284  /// this evaluates the script N values from equation 12 in Phil's notes
285  /** note that a_Xi is in mapped space.
286  */
287  virtual Real getN(const RealVect& a_Xi, int a_s, int a_d, int a_d1) const;
288 
289  /// note that a_Xi is in mapped space.
290  virtual Real getNMatrixEntry(const RealVect& a_Xi,
291  int a_s, int a_d, int a_d1,
292  int a_row, int a_column) const;
293 
294  /// Integrates \f$\mathcal{N}^s\f$ on a specific set of codimension 2
295  /// hyperedges that are orthogonal to the given directions.
296  virtual void integrateScriptN(FArrayBox& a_scrN,
297  const int a_dir0,
298  const int a_dir1,
299  const Box& a_box) const;
300 
301  virtual void incrementFaceMetricWithEdgeTerm(FArrayBox& a_faceMetrics,
302  int a_faceDir,
303  int a_edgeDir,
304  const Box& a_box,
305  const Side::LoHiSide& a_side) const;
306 
307  virtual void computeTransverseFaceMetric(FArrayBox& a_faceMetrics,
308  const Box& a_box,
309  int a_faceDir,
310  int a_dDir) const;
311 
312 
313  virtual void computeTangentialGrad(FluxBox& a_gradPhi,
314  const FluxBox& a_phiFace,
315  const Box& a_box) const;
316 
317 
318  virtual int tanGradComp(const int a_faceDir, const int a_tanDir,
319  const int a_comp) const;
320 
321  /// return row a_idir of contravariant metric
322  virtual void contravariantMetric(FArrayBox& a_metric,
323  int a_dir) const;
324 
325  /// convert vector components (in a_vectorIntv) of a_flux to orthonormal frame to that of this block
326  virtual void orthonormalize(FluxBox& a_flux,
327  const Interval& a_vectorIntv) const;
328 
329  /// overwrite vector components (in a_vectorIntv) of a_fluxFab with orthonormalized
330  virtual void orthonormalize(FArrayBox& a_fluxFab,
331  const Interval& a_vectorIntv) const;
332 
333  /// convert components in a_csComps of vector a_csFab in coordinate-system basis to components in a_orthoComps of vector a_orthoFab in orthonormal basis, at points with indices in a_box, on lines where direction a_idir is constant
334  virtual void orthonormalize(
335  const FArrayBox& a_csFab,
336  FArrayBox& a_orthoFab,
337  const Box& a_box,
338  int a_idir,
339  const IntVect& a_csComps,
340  const IntVect& a_orthoComps) const;
341 
342  /// convert vector components (in a_vectorIntv) of a_flux from orthonormal frame to that of this block
343  virtual void deorthonormalize(FluxBox& a_flux,
344  const Interval& a_vectorIntv) const;
345 
346  /// overwrite vector components (in a_vectorIntv) of a_fluxFab with deorthonormalized
347  virtual void deorthonormalize(FArrayBox& a_fluxFab,
348  const Interval& a_vectorIntv) const;
349 
350  /// convert components in a_orthoComps of vector a_orthoFab in orthonormal basis to components in a_csComps of vector a_csFab in coordinate-system basis, at points with indices in a_box, on lines where direction a_idir is constant
351  virtual void deorthonormalize(
352  const FArrayBox& a_orthoFab,
353  FArrayBox& a_csFab,
354  const Box& a_box,
355  int a_idir,
356  const IntVect& a_orthoComps,
357  const IntVect& a_csComps) const;
358 protected:
359 
361 
362  // which component directions to use when computing cell volumes
364 
366 };
367 
369 
370 
371 #include "NamespaceFooter.H"
372 
373 #endif
#define D_DECL6(a, b, c, d, e, f)
Definition: CHArray.H:39
virtual void cellVol(FArrayBox &a_vol, const FluxBox &a_N, const Box &a_box) const
computes cell volumes
void magnitudeN(FluxBox &a_NMag, const FluxBox &a_N, const Box &a_box) const
Computes magnitude of <N^T> on each face.
virtual void computeNJinverse(FluxBox &a_NJinverse, const FluxBox &a_Jinverse, const FluxBox &a_N, const Box &a_cellBox) const
given N and Jinverse, computes N/J
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 orthonormalize(FluxBox &a_flux, const Interval &a_vectorIntv) const
convert vector components (in a_vectorIntv) of a_flux to orthonormal frame to that of this block ...
virtual Real getNMatrixEntry(const RealVect &a_Xi, int a_s, int a_d, int a_d1, int a_row, int a_column) const
note that a_Xi is in mapped space.
NewFourthOrderCoordSys()
default constructor
static const IntVect & metricsCompDir(const int a_iDir)
Same as getNcomponent but returns an IntVect for an 'a_col' (direction)
Definition: NewFourthOrderCoordSys.H:153
A class to facilitate interaction with physical boundary conditions.
Definition: ProblemDomain.H:141
virtual int getNumN() const
returns number of components in the metric term matrix (N)
Definition: NewFourthOrderCoordSys.H:129
virtual void integrateScriptN(FArrayBox &a_scrN, const int a_dir0, const int a_dir1, const Box &a_box) const
virtual void volFlux(FluxBox &a_volFlux, const FluxBox &a_Nt, const Box &a_box) const
computes the volume flux on the faces
Virtual base class encapsulating mapped-grid coordinate systems.
Definition: NewFourthOrderCoordSys.H:77
virtual void getAvgJinverse(FluxBox &a_avgJinverse, const Box &a_box) const
computes cell-averaged 1/J
virtual ~NewFourthOrderCoordSys()
virtual void incrementFaceMetricWithEdgeTerm(FArrayBox &a_faceMetrics, int a_faceDir, int a_edgeDir, const Box &a_box, const Side::LoHiSide &a_side) const
virtual Real pointwiseJ(const RealVect &a_Xi) const
Jacobian evaluated at location Xi in mapped space.
const int SpaceDim
Definition: SPACE.H:38
virtual void computeTangentialGrad(FluxBox &a_gradPhi, const FluxBox &a_phiFace, const Box &a_box) const
A FArrayBox-like container for face-centered fluxes.
Definition: FluxBox.H:22
EdgeQuadrature * m_quadraturePtr
Definition: NewFourthOrderCoordSys.H:365
virtual void getAvgJ(FArrayBox &a_avgJ, const FluxBox &a_volFlux, const Box &a_box) const
computes cell-averaged J
Structure for passing component ranges in code.
Definition: Interval.H:23
virtual const RealVect & dx() const
access function to simplify things – returns mapped-space cell spacing
Definition: NewFourthOrderCoordSys.H:279
virtual RealVect realCoord(const RealVect &a_Xi) const =0
given coordinate in mapped space, return its location in real space
NewFourthOrderCoordSys BlockCoordSys
Definition: NewFourthOrderCoordSys.H:368
Interval m_volInterval
Definition: NewFourthOrderCoordSys.H:363
double Real
Definition: REAL.H:33
virtual void computeTransverseFaceMetric(FArrayBox &a_faceMetrics, const Box &a_box, int a_faceDir, int a_dDir) const
virtual void computeMetricTermProductAverage(FluxBox &a_product, const FluxBox &a_F, const FluxBox &a_N, const int a_NNumComp, const FluxBox &a_FforGrad, const Box &a_box, bool a_fourthOrder=true, Interval a_varIntervalProduct=Interval(), Interval a_varIntervalF=Interval(), int a_fluxSpaceContiguous=1, const ProblemDomain *const a_problemDomainPtr=NULL) const
Computes 4th-order average of product = N^T*F. F can be a flux dyad.
LoHiSide
Definition: LoHiSide.H:27
A Rectangular Domain on an Integer Lattice.
Definition: Box.H:469
A Real vector in SpaceDim-dimensional space.
Definition: RealVect.H:41
virtual void getN(FluxBox &a_N, const Box &a_box) const
computes integral of N over each face of a_box
virtual RealVect mappedCoord(const RealVect &a_x) const =0
given coordinate in real space, return its location in the mapped space
RealVect m_dx
Definition: NewFourthOrderCoordSys.H:360
An integer Vector in SpaceDim-dimensional space.
Definition: CHArray.H:42
Definition: FArrayBox.H:45
virtual void getNodeRealCoordinates(FArrayBox &a_nodeCoords, const Box &a_box) const
return Cartesian XYZ locations of nodes
virtual int getNcomponent(const int a_row, const int a_col) const
index function into face-centered metric terms
Definition: NewFourthOrderCoordSys.H:149
virtual int tanGradComp(const int a_faceDir, const int a_tanDir, const int a_comp) const
Virtual base class for defining edge-based quadratures.
Definition: EdgeQuadrature.H:37
virtual void deorthonormalize(FluxBox &a_flux, const Interval &a_vectorIntv) const
convert vector components (in a_vectorIntv) of a_flux from orthonormal frame to that of this block ...
Virtual base class encapsulating mapped-grid coordinate systems.
Definition: NewCoordSys.H:30
virtual void contravariantMetric(FArrayBox &a_metric, int a_dir) const
return row a_idir of contravariant metric