Skip to content

Commit 0b24888

Browse files
authored
Merge pull request #410 from hyungyukang/omega/vmix-hookup
This PR adds the velocity and tracer vertical mixing tendency terms. The implicit vertical mixing is solved by using TriDiagDiffSolver and is applied once at the end of each time step. - Implemented implicit vertical mixing using TriDiagDiffSolver. - Added VertMixImplicit to VertMix. - Applied vertical mixing once at the end of each time step. - Note: Tangential velocity, which is required by ComputeGradRichardsonNum in VertMix, is temporarily handled in VertMix.
2 parents 0eec69f + 0b915aa commit 0b24888

14 files changed

Lines changed: 604 additions & 14 deletions

components/omega/configs/Default.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ Omega:
6666
VelocityVertAdvTendencyEnable: true
6767
TracerVertAdvTendencyEnable: true
6868
PressureGradTendencyEnable: true
69+
VelVertMixTendencyEnable: true
70+
TracerVertMixTendencyEnable: true
6971
ManufacturedSolution:
7072
WavelengthX: 5.0e6
7173
WavelengthY: 4.33013e6

components/omega/src/ocn/OceanInit.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "Tracers.h"
3232
#include "VertAdv.h"
3333
#include "VertCoord.h"
34+
#include "VertMix.h"
3435

3536
#include "mpi.h"
3637

