2020#include " TimeStepper.h"
2121#include " Tracers.h"
2222#include " VertAdv.h"
23+ #include " VertMix.h"
2324#include < string>
2425
2526namespace 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
0 commit comments