Skip to content

Commit 4644744

Browse files
committed
Major updates. Basically, I brought in all changes from the current (hidden from public) branch. The Taylor Green vortex test now does a great job even without periodic BCs. More testing needed. Also, there's a major speed and bug fix in MappedAMRPoissonOp.
1 parent b8c63d8 commit 4644744

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+2939
-601
lines changed

src/BCutil/BGScalarProfiles.H

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
/*******************************************************************************
2+
* SOMAR - Stratified Ocean Model with Adaptive Refinement
3+
* Developed by Ed Santilli & Alberto Scotti
4+
* Copyright (C) 2016
5+
* Philadelphia University &
6+
* University of North Carolina at Chapel Hill
7+
*
8+
* This library is free software; you can redistribute it and/or
9+
* modify it under the terms of the GNU Lesser General Public
10+
* License as published by the Free Software Foundation; either
11+
* version 2.1 of the License, or (at your option) any later version.
12+
*
13+
* This library is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16+
* Lesser General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU Lesser General Public
19+
* License along with this library; if not, write to the Free Software
20+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
21+
* USA
22+
*
23+
* For up-to-date contact information, please visit the repository homepage,
24+
* https://github.com/somarhub.
25+
******************************************************************************/
26+
27+
#ifndef ___BGScalarProfiles_H__INCLUDED___
28+
#define ___BGScalarProfiles_H__INCLUDED___
29+
30+
#include "EllipticBCInterface.H"
31+
32+
33+
// -----------------------------------------------------------------------------
34+
// -----------------------------------------------------------------------------
35+
class LinearBGScalarProfile: public EllipticBCValueClass
36+
{
37+
public:
38+
LinearBGScalarProfile (Real a_Nsq)
39+
: m_Nsq(a_Nsq)
40+
{;}
41+
42+
virtual ~LinearBGScalarProfile ()
43+
{;}
44+
45+
virtual void operator() (Real* a_pos,
46+
int* a_dir,
47+
Side::LoHiSide* a_side,
48+
Real* a_value,
49+
const RealVect& a_dx,
50+
Real a_time) const
51+
{
52+
a_value[0] = -m_Nsq * a_pos[CH_SPACEDIM-1];
53+
}
54+
55+
protected:
56+
Real m_Nsq;
57+
};
58+
59+
60+
// -----------------------------------------------------------------------------
61+
// -----------------------------------------------------------------------------
62+
class QuadraticBGScalarProfile: public EllipticBCValueClass
63+
{
64+
public:
65+
QuadraticBGScalarProfile (Real a_NsqBottom,
66+
Real a_NsqTop)
67+
: m_NsqBottom(a_NsqBottom),
68+
m_NsqTop(a_NsqTop)
69+
{
70+
LevelGeometry::staticDefine();
71+
m_H = LevelGeometry::getDomainLength(CH_SPACEDIM-1);
72+
m_zCoeff = (m_NsqBottom - m_NsqTop) / m_H;
73+
}
74+
75+
virtual ~QuadraticBGScalarProfile ()
76+
{;}
77+
78+
virtual void operator() (Real* a_pos,
79+
int* a_dir,
80+
Side::LoHiSide* a_side,
81+
Real* a_value,
82+
const RealVect& a_dx,
83+
Real a_time) const
84+
{
85+
Real z = a_pos[CH_SPACEDIM-1];
86+
Real Nsq = m_NsqBottom - m_zCoeff * z;
87+
a_value[0] = -Nsq * z;
88+
}
89+
90+
protected:
91+
Real m_NsqBottom;
92+
Real m_NsqTop;
93+
Real m_H;
94+
Real m_zCoeff;
95+
};
96+
97+
98+
// -----------------------------------------------------------------------------
99+
// -----------------------------------------------------------------------------
100+
class TanhBGScalarProfile: public EllipticBCValueClass
101+
{
102+
public:
103+
TanhBGScalarProfile (Real a_z0,
104+
Real a_delta,
105+
Real a_rho0,
106+
Real a_drho)
107+
: m_z0(a_z0),
108+
m_delta(a_delta),
109+
m_rho0(a_rho0),
110+
m_drho(a_drho)
111+
{;}
112+
113+
virtual ~TanhBGScalarProfile ()
114+
{;}
115+
116+
virtual void operator() (Real* a_pos,
117+
int* a_dir,
118+
Side::LoHiSide* a_side,
119+
Real* a_value,
120+
const RealVect& a_dx,
121+
Real a_time) const
122+
{
123+
Real arg = (a_pos[CH_SPACEDIM-1] - m_z0) / m_delta;
124+
a_value[0] = m_rho0 - m_drho*tanh(arg);
125+
}
126+
127+
protected:
128+
Real m_z0; // Center location
129+
Real m_delta; // Thickness
130+
Real m_rho0; // Median buoyancy value
131+
Real m_drho; // Max buoyancy difference
132+
};
133+
134+
135+
#endif //!___BGScalarProfiles_H__INCLUDED__
136+

