Chombo + EB + MF  3.2
CubedSphere2DPanelCS.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 _CUBEDSPHERE2DPANELCS_H_
12 #define _CUBEDSPHERE2DPANELCS_H_
13 
14 #include <utility>
15 using std::pair;
16 
17 #include "REAL.H"
18 #include "DisjointBoxLayout.H"
19 #include "RealVect.H"
20 #include "IntVect.H"
21 #include "LevelData.H"
22 #include "FArrayBox.H"
23 #include "FluxBox.H"
24 #include "Vector.H"
25 #include "NewFourthOrderCoordSys.H"
26 
27 #include "NamespaceHeader.H"
28 // #include "UsingNamespace.H"
29 
30 /// Basic single-panel cubed sphere Coordinates
31 /**
32  The CubedSphere2DPanelCS class implements the NewFourthOrderCoordSys class
33  for cubed sphere panels in equiangular coordinates.
34 */
36 {
37 public:
38  /// constructor
39  /**
40  nPanel
41  (0-3 Equatorial, 4 North Pole, 5 South Pole) and defines the
42  panel on the cubed sphere described by this object.
43  dDX
44  The cell spacing on this panel.
45  ix
46  Index of the bottom-left edge of this panel in index space.
47  */
48  CubedSphere2DPanelCS(int nPanel, RealVect& dDX, IntVect& ix);
49 
50  void setFlatMap(bool a_flatMap);
51 
52  /**
53  Destructor.
54  */
55  virtual ~CubedSphere2DPanelCS();
56 
57  //void panel(int nPanel) {m_nPanel = nPanel;}
58 
59  /// given coordinate in mapped space, return its location in real space
60  RealVect realCoord(const RealVect& a_Xi) const;
61 
62  void realCoord(FArrayBox& a_x,
63  const FArrayBox& a_Xi,
64  const Box& a_box) const;
65 
66  /// given coordinate in real space, return its location in the mapped space
67  RealVect mappedCoord(const RealVect& a_x) const;
68 
69  /// return Cartesian XYZ locations of cell centers
70  virtual void getNodeRealCoordinates(FArrayBox& a_nodeCoords,
71  const Box& a_box) const;
72 
73  // return cell center positions in mapped coordinates
74  virtual void getCellMappedCoordinates(FArrayBox& a_cellCoords,
75  const Box& a_box) const;
76 
77  // return face center positions in mapped coordinates
78  virtual void getFaceMappedCoordinates(FArrayBox& a_faceCoords,
79  const int a_dir,
80  const Box& a_box) const;
81 
82  // return node positions in mapped coordinates
83  virtual void getNodeMappedCoordinates(FArrayBox& a_nodeCoords,
84  const Box& a_box) const;
85 
86  // Calculate the derivative of each coordinate vector
87  virtual Real dXdXi(const RealVect& a_Xi, int a_dirX, int a_dirXi) const;
88 
89  /// returns dimensionality of the space (3, or 2 if flat)
90  /**
91  */
92  virtual int dimension() const
93  {
94  return m_realDim;
95  }
96 
97  /// computes cell volumes
98  virtual void cellVol(FArrayBox& a_vol,
99  const FluxBox& a_N,
100  const Box& a_box) const;
101 
102  /// computes NT * F.
103  virtual void volFlux(FluxBox& a_volFlux,
104  const FluxBox& a_Nt,
105  const Box& a_box) const;
106 
107  /// computes face-centered N
108  virtual void getN(FluxBox& a_N, const Box& a_box) const;
109 
110  /// computes cell-averaged J
111  virtual void getAvgJ(FArrayBox& a_avgJ, const Box& a_box) const;
112 
113  /// computes cell-averaged J; ignores a_volFlux
114  virtual void getAvgJ(FArrayBox& a_avgJ,
115  const FluxBox& a_volFlux,
116  const Box& a_box) const;
117 
118  /// computes face-averaged 1/J
119  virtual void getAvgJinverse(FluxBox& a_avgJinverse,
120  const Box& a_box) const;
121 
122  /// Jacobian evaluated at location X in real space
123  virtual Real pointwiseJ(const RealVect& a_X) const;
124 
125  /// Jacobian evaluated at locations Xi in mapped space
126  virtual void pointwiseJ(FArrayBox& a_J,
127  const FArrayBox& a_Xi,
128  const Box& a_box) const;
129 
130  /// returns integral of divergence over mapped-grid cells
131  virtual void computeDivergence(FArrayBox& a_divF,
132  const FluxBox& a_F,
133  const FluxBox& a_N,
134  const Box& a_box,
135  Interval& divInterval) const;
136 
137  /// this evaluates the script N values from equation 12 in Phil's notes
138  /** note that a_Xi is in mapped space.
139  */
140  virtual Real getN(const RealVect& a_Xi, int a_s, int a_d, int a_d1) const;
141 
142  virtual Real getNMatrixEntry(const RealVect& a_Xi,
143  int a_s, int a_d, int a_d1,
144  int a_row, int a_column) const;
145 
146  /// transform a point from mapped-coordinate basis to longitude-latitude
147  /// coordinate basis
149  RealVect & a_rllXi) const;
150 
151  /// transform a point from mapped-coordinate basis to Cartesian
152  /// coordinate basis
154  Real * a_xyz) const;
155 
156  /// transform a FAB of points from mapped-coordinate basis to latitude-longitude
157  /// coordinate basis
159  const FArrayBox& a_xiFab,
160  FArrayBox& a_rllXiFab
161  ) const;
162 
163  /// transform a FAB of points from mapped-coordinate basis to Cartesian
164  /// coordinate basis
166  const FArrayBox& a_xiFab,
167  FArrayBox& a_xyzFab) const;
168 
169  /// transform a vector from mapped-coordinate basis to real-coordinate basis,
170  /// given a point a_xi in mapped space
172  const Real * a_vecCS,
173  Real * a_vecXYZ) const;
174 
175  /// transform a vector from real-coordinate basis to mapped-coordinate basis,
176  /// given a point a_xi in mapped space
178  const Real * a_vecXYZ,
179  Real * a_vecCS) const;
180 
181  /// transform a vector from longitude-latitude coordinate basis to
182  /// mapped-coordinate basis
184  const Real * a_vecRLL,
185  Real * a_vecCS) const;
186 
187  /// transform a FAB of vectors from latitude-longitude coordinate basis to
188  /// mapped-coordinate basis
190  const FArrayBox& a_xiFab,
191  const FArrayBox& a_vecRLLFab,
192  FArrayBox& a_vecCSFab) const;
193 
194  /// transform a FAB of vectors from mapped-coordinate basis to
195  /// latitude-longitude coordinate basis
197  const FArrayBox& a_xiFab,
198  const FArrayBox& a_vecCSFab,
199  FArrayBox& a_vecRLLFab) const;
200 
201  /// transform a FAB of SpaceDim-vectors from mapped-coordinate basis to real-coordinate basis at cell centers
202  virtual void vectorTransformMappedToRealCenterFab(FArrayBox& a_vectorFab) const;
203 
204  /// transform a FAB of SpaceDim-vectors from real-coordinate basis to mapped-coordinate basis at cell centers
205  virtual void vectorTransformRealToMappedCenterFab(FArrayBox& a_vectorFab) const;
206 
207  /// return row a_idir of contravariant metric
208  virtual void contravariantMetric(FArrayBox& a_metric,
209  int a_dir) const;
210 
211  /// 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
212  virtual void orthonormalize(
213  const FArrayBox& a_csFab,
214  FArrayBox& a_orthoFab,
215  const Box& a_box,
216  int a_idir,
217  const IntVect& a_csComps,
218  const IntVect& a_orthoComps) const;
219 
220  /// 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
221  virtual void deorthonormalize(
222  const FArrayBox& a_orthoFab,
223  FArrayBox& a_csFab,
224  const Box& a_box,
225  int a_idir,
226  const IntVect& a_orthoComps,
227  const IntVect& a_csComps) const;
228 
229  /// return coefficients to convert components of a vector from coordinate-system basis to orthonormal basis, at points with indices in a_box, on lines where direction a_idir is constant
230  virtual void getOrthonormalizingMatrix(
231  FArrayBox& a_matrixFab,
232  const Box& a_box,
233  int a_idir) const;
234 
235  /// return coefficients to convert components of a vector from orthonormal basis to coordinate-system basis, at points with indices in a_box, on lines where direction a_idir is constant
236  virtual void getDeorthonormalizingMatrix(
237  FArrayBox& a_matrixFab,
238  const Box& a_box,
239  int a_idir) const;
240 
241  /// return radial component of curl of a_vecFab, which has SpaceDim components and is cell-centered. Does not seem to work.
242  virtual void curl(
243  const FArrayBox& a_vecFab,
244  FArrayBox& a_curlFab,
245  const Box& a_box) const;
246 
247 
248  /// return radial component of curl of a_vecFab, which has SpaceDim components and is cell-centered, by converting to spherical coordinates.
249  virtual void curlSpherical(
250  const FArrayBox& a_vecFab,
251  FArrayBox& a_curlFab,
252  const Box& a_box) const;
253 
254  /// access function to panel id
255  int panel() const
256  {
257  return m_nPanel;
258  }
259 
260 protected:
261  // Panel id (this object has different behaviour depending on the panel)
262  int m_nPanel;
263 
264  // number of dimensions in real space
266 
267  // whether to map to a flat plane; default false
268  bool m_flatMap;
269 
270  // Index of the bottom-left edge of this panel in index space
272 
273 };
274 
275 #include "NamespaceFooter.H"
276 
277 #endif
virtual void getAvgJinverse(FluxBox &a_avgJinverse, const Box &a_box) const
computes face-averaged 1/J
int panel() const
access function to panel id
Definition: CubedSphere2DPanelCS.H:255
virtual void cellVol(FArrayBox &a_vol, const FluxBox &a_N, const Box &a_box) const
computes cell volumes
void vectorTransformLatLonToEquiangular(const RealVect &a_xi, const Real *a_vecRLL, Real *a_vecCS) const
RealVect realCoord(const RealVect &a_Xi) const
given coordinate in mapped space, return its location in real space
void fabVectorTransformLatLonToEquiangular(const FArrayBox &a_xiFab, const FArrayBox &a_vecRLLFab, FArrayBox &a_vecCSFab) const
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.
void vectorTransformCartesianToEquiangular(const RealVect &a_xi, const Real *a_vecXYZ, Real *a_vecCS) const
void vectorTransformEquiangularToCartesian(const RealVect &a_xi, const Real *a_vecCS, Real *a_vecXYZ) const
Virtual base class encapsulating mapped-grid coordinate systems.
Definition: NewFourthOrderCoordSys.H:77
IntVect m_ix
Definition: CubedSphere2DPanelCS.H:271
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
void pointTransformEquiangularToCartesian(const RealVect &a_xi, Real *a_xyz) const
void fabTransformEquiangularToLonLat(const FArrayBox &a_xiFab, FArrayBox &a_rllXiFab) const
virtual void getFaceMappedCoordinates(FArrayBox &a_faceCoords, const int a_dir, const Box &a_box) const
virtual void getAvgJ(FArrayBox &a_avgJ, const Box &a_box) const
computes cell-averaged J
int m_nPanel
Definition: CubedSphere2DPanelCS.H:262
A FArrayBox-like container for face-centered fluxes.
Definition: FluxBox.H:22
virtual void volFlux(FluxBox &a_volFlux, const FluxBox &a_Nt, const Box &a_box) const
computes NT * F.
virtual ~CubedSphere2DPanelCS()
CubedSphere2DPanelCS(int nPanel, RealVect &dDX, IntVect &ix)
constructor
virtual void curlSpherical(const FArrayBox &a_vecFab, FArrayBox &a_curlFab, const Box &a_box) const
return radial component of curl of a_vecFab, which has SpaceDim components and is cell-centered...
Structure for passing component ranges in code.
Definition: Interval.H:23
virtual void curl(const FArrayBox &a_vecFab, FArrayBox &a_curlFab, const Box &a_box) const
return radial component of curl of a_vecFab, which has SpaceDim components and is cell-centered...
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 void getNodeRealCoordinates(FArrayBox &a_nodeCoords, const Box &a_box) const
return Cartesian XYZ locations of cell centers
virtual void getDeorthonormalizingMatrix(FArrayBox &a_matrixFab, const Box &a_box, int a_idir) const
return coefficients to convert components of a vector from orthonormal basis to coordinate-system bas...
virtual void getCellMappedCoordinates(FArrayBox &a_cellCoords, const Box &a_box) const
void pointTransformEquiangularToLonLat(const RealVect &a_xi, RealVect &a_rllXi) const
double Real
Definition: REAL.H:33
virtual Real pointwiseJ(const RealVect &a_X) const
Jacobian evaluated at location X in real space.
virtual void getNodeMappedCoordinates(FArrayBox &a_nodeCoords, const Box &a_box) const
virtual void deorthonormalize(const FArrayBox &a_orthoFab, FArrayBox &a_csFab, const Box &a_box, int a_idir, const IntVect &a_orthoComps, const IntVect &a_csComps) const
convert components in a_orthoComps of vector a_orthoFab in orthonormal basis to components in a_csCom...
virtual void orthonormalize(const FArrayBox &a_csFab, FArrayBox &a_orthoFab, const Box &a_box, int a_idir, const IntVect &a_csComps, const IntVect &a_orthoComps) const
convert components in a_csComps of vector a_csFab in coordinate-system basis to components in a_ortho...
virtual void getN(FluxBox &a_N, const Box &a_box) const
computes face-centered N
A Rectangular Domain on an Integer Lattice.
Definition: Box.H:469
A Real vector in SpaceDim-dimensional space.
Definition: RealVect.H:41
virtual void contravariantMetric(FArrayBox &a_metric, int a_dir) const
return row a_idir of contravariant metric
virtual void getOrthonormalizingMatrix(FArrayBox &a_matrixFab, const Box &a_box, int a_idir) const
return coefficients to convert components of a vector from coordinate-system basis to orthonormal bas...
virtual Real dXdXi(const RealVect &a_Xi, int a_dirX, int a_dirXi) const
note that a_Xi is in mapped space.
Basic single-panel cubed sphere Coordinates.
Definition: CubedSphere2DPanelCS.H:35
virtual void vectorTransformMappedToRealCenterFab(FArrayBox &a_vectorFab) const
transform a FAB of SpaceDim-vectors from mapped-coordinate basis to real-coordinate basis at cell cen...
void fabTransformEquiangularToCartesian(const FArrayBox &a_xiFab, FArrayBox &a_xyzFab) const
An integer Vector in SpaceDim-dimensional space.
Definition: CHArray.H:42
Definition: FArrayBox.H:45
int m_realDim
Definition: CubedSphere2DPanelCS.H:265
virtual int dimension() const
returns dimensionality of the space (3, or 2 if flat)
Definition: CubedSphere2DPanelCS.H:92
RealVect mappedCoord(const RealVect &a_x) const
given coordinate in real space, return its location in the mapped space
void setFlatMap(bool a_flatMap)
void fabVectorTransformEquiangularToLatLon(const FArrayBox &a_xiFab, const FArrayBox &a_vecCSFab, FArrayBox &a_vecRLLFab) const
bool m_flatMap
Definition: CubedSphere2DPanelCS.H:268