BISICLES AMR ice sheet model  0.9
LevelSigmaCS.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 _LEVELSIGMACS_H_
12 #define _LEVELSIGMACS_H_
13 
14 #include "DisjointBoxLayout.H"
15 #include "LevelData.H"
16 #include "FArrayBox.H"
17 #include "NodeFArrayBox.H"
18 #include "FluxBox.H"
19 #include "RealVect.H"
20 #include "Interval.H"
21 #include "AMRIO.H"
22 
23 
24 #include "NamespaceHeader.H"
25 
26 #define BISICLES_LAYERED 0
27 #define BISICLES_FULLZ 1
28 #if CH_SPACEDIM == 2
29 // for now, BISICLES_LAYERED is the same as 2D, but
30 // if we one day look at flow line models there could a 1D variant
31 #define BISICLES_Z 0
32 #elif CH_SPACEDIM == 3
33 // for now, BISICLES_FULLZ is the same as 3D, but
34 // if we one day look at flow line models there could a 2D variant
35 #define BISICLES_Z 1
36 #elif CH_SPACEDIM == 1
37 // for now, same as 2D
38 // for now, BISICLES_LAYERED is the same as 2D, but
39 // if we one day look at flow line models there could a 1D variant
40 #define BISICLES_Z 0
41 #endif
42 
44 
49 {
50 public:
52  LevelSigmaCS();
53 
55  LevelSigmaCS(const DisjointBoxLayout& a_grids,
56  const RealVect& a_dx,
57  const IntVect& a_ghostVect = IntVect::Unit);
58 
59  LevelSigmaCS( const DisjointBoxLayout& a_grids,
60  const RealVect& a_dx,
61  const LevelSigmaCS& a_fineCS,
62  int a_nRef
63  );
67  virtual ~LevelSigmaCS();
68 
69  void define(const DisjointBoxLayout& a_grids,
70  const RealVect& a_dx,
71  const IntVect& a_ghostVect = IntVect::Unit);
72 
74  void define(const LevelSigmaCS& a_fineCS,
75  int a_nRef);
76 
79 
82  RealVect realCoord(const RealVect& a_Xi, const DataIndex& a_index) const;
83 
85 
88  RealVect mappedCoord(const RealVect& a_x, const DataIndex& a_index) const;
89 
91 
93  void getNodeRealCoordinates(LevelData<NodeFArrayBox>& a_nodeCoords) const;
94 
95 
96  // return cell spacing dx
97  RealVect dx() const {return m_dx;}
98 
100  LevelData<FArrayBox>& getH();
101 
103  const LevelData<FArrayBox>& getH() const;
104 
106  LevelData<FluxBox>& getFaceH();
107 
109  const LevelData<FluxBox>& getFaceH() const;
110 
112  const LevelData<FArrayBox>& getTopography() const;
113 
115  LevelData<FArrayBox>& getTopography();
116 
118 
119  void setTopography(const LevelData<FArrayBox>& a_topography);
121 
124  //void setUnitShift(const RealVect& a_unitShift)
125  //{
126  // m_unitShift = a_unitShift;
127  //}
128 
129 
131 
145  void setBackgroundSlope(const RealVect& a_backgroundSlope)
146  {
147  m_backgroundSlope = a_backgroundSlope;
148  }
149 
150  const RealVect& getBackgroundSlope() const
151  {
152  return m_backgroundSlope;
153  }
154 
155 
156  //sets the surface elevation (at cell centres)
157  void setSurfaceHeight(const LevelData<FArrayBox>& a_surface);
158  //sets the surface gradient (at cell centres)
159  void setGradSurface(const LevelData<FArrayBox>& a_gradSurface);
160  //sets the surface gradient (at cell faces)
161  void setGradSurfaceFace(const LevelData<FluxBox>& a_gradSurface);
162 
163 
164  //returns the surface elevation (at cell centres)
165  const LevelData<FArrayBox>& getSurfaceHeight() const ;
166  //returns the surface gradient (at cell centres)
167  const LevelData<FArrayBox>& getGradSurface() const;
168  //returns the surface gradient (at cell faces)
169  const LevelData<FluxBox>& getGradSurfaceFace() const;
170  //returns the thickness over flotation (at cell centres)
171  const LevelData<FArrayBox>& getThicknessOverFlotation() const;
172 
174 
178  void getSurfaceHeight(LevelData<FArrayBox>& a_zSurface) const;
179 
181 
187  const LevelData<BaseFab<int> >& getFloatingMask() const {return m_floatingMask;}
188 
190 
193  void recomputeGeometry( const LevelSigmaCS* a_crseCoords,
194  const int a_refRatio) ;
195 
197 
200  void recomputeGeometryFace( const LevelSigmaCS* a_crseCoords,
201  const int a_refRatio) ;
202 
204 
205  const LevelData<FArrayBox>& deltaFactors() const;
206 
208 
209  const LevelData<FluxBox>& faceDeltaFactors() const;
210 
211 
213  Real seaLevel() const {return m_seaLevel;}
214 
216  void setSeaLevel(const Real& a_seaLevel) {m_seaLevel = a_seaLevel;}
217 
219  Real iceDensity() const {return m_iceDensity;}
221  Real waterDensity() const {return m_waterDensity;}
223  Real gravity() const {return m_gravity;}
224 
226  void setIceDensity(const Real& a_iceDensity)
227  {m_iceDensity = a_iceDensity;}
228  void setWaterDensity(const Real& a_waterDensity)
229  {m_waterDensity = a_waterDensity;}
230  void setGravity(const Real& a_gravity)
231  {m_gravity = a_gravity;}
232 
233 
235  bool isDefined() const {return m_isDefined;}
236 
239  LevelSigmaCS* makeCoarser(int a_coarsenFactor) const;
240 
242  const DisjointBoxLayout& grids() const {return m_grids;}
243 
244  const LayoutData<bool>& anyFloating() const { return m_anyFloating;}
245 
247 
263 
265  /***
266  Interpolating thickness and topography independently tends to
267  move the grounding line, and results in steep surfaces there
268  which are not seen in interpolation of the surface itself.
269  interpFromCoarse interpolates topography, the upper and lower surfaces
270  then adjusts base (and so thickness) to maintain the grounding line.
271 
272  optionally, topography and thickness can be set elsewhere,
273  and the mask can be recomputed, in either the valid region, or in
274  both valid region and ghost region.
275  */
276  void interpFromCoarse(const LevelSigmaCS& a_crseCoords,
277  const int a_refinementRatio,
278  const bool a_interpolateTopography = true,
279  const bool a_interpolateThickness = true,
280  const bool a_preserveMask = true,
281  const bool a_interpolateTopographyGhost = true,
282  const bool a_interpolateThicknessGhost = true,
283  const bool a_preserveMaskGhost = true,
284  int a_thicknessInterpolationMethod = STD_THICKNESS_INTERPOLATION_METHOD);
285 
286 
287 
288 
289 
290  // exchange topography accounting for the unit shift.
291  void exchangeTopography();
292  // exchange a_level accounting for the unit shift.
293  void unitShiftExchange(LevelData<FArrayBox>& a_level);
294 
296  IntVect ghostVect() const {return m_ghostVect;}
297 
298 protected:
299 
301  DisjointBoxLayout m_grids;
302 
304  DisjointBoxLayout m_Hgrids;
305 
306  // cell spacing
307  RealVect m_dx;
308 
310  IntVect m_ghostVect;
311 
312  // for periodic problems : a vector with components
313  // (topography(x + Lx , y) - topography(x , y),
314  // (topography(x , y + Ly) - topography(x , y)
315  RealVect m_unitShift;
316 
318 
320  LevelData<FArrayBox> m_topography;
321 
323  LevelData<FArrayBox> m_H;
324 
326  LevelData<FluxBox> m_faceH;
327 
329  LevelData<FArrayBox> m_surface;
330 
332  LevelData<FArrayBox> m_gradSurface;
333 
335  LevelData<FluxBox> m_gradSurfaceFace;
336 
338  LevelData<FArrayBox> m_thicknessOverFlotation;
339 
341  LevelData<BaseFab<int> > m_floatingMask;
342 
344  LayoutData<bool> m_anyFloating;
346  LevelData<FArrayBox> m_deltaFactors;
347 
349  LevelData<FluxBox> m_faceDeltaFactors;
350 
353 
354 
355  // sea level
357 
360 
363 
365  Real m_gravity;
366 
367  // set a reasonable set of default values
368  void setDefaultValues();
369 
371  void computeDeltaFactors();
372 
374  void computeSurface(const LevelSigmaCS* a_crseCoords,
375  const int a_refRatio);
376 
378  void computeFloatingMask(const LevelData<FArrayBox>& a_surface);
379 
380 
381 #if BISICLES_Z == BISICLES_LAYERED
382 
383 public:
384  // some poor man's multidim stuff that is only useful when we
385  // are treating the problem as a stack of layers with constant
386  // sigma at the boundaries which never get refined
387 
388  // vector of sigma values at the layer interfaces
389  const Vector<Real>& getFaceSigma() const
390  { return m_faceSigma; }
391 
392  //vector of delta sigma's (at the layer midpoints)
393  const Vector<Real>& getDSigma() const
394  { return m_dSigma;}
395 
396  // vector of sigma values at the layer midpoints
397  const Vector<Real>& getSigma() const
398  { return m_sigma; }
399 
400  void setFaceSigma(const Vector<Real>& a_faceSigma)
401  {
402  m_faceSigma = a_faceSigma;
403  m_sigma.resize(m_faceSigma.size()-1);
404  m_dSigma.resize(m_faceSigma.size()-1);
405  for (unsigned int i = 0; i < m_sigma.size(); ++i)
406  {
407  //layer midpoint
408  m_sigma[i] = 0.5 * (a_faceSigma[i] + a_faceSigma[i+1]);
409  //layer delta sigma
410  m_dSigma[i] = (a_faceSigma[i+1] - a_faceSigma[i]);
411  }
412  }
413 
414 protected:
415 
416  Vector<Real> m_faceSigma;
417  Vector<Real> m_sigma;
418  Vector<Real> m_dSigma;
419 
420 #endif
421 
422 
423 };
424 
425 
426 // specializations of IO routines for LayoutData<SigmaCS>
427 
428 void WriteSigmaMappedUGHDF5(const string& a_fileRoot,
429  const DisjointBoxLayout& a_grids,
430  const LevelData<FArrayBox>& a_data,
431  const LevelSigmaCS& a_CoordSys,
432  const Box& a_domainBox);
433 
434 void WriteSigmaMappedUGHDF5(const string& a_fileRoot,
435  const DisjointBoxLayout& a_grids,
436  const LevelData<FArrayBox>& a_data,
437  const LevelSigmaCS& a_CoordSys,
438  const Vector<string>& a_vectNames,
439  const Box& a_domainBox);
440 
441 void
442 WriteSigmaMappedAMRHierarchyHDF5(const string& a_fileRoot,
443  const Vector<DisjointBoxLayout>& a_vectGrids,
444  const Vector<LevelData<FArrayBox>* > & a_vectData,
445  const Vector<string>& a_vectNames,
446  const Vector<const LevelSigmaCS* >& a_vectCoordSys,
447  const Box& a_baseDomain,
448  const Real& a_dt,
449  const Real& a_time,
450  const Vector<int>& a_vectRatio,
451  const int& a_numLevels);
452 
453 #include "NamespaceFooter.H"
454 
455 #endif
Real iceDensity() const
ice density – this is probably an interim approach
Definition: LevelSigmaCS.H:219
void recomputeGeometryFace(const LevelSigmaCS *a_crseCoords, const int a_refRatio)
recomputes quantities which are dependent on face-centered H.
Definition: LevelSigmaCS.cpp:663
RealVect realCoord(const RealVect &a_Xi, const DataIndex &a_index) const
Definition: LevelSigmaCS.cpp:248
ThicknessInterpolationMethod
choice of thickness interpolation method in interpFromCoarse
Definition: LevelSigmaCS.H:259
virtual ~LevelSigmaCS()
Definition: LevelSigmaCS.cpp:50
LevelData< FArrayBox > m_deltaFactors
Definition: LevelSigmaCS.H:346
const LevelData< FArrayBox > & getSurfaceHeight() const
returns the cell-centred surface elevation
Definition: LevelSigmaCS.cpp:496
Real m_gravity
acceleration due to gravity – probably an interim approach
Definition: LevelSigmaCS.H:365
const LayoutData< bool > & anyFloating() const
Definition: LevelSigmaCS.H:244
LevelData< FArrayBox > m_H
cell-centered ice thickness
Definition: LevelSigmaCS.H:323
const LevelData< FluxBox > & getGradSurfaceFace() const
returns the face-centred surface gradient
Definition: LevelSigmaCS.cpp:510
LevelData< FluxBox > m_gradSurfaceFace
face-centered gradient of surface elevation
Definition: LevelSigmaCS.H:335
void WriteSigmaMappedUGHDF5(const string &a_fileRoot, const DisjointBoxLayout &a_grids, const LevelData< FArrayBox > &a_data, const LevelSigmaCS &a_CoordSys, const Box &a_domainBox)
Definition: LevelSigmaCS.cpp:984
Real m_waterDensity
seawater density – probably an interim approach
Definition: LevelSigmaCS.H:362
LevelSigmaCS()
default constructor
Definition: LevelSigmaCS.cpp:31
void setSeaLevel(const Real &a_seaLevel)
set sea level
Definition: LevelSigmaCS.H:216
void setSurfaceHeight(const LevelData< FArrayBox > &a_surface)
sets the cell-centered surface height
Definition: LevelSigmaCS.cpp:414
void computeSurface(const LevelSigmaCS *a_crseCoords, const int a_refRatio)
(re)compute surface elevation and gradients
Definition: LevelSigmaCS.cpp:795
void setIceDensity(const Real &a_iceDensity)
interim or not, we also need to set these
Definition: LevelSigmaCS.H:226
const LevelData< FArrayBox > & getTopography() const
returns a const-reference to the cell-centered topography
Definition: LevelSigmaCS.cpp:372
Real seaLevel() const
returns sea level
Definition: LevelSigmaCS.H:213
const LevelData< FArrayBox > & getGradSurface() const
returns the cell-centred surface gradient
Definition: LevelSigmaCS.cpp:503
void recomputeGeometry(const LevelSigmaCS *a_crseCoords, const int a_refRatio)
recomputes quantities which are dependent on cell-centered H.
Definition: LevelSigmaCS.cpp:557
void computeFloatingMask(const LevelData< FArrayBox > &a_surface)
sets floating mask based on surface height
Definition: LevelSigmaCS.cpp:913
RealVect m_unitShift
Definition: LevelSigmaCS.H:315
void computeDeltaFactors()
(re)compute delta factors
Definition: LevelSigmaCS.cpp:736
Real gravity() const
acceleration due to gravity – probably an interim approach
Definition: LevelSigmaCS.H:223
DisjointBoxLayout m_grids
Definition: LevelSigmaCS.H:301
const LevelData< FArrayBox > & deltaFactors() const
return cell-centered and ,
Definition: LevelSigmaCS.cpp:971
LevelData< FluxBox > & getFaceH()
returns modifiable face-centered H
Definition: LevelSigmaCS.cpp:356
void exchangeTopography()
Definition: LevelSigmaCS.cpp:1506
LevelData< FArrayBox > & getH()
returns modifiable cell-centered H (ice sheet thickness) for this
Definition: LevelSigmaCS.cpp:341
void interpFromCoarse(const LevelSigmaCS &a_crseCoords, const int a_refinementRatio, const bool a_interpolateTopography=true, const bool a_interpolateThickness=true, const bool a_preserveMask=true, const bool a_interpolateTopographyGhost=true, const bool a_interpolateThicknessGhost=true, const bool a_preserveMaskGhost=true, int a_thicknessInterpolationMethod=STD_THICKNESS_INTERPOLATION_METHOD)
fill the data in this by interpolation from a coarser level
Definition: LevelSigmaCS.cpp:1202
const Vector< Real > & getDSigma() const
Definition: LevelSigmaCS.H:393
RealVect m_backgroundSlope
Definition: LevelSigmaCS.H:317
DisjointBoxLayout m_Hgrids
"flattened" grids (in 3d) for quantities like H
Definition: LevelSigmaCS.H:304
void unitShiftExchange(LevelData< FArrayBox > &a_level)
Definition: LevelSigmaCS.cpp:1512
void getNodeRealCoordinates(LevelData< NodeFArrayBox > &a_nodeCoords) const
return Cartesian XYZ locations of nodes
Definition: LevelSigmaCS.cpp:310
Real waterDensity() const
seawater density – probably an interim approach
Definition: LevelSigmaCS.H:221
LevelData< FArrayBox > m_surface
cell-centered surface elevation
Definition: LevelSigmaCS.H:329
Basic Sigma fourth-order coordinate system on an AMR level.
Definition: LevelSigmaCS.H:48
void setGradSurface(const LevelData< FArrayBox > &a_gradSurface)
sets the cell-centered surface gradient
Definition: LevelSigmaCS.cpp:440
const LevelData< FArrayBox > & getThicknessOverFlotation() const
Definition: LevelSigmaCS.cpp:516
LayoutData< bool > m_anyFloating
is anything floating?
Definition: LevelSigmaCS.H:344
const DisjointBoxLayout & grids() const
access function
Definition: LevelSigmaCS.H:242
LevelData< FluxBox > m_faceH
face-centered ice thickness
Definition: LevelSigmaCS.H:326
bool m_isDefined
has this object been defined?
Definition: LevelSigmaCS.H:352
void setGravity(const Real &a_gravity)
Definition: LevelSigmaCS.H:230
const RealVect & getBackgroundSlope() const
Definition: LevelSigmaCS.H:150
LevelSigmaCS * makeCoarser(int a_coarsenFactor) const
Definition: LevelSigmaCS.cpp:1191
Vector< Real > m_dSigma
Definition: LevelSigmaCS.H:418
LevelData< BaseFab< int > > m_floatingMask
floating mask
Definition: LevelSigmaCS.H:341
void WriteSigmaMappedAMRHierarchyHDF5(const string &a_fileRoot, const Vector< DisjointBoxLayout > &a_vectGrids, const Vector< LevelData< FArrayBox > * > &a_vectData, const Vector< string > &a_vectNames, const Vector< const LevelSigmaCS * > &a_vectCoordSys, const Box &a_baseDomain, const Real &a_dt, const Real &a_time, const Vector< int > &a_vectRatio, const int &a_numLevels)
Definition: LevelSigmaCS.cpp:1042
IntVect m_ghostVect
ghost vector
Definition: LevelSigmaCS.H:310
void setWaterDensity(const Real &a_waterDensity)
Definition: LevelSigmaCS.H:228
LevelData< FArrayBox > m_thicknessOverFlotation
cell-centered thickness over flotation
Definition: LevelSigmaCS.H:338
void setFaceSigma(const Vector< Real > &a_faceSigma)
Definition: LevelSigmaCS.H:400
const LevelData< BaseFab< int > > & getFloatingMask() const
returns floating mask specifying whether ice is grounded or floating
Definition: LevelSigmaCS.H:187
const LevelData< FluxBox > & faceDeltaFactors() const
return face-centered and
Definition: LevelSigmaCS.cpp:979
Vector< Real > m_faceSigma
Definition: LevelSigmaCS.H:416
Real m_iceDensity
ice density
Definition: LevelSigmaCS.H:359
void setBackgroundSlope(const RealVect &a_backgroundSlope)
set the unit topography difference
Definition: LevelSigmaCS.H:145
Vector< Real > m_sigma
Definition: LevelSigmaCS.H:417
Real m_seaLevel
Definition: LevelSigmaCS.H:356
RealVect mappedCoord(const RealVect &a_x, const DataIndex &a_index) const
given coordinate in real space, return location in mapped space
Definition: LevelSigmaCS.cpp:279
const Vector< Real > & getFaceSigma() const
Definition: LevelSigmaCS.H:389
void setDefaultValues()
Definition: LevelSigmaCS.cpp:709
void setTopography(const LevelData< FArrayBox > &a_topography)
sets the base height.
Definition: LevelSigmaCS.cpp:390
IntVect ghostVect() const
accessor for ghost vector
Definition: LevelSigmaCS.H:296
RealVect dx() const
Definition: LevelSigmaCS.H:97
LevelData< FluxBox > m_faceDeltaFactors
Definition: LevelSigmaCS.H:349
void setGradSurfaceFace(const LevelData< FluxBox > &a_gradSurface)
sets the face-centred surface gradient
Definition: LevelSigmaCS.cpp:466
RealVect m_dx
Definition: LevelSigmaCS.H:307
LevelData< FArrayBox > m_gradSurface
cell-centered gradient of surface elevation
Definition: LevelSigmaCS.H:332
bool isDefined() const
returns true if this object has been defined.
Definition: LevelSigmaCS.H:235
const Vector< Real > & getSigma() const
Definition: LevelSigmaCS.H:397
LevelData< FArrayBox > m_topography
cell-centered topography
Definition: LevelSigmaCS.H:320
void define(const DisjointBoxLayout &a_grids, const RealVect &a_dx, const IntVect &a_ghostVect=IntVect::Unit)
Definition: LevelSigmaCS.cpp:55