@@ -200,6 +201,7 @@ static int initOmegaModulesImpl(MPI_Comm Comm) {
200201
AuxiliaryState::init();
201202
Eos::init();
202203
PressureGrad::init();
204+
VertMix::init();
203205
Tendencies::init();
204206

205207
// Validate SurfaceTracerRestoring configuration

components/omega/src/ocn/OceanState.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,6 @@ class OceanState {
4848
OceanState(const OceanState &) = delete;
4949
OceanState(OceanState &&) = delete;
5050

51-
// Current time index
52-
// this index is circular so that it returns to index 0
53-
// if it is over max index
54-
I4 CurTimeIndex; ///< Time dimension array index for current level
55-
5651
/// Get the current time level index associated with a time level
5752
I4 getTimeIndex(const I4 TimeLevel) const;
5853

@@ -63,6 +58,11 @@ class OceanState {
6358

6459
std::string Name;
6560

61+
// Current time index
62+
// this index is circular so that it returns to index 0
63+
// if it is over max index
64+
I4 CurTimeIndex; ///< Time dimension array index for current level
65+
6666
// Sizes and global IDs
6767
// Note that all sizes are actual counts (1-based) so that loop extents
6868
// should always use the 0:NCellsXX-1 form.

components/omega/src/ocn/Tendencies.cpp

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "TimeStepper.h"
2121
#include "Tracers.h"
2222
#include "VertAdv.h"
23+
#include "VertMix.h"
2324
#include <string>
2425

2526
namespace OMEGA {
@@ -39,6 +40,7 @@ void Tendencies::init() {
3940
TimeStepper *DefTimeStepper = TimeStepper::getDefault();
4041
Eos *DefEos = Eos::getInstance();
4142
PressureGrad *DefPGrad = PressureGrad::getDefault();
43+
VertMix *DefVertMix = VertMix::getInstance();
4244

4345
I4 NTracers = Tracers::getNumTracers();
4446

@@ -78,9 +80,10 @@ void Tendencies::init() {
7880
TimeInterval TimeStep = DefTimeStepper->getTimeStep();
7981

8082
// Ceate default tendencies
81-
Tendencies::DefaultTendencies = create(
82-
"Default", DefHorzMesh, DefVertCoord, DefVertAdv, DefPGrad, DefEos,
83-
NTracers, TimeStep, &TendConfig, CustomThickTend, CustomVelTend);
83+
Tendencies::DefaultTendencies =
84+
create("Default", DefHorzMesh, DefVertCoord, DefVertAdv, DefPGrad,
85+
DefEos, DefVertMix, NTracers, TimeStep, &TendConfig,
86+
CustomThickTend, CustomVelTend);
8487

8588
DefaultTendencies->readConfig(OmegaConfig);
8689

@@ -317,6 +320,30 @@ void Tendencies::readConfig(Config *OmegaConfig ///< [in] Omega config
317320
HostArray1DI4(TracerIdsToRestoreVec.data(),
318321
TracerIdsToRestoreVec.size()));
319322
}
323+
324+
// Validate VertMix tendency
325+
Err += TendConfig.get("VelVertMixTendencyEnable",
326+
this->VMix->VelVertMixSetup.Enabled);
327+
CHECK_ERROR_ABORT(
328+
Err, "Tendencies: VelVertMixTendencyEnable not found in TendConfig");
329+
330+
Err += TendConfig.get("TracerVertMixTendencyEnable",
331+
this->VMix->TracerVertMixSetup.Enabled);
332+
CHECK_ERROR_ABORT(
333+
Err, "Tendencies: TracerVertMixTendencyEnable not found in TendConfig");
334+
335+
if (this->VMix->VelVertMixSetup.Enabled ||
336+
this->VMix->TracerVertMixSetup.Enabled) {
337+
338+
if (!this->EqState) {
339+
ABORT_ERROR("Tendencies: Eos must be initialized when"
340+
"vertical mixing tendencies are enabled");
341+
}
342+
if (!this->VMix) {
343+
ABORT_ERROR("Tendencies: VertMix must be initialized when"
344+
"vertical mixing tendencies are enabled");
345+
}
346+
}
320347
}
321348

322349
//------------------------------------------------------------------------------
@@ -380,6 +407,7 @@ Tendencies::Tendencies(const std::string &Name_, ///< [in] Name for tendencies
380407
VertAdv *VAdv, ///< [in] Vertical advection
381408
PressureGrad *PGrad, ///< [in] Pressure gradient
382409
Eos *EqState, ///< [in] Equation of state
410+
VertMix *VMix, ///< [in] Vertical mixing
383411
int NTracersIn, ///< [in] Number of tracers
384412
TimeInterval TimeStepIn, ///< [in] Time step
385413
Config *Options, ///< [in] Configuration options
@@ -393,7 +421,8 @@ Tendencies::Tendencies(const std::string &Name_, ///< [in] Name for tendencies
393421
TracerDiffusion(Mesh, VCoord), TracerHyperDiff(Mesh, VCoord),
394422
TracerHorzAdv(Mesh, VCoord), SurfaceTracerRestoring(Mesh),
395423
CustomThicknessTend(InCustomThicknessTend),
396-
CustomVelocityTend(InCustomVelocityTend), EqState(EqState), PGrad(PGrad) {
424+
CustomVelocityTend(InCustomVelocityTend), EqState(EqState), PGrad(PGrad),
425+
VMix(VMix) {
397426

398427
// Tendency arrays
399428
PseudoThicknessTend = Array2DReal("PseudoThicknessTend", Mesh->NCellsSize,
@@ -418,10 +447,11 @@ Tendencies::Tendencies(const std::string &Name_, ///< [in] Name for tendencies
418447
VertAdv *VAdv, ///< [in] Vertical advection
419448
PressureGrad *PGrad, ///< [in] Pressure gradient
420449
Eos *EqState, ///< [in] Equation of state
450+
VertMix *VMix, ///< [in] Vertical mixing
421451
int NTracersIn, ///< [in] Number of tracers
422452
TimeInterval TimeStepIn, ///< [in] Time step
423453
Config *Options) ///< [in] Configuration options
424-
: Tendencies(Name_, Mesh, VCoord, VAdv, PGrad, EqState, NTracersIn,
454+
: Tendencies(Name_, Mesh, VCoord, VAdv, PGrad, EqState, VMix, NTracersIn,
425455
TimeStepIn, Options, CustomTendencyType{},
426456
CustomTendencyType{}) {}
427457

components/omega/src/ocn/Tendencies.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include "TimeMgr.h"
4242
#include "VertAdv.h"
4343
#include "VertCoord.h"
44+
#include "VertMix.h"
4445

4546
#include <functional>
4647
#include <memory>
@@ -169,6 +170,7 @@ class Tendencies {
169170
VertAdv *VAdv, ///< [in] Vertical advection
170171
PressureGrad *PGrad, ///< [in] Pressure gradient
171172
Eos *EqState, ///< [in] Equation of state
173+
VertMix *VMix, ///< [in] Vertical mixing
172174
int NTracersIn, ///< [in] Number of tracers
173175
TimeInterval TimeStep, ///< [in] Time step
174176
Config *Options, ///< [in] Configuration options
@@ -181,6 +183,7 @@ class Tendencies {
181183
VertAdv *VAdv, ///< [in] Vertical advection
182184
PressureGrad *PGrad, ///< [in] Pressure gradient
183185
Eos *EqState, ///< [in] Equation of state
186+
VertMix *VMix, ///< [in] Vertical mixing
184187
int NTracersIn, ///< [in] Number of tracers
185188
TimeInterval TimeStep, ///< [in] Time step
186189
Config *Options ///< [in] Configuration options
@@ -199,6 +202,7 @@ class Tendencies {
199202
CustomTendencyType CustomVelocityTend;
200203
Eos *EqState; ///< Pointer to equation of state
201204
PressureGrad *PGrad; ///< Pointer to pressure gradient
205+
VertMix *VMix; ///< Pointer to vertical mixing
202206
I4 NTracers; ///< Number of tracers
203207
TimeInterval TimeStep; ///< Time step
204208

0 commit comments

Comments
 (0)