Chombo + EB + MF  3.2
CubedSphere2DCS.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 _CUBEDSPHERE2DCS_H_
12 #define _CUBEDSPHERE2DCS_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 "MultiBlockCoordSys.H"
26 
27 #include "NamespaceHeader.H"
28 // #include "UsingNamespace.H"
29 
30 /// simple multiblock coordinate system for a cylinder
31 /**
32  The CubedSphere2DCS coordinate system class is a multiblock example
33  that takes place on a cubed inflated onto the surface of a sphere.
34 */
36 {
37 public:
38  /// default constructor
40 
41  CubedSphere2DCS(int a_nResolution,
42  int a_nLayers = 0);
43 
44  /**
45  Destructor.
46  */
47  virtual ~CubedSphere2DCS();
48 
49  virtual void define(int a_nResolution,
50  int a_nLayers = 0);
51 
52  virtual void define(const ProblemDomain& a_levelDomain,
53  const RealVect& a_dx);
54 
55  void setFlatMap(bool a_flatMap);
56 
57  void setRadii(Real a_rMin,
58  Real a_rMax);
59 
60  void regrid(const DisjointBoxLayout& a_newGrids);
61 
62  RealVect realCoord(const RealVect& a_X) const;
63 
64  RealVect mappedCoord(const RealVect& a_x) const;
65 
66  /// Calculate the pointwise transformation matrix using gnomonic
67  /// coordinates on the source panel (a_dX, a_dY).
68  void vecTransMatrix_Pt(
69  int a_nSourcePanel,
70  int a_nDestPanel,
71  Real a_dX,
72  Real a_dY,
73  Real* a_dT
74  ) const;
75 
76  // Calculate the element averaged transformation matrix, and gradient
77  // of the transformation matrix
78  void vecTransMatrix(
79  int a_nSourcePanel,
80  int a_nDestPanel,
81  int a_nAlphaIx,
82  int a_nBetaIx,
83  Real a_dDeltaA,
84  Real* a_dAvgT,
85  Real* a_dAlphaGradT,
86  Real* a_dBetaGradT
87  ) const;
88 
89  // Calculate the pointwise vector transformation
91  int a_nDst,
92  const RealVect& a_xiSrc,
93  int a_nSrc
94  ) const;
95 
96  /// convert from mapped coordinate to Cartesian coordinates
97  /** given a_xiSrc in block a_nSrc, return 3D Cartesian coordinates of point.
98  */
99  void cartesianFromMapped(Real& xx,
100  Real& yy,
101  Real& zz,
102  const RealVect& a_xiSrc,
103  int a_nSrc) const;
104 
105  /// convert from Cartesian coordinates to mapped coordinate
106  /** given 3D Cartesian coordinates of point and destination block
107  returns mapped coordinates of that point. Radius information is
108  discarded.
109  */
110  void mappedFromCartesian(RealVect& a_xiDst,
111  int a_nDst,
112  Real xx,
113  Real yy,
114  Real zz) const;
115 
116  /// block mapping conversion function
117  /** given a_xiSrc in block a_nSrc, returns which block (a_n_valid)
118  contains that location in its valid region and its
119  location (a_xi_valid) in that block's computational coordinate space.
120  */
121  virtual void blockRemapping(RealVect& a_xi_valid,
122  int& a_n_valid,
123  const RealVect& a_xiSrc,
124  int a_nSrc) const;
125 
126  // general block mapping conversion function
127  /** given mapped coordinate a_xiSrc of a point in block a_nSrc return
128  mapped coordinates in block a_nDst.
129  */
130  virtual RealVect blockRemappingGeneral(int a_nDst,
131  const RealVect & a_xiSrc,
132  int a_nSrc) const;
133 
134  virtual Vector<RealVect> displacements(const Vector<RealVect>& a_dstCoords,
135  const Vector<int>& a_dstBlocks,
136  const RealVect& a_srcCoords,
137  int a_srcBlock) const;
138 
139  /// Have separate volume flux on each block. Normally does nothing, but cubed-sphere coordinate system needs it.
140  virtual void separateVolFlux(LevelData<FluxBox>& a_flux) const;
141 
142  /// Function to convert from 0:1 to m_rMin:m_rMax.
143  virtual Real radialMappedToReal(Real a_rMapped) const;
144 
145  /// Function to convert from m_rMin:m_rMax to 0:1.
146  virtual Real radialRealToMapped(Real a_rReal) const;
147 
148 protected:
149  // Resolution per element
151 
152  // Number of vertical layers (= resolution)
154 
155  // Whether to map to a flat surface; default false
156  bool m_flatMap;
157 
158  // These are used only in 3D.
160 
161  // Used only in 3D. Call only after m_rMin and m_rMax have been set.
162  void setFortranCommon();
163 
164  // define m_boundaries, called by define()
165  void defineBoundaries();
166 };
167 
168 
170 {
171 public:
172 
174  {
175  m_flatMap = false;
176  }
177 
179  {
180  }
181 
182  virtual MultiBlockCoordSys* getCoordSys(const ProblemDomain& levelDomain,
183  const RealVect& a_dx) const;
184 
185  void setFlatMap(bool a_flatMap)
186  {
187  m_flatMap = a_flatMap;
188  }
189 
190  void setRadii(Real a_rMin,
191  Real a_rMax)
192  {
193  m_rMin = a_rMin;
194  m_rMax = a_rMax;
195  }
196 
197 protected:
198 
199  bool m_flatMap;
200 
201  // These are used only in 3D.
203 };
204 
205 #include "NamespaceFooter.H"
206 
207 #endif
Definition: CubedSphere2DCS.H:169
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
void setFlatMap(bool a_flatMap)
Definition: CubedSphere2DCS.H:185
virtual void separateVolFlux(LevelData< FluxBox > &a_flux) const
Have separate volume flux on each block. Normally does nothing, but cubed-sphere coordinate system ne...
A class to facilitate interaction with physical boundary conditions.
Definition: ProblemDomain.H:141
void setRadii(Real a_rMin, Real a_rMax)
RealVect realCoord(const RealVect &a_X) const
bool m_flatMap
Definition: CubedSphere2DCS.H:199
Real m_rMin
Definition: CubedSphere2DCS.H:202
virtual Real radialMappedToReal(Real a_rMapped) const
Function to convert from 0:1 to m_rMin:m_rMax.
void mappedFromCartesian(RealVect &a_xiDst, int a_nDst, Real xx, Real yy, Real zz) const
convert from Cartesian coordinates to mapped coordinate
void vecTransMatrix_Pt(int a_nSourcePanel, int a_nDestPanel, Real a_dX, Real a_dY, Real *a_dT) const
Class to describe transformation of SpaceDim-vectors, typically from one block to another...
Definition: VectorTransformation.H:23
virtual void blockRemapping(RealVect &a_xi_valid, int &a_n_valid, const RealVect &a_xiSrc, int a_nSrc) const
block mapping conversion function
void setFortranCommon()
virtual ~CubedSphere2DCS()
virtual RealVect blockRemappingGeneral(int a_nDst, const RealVect &a_xiSrc, int a_nSrc) const
int m_nResolution
Definition: CubedSphere2DCS.H:150
void setFlatMap(bool a_flatMap)
void cartesianFromMapped(Real &xx, Real &yy, Real &zz, const RealVect &a_xiSrc, int a_nSrc) const
convert from mapped coordinate to Cartesian coordinates
virtual Vector< RealVect > displacements(const Vector< RealVect > &a_dstCoords, const Vector< int > &a_dstBlocks, const RealVect &a_srcCoords, int a_srcBlock) const
return displacements
double Real
Definition: REAL.H:33
virtual Real radialRealToMapped(Real a_rReal) const
Function to convert from m_rMin:m_rMax to 0:1.
A BoxLayout that has a concept of disjointedness.
Definition: DisjointBoxLayout.H:30
VectorTransformation vectorBlockTransformation(int a_nDst, const RealVect &a_xiSrc, int a_nSrc) const
return vector transformation from one block to another at a point.
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
A Real vector in SpaceDim-dimensional space.
Definition: RealVect.H:41
int m_nLayers
Definition: CubedSphere2DCS.H:153
Real m_rMin
Definition: CubedSphere2DCS.H:159
bool m_flatMap
Definition: CubedSphere2DCS.H:156
pure-virtual base class defining factory interface for MultiBlockCoordSys
Definition: MultiBlockCoordSys.H:409
CubedSphere2DCS()
default constructor
void regrid(const DisjointBoxLayout &a_newGrids)
void setRadii(Real a_rMin, Real a_rMax)
Definition: CubedSphere2DCS.H:190
Real m_rMax
Definition: CubedSphere2DCS.H:159
CubedSphere2DCSFactory()
Definition: CubedSphere2DCS.H:173
void defineBoundaries()
virtual ~CubedSphere2DCSFactory()
Definition: CubedSphere2DCS.H:178
RealVect mappedCoord(const RealVect &a_x) const
simple multiblock coordinate system for a cylinder
Definition: CubedSphere2DCS.H:35
virtual void define(int a_nResolution, int a_nLayers=0)