src/BCutil/PhysBCUtil.H

Lines changed: 90 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,22 +43,48 @@
4343
class PhysBCUtil
4444
{
4545
public:
46+
// Scalar info -------------------------------------------------------------
47+
// This controls the number of scalars in the simulation, their names,
48+
// the number of components for each scalar, etc...
49+
50+
// These can be used to identify a specific scalar.
51+
// WARNING: Do not add scalars. SOMAR can't handle it yet.
52+
struct ScalarIndex {
53+
enum {
54+
BUOYANCY_DEVIATION = 0,
55+
_COUNT
56+
};
57+
};
58+
59+
// Basic accessors
60+
static inline unsigned int getNumScalars ();
61+
static inline const std::string& getName (unsigned int a_idx);
62+
static inline int getNumComps (unsigned int a_idx);
63+
static inline const IntVect& getGhostVect (unsigned int a_idx);
64+
65+
66+
// Construction / destruction ----------------------------------------------
67+
4668
// Constructor
4769
PhysBCUtil ();
4870

4971
// Destructor
5072
virtual ~PhysBCUtil ();
5173

52-
// Derived classes should be thier own factories.
74+
// Derived classes should be their own factories.
5375
virtual PhysBCUtil* newPhysBCUtil () const = 0;
5476

55-
// Reads BC data from file
77+
// Overridable constructor
5678
virtual void define ();
5779

80+
// Performs static initialization (IO, etc).
81+
static void staticDefine ();
82+
static inline bool isStaticDefined ();
83+
5884

5985
// ICs / background fields -------------------------------------------------
6086
// These functions have defaults that just set the FABs to zero and should
61-
// be overriden as needed.
87+
// be overridden as needed.
6288

6389
// Fills a FAB with the initial velocity.
6490
// Locations are in mapped space, but components are Cartesian.
@@ -82,7 +108,7 @@ public:
82108

83109

84110
// Utility functions -------------------------------------------------------
85-
// Most of these functions just call thier FAB versions and should not
111+
// Most of these functions just call their FAB versions and should not
86112
// need to be overridden.
87113

88114
// Sets the velocity ICs over an entire level
@@ -115,6 +141,7 @@ public:
115141
const Real a_time,
116142
const LevelGeometry& a_levGeo) const;
117143

144+
// TODO: This should be moved to StratUtils.
118145
// Computes the Brunt–Väisälä frequency on a single grid.
119146
// All ins and outs must be CC.
120147
// a_bFAB is the background buoyancy field.
@@ -127,6 +154,7 @@ public:
127154
const Box& a_destBox,
128155
const RealVect& a_dx) const;
129156

