Chombo + EB + MF  3.2
CubedSphereShellCS.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 _CUBEDSPHERESHELLCS_H_
12 #define _CUBEDSPHERESHELLCS_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 "Spline1DMapping.H"
26 #include "MultiBlockCoordSys.H"
27 
28 #include "NamespaceHeader.H"
29 // #include "UsingNamespace.H"
30 
31 /// Multiblock coordinate system for cubed sphere shell
32 /// with variable-thickness spherical layers
33 /**
34  The CubedSphereShellCS coordinate system class is a multiblock example
35  that takes place on a cubed inflated onto the surface of a sphere, and
36  creates a shell with r-direction layers of variable thickness.
37  NOTE: Supports only a "scaled thin atmosphere" approximation which
38  ignores the r dependencies of the horizontal grid metrics
39 */
41 {
42 public:
43  /// default constructor
45 
46  /// constructor that makes constant thickness vertical layers
47  CubedSphereShellCS(int a_nResolution, int a_nLayers = 0,
48  Real a_height = 1, Real a_radius = 1);
49 
50  /**
51  Destructor.
52  */
53  virtual ~CubedSphereShellCS();
54 
55  virtual void define(int a_nResolution, int a_nLayers = 0,
56  Real a_height = 1, Real a_radius = 1);
57 
58  virtual void define(const ProblemDomain& a_levelDomain,
59  const RealVect& a_dx);
60 
61  void setFlatMap(bool a_flatMap);
62 
63  void setHeight(Real a_height);
64 
65  Real getHeight() const;
66 
67  void setRadius(Real a_radius);
68 
69  Real getRadius() const;
70 
72 
73  void regrid(const DisjointBoxLayout& a_newGrids);
74 
75  RealVect realCoord(const RealVect& a_X) const;
76 
77  RealVect mappedCoord(const RealVect& a_x) const;
78 
79  /// Calculate the pointwise transformation matrix using gnomonic
80  /// coordinates on the source panel (a_dX, a_dY).
81  void vecTransMatrix_Pt(
82  int a_nSourcePanel,
83  int a_nDestPanel,
84  Real a_dX,
85  Real a_dY,
86  Real* a_dT
87  ) const;
88 
89  // Calculate the element averaged transformation matrix, and gradient
90  // of the transformation matrix
91  void vecTransMatrix(
92  int a_nSourcePanel,
93  int a_nDestPanel,
94  int a_nAlphaIx,
95  int a_nBetaIx,
96  Real a_dDeltaA,
97  Real* a_dAvgT,
98  Real* a_dAlphaGradT,
99  Real* a_dBetaGradT
100  ) const;
101 
102  // Calculate the pointwise vector transformation
104  int a_nDst,
105  const RealVect& a_xiSrc,
106  int a_nSrc
107  ) const;
108 
109  /// convert from mapped coordinate to Cartesian coordinates
110  /** given a_xiSrc in block a_nSrc, return 3D Cartesian coordinates of point.
111  */
112  void cartesianFromMapped(Real& xx,
113  Real& yy,
114  Real& zz,
115  const RealVect& a_xiSrc,
116  int a_nSrc) const;
117 
118  /// convert from Cartesian coordinates to mapped coordinate
119  /** given 3D Cartesian coordinates of point and destination block
120  returns mapped coordinates of that point. Radius information is
121  discarded.
122  */
123  void mappedFromCartesian(RealVect& a_xiDst,
124  int a_nDst,
125  Real xx,
126  Real yy,
127  Real zz) const;
128 
129  /// convert from Lon-Lat-R coordinates to CSS computational coordinate
130  /** given a_llr, find a_xi and block a_nPanel. NOTE: no spline lookup
131  */
132  void cssXiFromLonLat2D(RealVect a_llr,
133  RealVect& a_xi,
134  int& a_nPanel) const;
135 
136  /// block mapping conversion function
137  /** given a_xiSrc in block a_nSrc, returns which block (a_n_valid)
138  contains that location in its valid region and its
139  location (a_xi_valid) in that block's computational coordinate space.
140  */
141  virtual void blockRemapping(RealVect& a_xi_valid,
142  int& a_n_valid,
143  const RealVect& a_xiSrc,
144  int a_nSrc) const;
145 
146  // general block mapping conversion function
147  /** given mapped coordinate a_xiSrc of a point in block a_nSrc return
148  mapped coordinates in block a_nDst.
149  */
150  virtual RealVect blockRemappingGeneral(int a_nDst,
151  const RealVect & a_xiSrc,
152  int a_nSrc) const;
153 
154  virtual Vector<RealVect> displacements(const Vector<RealVect>& a_dstCoords,
155  const Vector<int>& a_dstBlocks,
156  const RealVect& a_srcCoords,
157  int a_srcBlock) const;
158 
159  /// Have separate volume flux on each block. Normally does nothing, but cubed-sphere coordinate system needs it.
160  virtual void separateVolFlux(LevelData<FluxBox>& a_flux) const;
161 
162 protected:
163  // Resolution per element
165 
166  // Number of vertical layers (= resolution)
168 
169  // Height of the domain in r direction
171 
172  // Radius of the domain in r direction - considered constant
174 
175  // Whether to map to a flat surface; default false
176  bool m_flatMap;
177 
178  // Vertical mapping, should map from [0,1] to radial direction
180 
181  // define m_boundaries, called by define()
182  void defineBoundaries();
183 };
184 
185 
187 {
188 public:
189 
191  {
192  m_flatMap = false;
193  }
194 
196  {
197  }
198 
199  virtual MultiBlockCoordSys* getCoordSys(const ProblemDomain& levelDomain,
200  const RealVect& a_dx) const;
201 
203  {
204  m_verticalMap = a_map;
205  }
206 
207  void setHeight(Real a_height)
208  {
209  m_height = a_height;
210  }
211 
212  void setRadius(Real a_radius)
213  {
214  m_radius = a_radius;
215  }
216 
217  void setFlatMap(bool a_flatMap)
218  {
219  m_flatMap = a_flatMap;
220  }
221 
222 protected:
223 
226  bool m_flatMap;
228 };
229 
230 #include "NamespaceFooter.H"
231 
232 #endif
Real getHeight() const
Real m_radius
Definition: CubedSphereShellCS.H:225
virtual RealVect blockRemappingGeneral(int a_nDst, const RealVect &a_xiSrc, int a_nSrc) const
Real getRadius() const
Definition: CubedSphereShellCS.H:186
RealVect realCoord(const RealVect &a_X) const
void setFlatMap(bool a_flatMap)
A class to facilitate interaction with physical boundary conditions.
Definition: ProblemDomain.H:141
void setFlatMap(bool a_flatMap)
Definition: CubedSphereShellCS.H:217
void setVerticalMap(RefCountedPtr< Spline1DMapping > a_map)
Definition: CubedSphereShellCS.H:202
Real m_radius
Definition: CubedSphereShellCS.H:173
void vecTransMatrix(int a_nSourcePanel, int a_nDestPanel, int a_nAlphaIx, int a_nBetaIx, Real a_dDeltaA, Real *a_dAvgT, Real *a_dAlphaGradT, Real *a_dBetaGradT) const
Class to describe transformation of SpaceDim-vectors, typically from one block to another...
Definition: VectorTransformation.H:23
void vecTransMatrix_Pt(int a_nSourcePanel, int a_nDestPanel, Real a_dX, Real a_dY, Real *a_dT) const
void mappedFromCartesian(RealVect &a_xiDst, int a_nDst, Real xx, Real yy, Real zz) const
convert from Cartesian coordinates to mapped coordinate
virtual Vector< RealVect > displacements(const Vector< RealVect > &a_dstCoords, const Vector< int > &a_dstBlocks, const RealVect &a_srcCoords, int a_srcBlock) const
return displacements
void setRadius(Real a_radius)
Definition: CubedSphereShellCS.H:212
void regrid(const DisjointBoxLayout &a_newGrids)
virtual ~CubedSphereShellCS()
void setHeight(Real a_height)
bool m_flatMap
Definition: CubedSphereShellCS.H:176
virtual void blockRemapping(RealVect &a_xi_valid, int &a_n_valid, const RealVect &a_xiSrc, int a_nSrc) const
block mapping conversion function
int m_nResolution
Definition: CubedSphereShellCS.H:164
virtual void define(int a_nResolution, int a_nLayers=0, Real a_height=1, Real a_radius=1)
void setRadius(Real a_radius)
double Real
Definition: REAL.H:33
void cartesianFromMapped(Real &xx, Real &yy, Real &zz, const RealVect &a_xiSrc, int a_nSrc) const
convert from mapped coordinate to Cartesian coordinates
A BoxLayout that has a concept of disjointedness.
Definition: DisjointBoxLayout.H:30
virtual const NewCoordSys * getCoordSys(int a_n) const
Return the mapping which corresponds to the block with the given index.
Definition: MultiBlockCoordSys.H:250
virtual interface class encapsulating multi-block mapping API
Definition: MultiBlockCoordSys.H:34
virtual void separateVolFlux(LevelData< FluxBox > &a_flux) const
Have separate volume flux on each block. Normally does nothing, but cubed-sphere coordinate system ne...
CubedSphereShellCSFactory()
Definition: CubedSphereShellCS.H:190
A Real vector in SpaceDim-dimensional space.
Definition: RealVect.H:41
VectorTransformation vectorBlockTransformation(int a_nDst, const RealVect &a_xiSrc, int a_nSrc) const
return vector transformation from one block to another at a point.
void cssXiFromLonLat2D(RealVect a_llr, RealVect &a_xi, int &a_nPanel) const
convert from Lon-Lat-R coordinates to CSS computational coordinate
RefCountedPtr< Spline1DMapping > m_verticalMap
Definition: CubedSphereShellCS.H:227
pure-virtual base class defining factory interface for MultiBlockCoordSys
Definition: MultiBlockCoordSys.H:409
Definition: CubedSphereShellCS.H:40
void setHeight(Real a_height)
Definition: CubedSphereShellCS.H:207
RealVect mappedCoord(const RealVect &a_x) const
Real m_height
Definition: CubedSphereShellCS.H:170
bool m_flatMap
Definition: CubedSphereShellCS.H:226
Real m_height
Definition: CubedSphereShellCS.H:224
int m_nLayers
Definition: CubedSphereShellCS.H:167
RefCountedPtr< Spline1DMapping > m_verticalMap
Definition: CubedSphereShellCS.H:179
void setVerticalMap(RefCountedPtr< Spline1DMapping > a_map)
virtual ~CubedSphereShellCSFactory()
Definition: CubedSphereShellCS.H:195
CubedSphereShellCS()
default constructor