157+
// TODO: This should be moved to StratUtils.
130158
// Computes the Brunt–Väisälä frequency over an entire level.
131159
// a_Nsq must be CC.
132160
virtual void computeNSq (LevelData<FArrayBox>& a_Nsq,
@@ -139,8 +167,8 @@ public:
139167
// This is in case the BC's have an effect on the timestep.
140168
// Pass in currently computed dt, along with the cfl and dx. If the effect
141169
// of the BCs requires a decreased timestep, then the newly reduced timestep
142-
// is returned. In the default case, this just returns a_dt back; however,
143-
// derived classes may actually have an effect.
170+
// is returned. In the default case, this just returns a_dt back. Derived
171+
// classes may need this.
144172
virtual void computeBoundaryDt (Real& a_dt,
145173
const Real a_cfl,
146174
const LevelGeometry& a_levGeo) const;
@@ -201,7 +229,7 @@ public:
201229
// Sets ghosts needed to calculate the viscous source term nu.L[vel]
202230
virtual Tuple<BCMethodHolder, SpaceDim> viscousSourceFuncBC () const;
203231

204-
// Used in single-compoent velocity TGA solves
232+
// Used in single-component velocity TGA solves
205233
virtual BCMethodHolder viscousSolveFuncBC (int a_dir) const;
206234

207235
// returns single-component BC for viscous refluxing solves
@@ -319,10 +347,13 @@ protected:
319347
// Member variables and utility functions ----------------------------------
320348

321349
// Have we read params from the input file yet?
322-
static bool s_staticMembersSet;
350+
static bool m_isStaticDefined;
323351

324352
static RealVect s_domLength;
353+
325354
static bool s_useBackgroundScalar;
355+
static int s_bgScalarProfile;
356+
static RefCountedPtr<EllipticBCValueClass> s_stdProfilePtr;
326357

327358
static RealVect s_tidalU0;
328359
static Real s_tidalOmega;
@@ -331,10 +362,61 @@ protected:
331362
static bool s_useSpongeLayer;
332363
static Real s_spongeWidth[CH_SPACEDIM][2];
333364
static Real s_spongeDtMult[CH_SPACEDIM][2];
365+
366+
// Scalar metadata
367+
struct ScalarMetaData
368+
{
369+
std::string name;
370+
int numComps;
371+
IntVect ghostVect;
372+
};
373+
static const ScalarMetaData s_scalarMetaData[ScalarIndex::_COUNT];
334374
};
335375

336376

337377

378+
// -----------------------------------------------------------------------------
379+
// Simple accessor
380+
// -----------------------------------------------------------------------------
381+
inline bool PhysBCUtil::isStaticDefined ()
382+
{
383+
return m_isStaticDefined;
384+
}
385+
386+
387+
// -----------------------------------------------------------------------------
388+
// Simple accessor
389+
// -----------------------------------------------------------------------------
390+
inline unsigned int PhysBCUtil::getNumScalars ()
391+
{
392+
return ScalarIndex::_COUNT;
393+
}
394+
395+
396+
// -----------------------------------------------------------------------------
397+
// Simple accessor
398+
// -----------------------------------------------------------------------------
399+
inline const std::string& PhysBCUtil::getName (unsigned int a_idx) {
400+
return s_scalarMetaData[a_idx].name;
401+
}
402+
403+
404+
// -----------------------------------------------------------------------------
405+
// Simple accessor
406+
// -----------------------------------------------------------------------------
407+
inline int PhysBCUtil::getNumComps (unsigned int a_idx) {
408+
return s_scalarMetaData[a_idx].numComps;
409+
}
410+
411+
412+
// -----------------------------------------------------------------------------
413+
// Simple accessor
414+
// -----------------------------------------------------------------------------
415+
inline const IntVect& PhysBCUtil::getGhostVect (unsigned int a_idx) {
416+
return s_scalarMetaData[a_idx].ghostVect;
417+
}
418+
419+
338420
// -----------------------------------------------------------------------------
339421
// Simple accessor
340422
// -----------------------------------------------------------------------------

0 commit comments

Comments
 (0)