ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_TI_slow_headers.H
Go to the documentation of this file.
1 #ifndef ERF_SLOW_INTEGRATION_H_
2 #define ERF_SLOW_INTEGRATION_H_
3 
4 #include "AMReX_MultiFab.H"
5 #include "AMReX_BCRec.H"
6 #include "AMReX_YAFluxRegister.H"
7 #include "AMReX_MultiCutFab.H"
8 #include "AMReX_EBMultiFabUtil.H"
9 
10 #include "ERF_DataStruct.H"
11 #include "ERF_IndexDefines.H"
12 #include "ERF_SurfaceLayer.H"
13 #include "ERF_Advection.H"
14 #include "ERF_Diffusion.H"
15 #include "ERF_EddyViscosity.H"
16 #include "ERF_TerrainMetrics.H"
17 #include "ERF_TileNoZ.H"
18 #include "ERF_EB.H"
19 #include "ERF_ReadBndryPlanes.H"
20 #include "Prob/ERF_CloudChamber.H"
21 
22 /**
23  * @brief Budget tracking for the cloud chamber simulation.
24  */
25 class CloudChamberBudget;
26 
27 namespace erf_auxiliary { class AuxiliaryInertTracer; }
28 namespace erf_sbm { class SBMStateManager; class SBMTransport; }
29 
30 /**
31  * @brief Driver for the SHOC physics model.
32  */
33 class ShocDriver;
34 
35 /**
36  * The weight of the fluxes of RK stage nrk at this level in the update the step ends with. The
37  * compressible integrator and the anelastic MidPoint integrator update from their final stage
38  * alone (nrk = 2 and nrk = 1), which takes weight 1. The anelastic RK2 integrator is Heun's,
39  * S^{n+1} = S^n + dt (R0 + R1) / 2, so both of its stages take weight 1/2.
40  *
41  * @param[in] solverChoice the solver options
42  * @param[in] level the level being advanced
43  * @param[in] nrk the RK stage
44  */
45 inline amrex::Real
46 StageFluxWeight (const SolverChoice& solverChoice, int level, int nrk)
47 {
48  if (solverChoice.anelastic[level] == 1) {
49  if (solverChoice.anelastic_type[level] == AnelasticType::RK2) {
50  return amrex::Real(0.5);
51  }
52  return (nrk == 1) ? amrex::Real(1.) : amrex::Real(0.);
53  }
54  return (nrk == 2) ? amrex::Real(1.) : amrex::Real(0.);
55 }
56 
57 /**
58  * The weight with which the fluxes of RK stage nrk at this level go into the flux registers:
59  * the weight of that stage's fluxes in the update the step ends with, or zero if they are not
60  * registered. Only with two-way coupling and more than one level. The compressible integrator
61  * and the anelastic MidPoint integrator update from their final stage alone (nrk = 2 and nrk = 1),
62  * which takes weight 1. The anelastic RK2 integrator is Heun's, S^{n+1} = S^n + dt (R0 + R1) / 2,
63  * so both of its stages take weight 1/2. Every stage that adds fluxes to the registers must use
64  * this, so that the registers hold the fluxes the update applied.
65  *
66  * @param[in] solverChoice the solver options
67  * @param[in] level the level being advanced
68  * @param[in] finest_level the finest level
69  * @param[in] nrk the RK stage
70  */
71 inline amrex::Real
72 RefluxStageWeight (const SolverChoice& solverChoice, int level, int finest_level, int nrk)
73 {
74  if (solverChoice.coupling_type != CouplingType::TwoWay || finest_level == 0) {
75  return amrex::Real(0.);
76  }
77  return StageFluxWeight(solverChoice, level, nrk);
78 }
79 
80 /**
81  * Whether the fluxes of RK stage nrk at this level go into the flux registers
82  * (RefluxStageWeight is not zero).
83  */
84 inline bool
85 IsRefluxStage (const SolverChoice& solverChoice, int level, int finest_level, int nrk)
86 {
87  return RefluxStageWeight(solverChoice, level, finest_level, nrk) > amrex::Real(0.);
88 }
89 
90 void erf_make_tau_terms (int level, int nrk,
91  const amrex::Vector<amrex::BCRec>& domain_bcs_type,
92  const amrex::MultiFab& z_phys_nd,
93  amrex::Vector<amrex::MultiFab>& S_data,
94  const amrex::MultiFab& xvel,
95  const amrex::MultiFab& yvel,
96  const amrex::MultiFab& zvel,
97  amrex::Vector<std::unique_ptr<amrex::MultiFab>>& Tau_lev,
98  amrex::Vector<std::unique_ptr<amrex::MultiFab>>& Tau_corr_lev,
99  amrex::MultiFab* SmnSmn,
100  amrex::MultiFab* eddyDiffs,
101  const amrex::Geometry geom,
102  const SolverChoice& solverChoice,
103  const amrex::Vector<std::unique_ptr<SurfaceLayer>>& SurfLayer,
104  amrex::Gpu::DeviceVector<amrex::Real>& stretched_dz_d,
105  const amrex::MultiFab& detJ,
106  amrex::Vector<std::unique_ptr<amrex::MultiFab>>& mapfac,
107  const amrex::MultiFab& ax,
108  const amrex::MultiFab& ay,
109  const amrex::MultiFab& az,
110  const eb_& ebfact,
111  const amrex::MultiFab* ib_wall_face13 = nullptr,
112  const amrex::MultiFab* ib_wall_face23 = nullptr);
113 
114 void copy_surface_tau_for_implicit (amrex::Vector<std::unique_ptr<amrex::MultiFab>>& Tau_lev,
115  amrex::Vector<std::unique_ptr<amrex::MultiFab>>& Tau_corr_lev);
116 
117 /**
118  * Function for computing the slow RHS for the evolution equations for the density, potential temperature and momentum.
119  *
120  */
121 void erf_slow_rhs_pre (int level, int finest_level, int nrk,
122  double dt,
123  amrex::Vector<amrex::MultiFab>& S_rhs,
124  amrex::Vector<amrex::MultiFab>& S_old,
125  amrex::Vector<amrex::MultiFab>& S_data,
126  const amrex::MultiFab & S_prim,
127  const amrex::MultiFab & qt,
128  amrex::MultiFab& avg_xmom,
129  amrex::MultiFab& avg_ymom,
130  amrex::MultiFab& avg_zmom,
131  const amrex::MultiFab& xvel,
132  const amrex::MultiFab& yvel,
133  const amrex::MultiFab& zvel,
134  std::unique_ptr<amrex::MultiFab>& z_t,
135  const amrex::MultiFab& cc_src,
136  const amrex::MultiFab& xmom_src,
137  const amrex::MultiFab& ymom_src,
138  const amrex::MultiFab& zmom_src,
139  const amrex::MultiFab& buoyancy,
140  const amrex::MultiFab* zmom_crse_rhs,
141  amrex::Vector<std::unique_ptr<amrex::MultiFab>>& Tau_lev,
142  amrex::Vector<std::unique_ptr<amrex::MultiFab>>& Tau_corr_lev,
143  amrex::Vector<amrex::Vector<std::unique_ptr<amrex::MultiFab>>>& Tau_EB,
144  amrex::MultiFab* SmnSmn,
145  amrex::MultiFab* eddyDiffs,
146  amrex::MultiFab* Hfx1,
147  amrex::MultiFab* Hfx2,
148  amrex::MultiFab* Hfx3,
149  amrex::MultiFab* Q1fx1,
150  amrex::MultiFab* Q1fx2,
151  amrex::MultiFab* Q1fx3,
152  amrex::MultiFab* Q2fx3,
153  amrex::MultiFab* Diss,
154  amrex::MultiFab* mf_surface_fluxes,
155  amrex::MultiFab* Hfx3_EB,
156  const amrex::Geometry geom,
157  const SolverChoice& solverChoice,
158  const amrex::Vector<std::unique_ptr<SurfaceLayer>>& SurfLayer,
159  const amrex::Gpu::DeviceVector<amrex::BCRec>& domain_bcs_type_d,
160  const amrex::Vector<amrex::BCRec>& domain_bcs_type,
161  const amrex::MultiFab& z_phys_nd,
162  const amrex::MultiFab& z_phys_cc,
163  const amrex::MultiFab& ax,
164  const amrex::MultiFab& ay,
165  const amrex::MultiFab& az,
166  const amrex::MultiFab& dJ,
167  amrex::Gpu::DeviceVector<amrex::Real>& stretched_dz_d,
168  amrex::Vector<amrex::MultiFab>& gradp,
169  amrex::Vector<std::unique_ptr<amrex::MultiFab>>& mapfac,
170  const eb_& ebfact,
171 #ifdef ERF_USE_EAMXX_SHOC
172  SHOCInterface* eamxx_shoc_lev,
173 #endif
174  ShocDriver* native_shoc_lev,
175  amrex::YAFluxRegister* fr_as_crse,
176  amrex::YAFluxRegister* fr_as_fine,
177  const amrex::MultiFab* cloud_chamber_base_state,
178  const erf_cloud_chamber::Config* cloud_chamber_config,
179  CloudChamberBudget* cloud_budget,
180  const amrex::MultiFab* ib_wall_face13 = nullptr,
181  const amrex::MultiFab* ib_wall_face23 = nullptr,
182  const amrex::MultiFab* ib_wall_face33 = nullptr,
183  const amrex::MultiFab* ib_wall_hfx = nullptr);
184 
185 /**
186  * Function for computing the slow RHS for the evolution equations for the scalars other than density or potential temperature
187  *
188  */
189 void erf_slow_rhs_post (int level, int finest_level, int nrk,
190  double step_old_time,
191  double input_time,
192  double target_time,
193  double dt,
194  int n_qstate,
195  amrex::Vector<amrex::MultiFab>& S_rhs,
196  amrex::Vector<amrex::MultiFab>& S_old,
197  amrex::Vector<amrex::MultiFab>& S_new,
198  amrex::Vector<amrex::MultiFab>& S_data,
199  const amrex::MultiFab& S_prim,
200  amrex::MultiFab& avg_xmom,
201  amrex::MultiFab& avg_ymom,
202  amrex::MultiFab& avg_zmom,
203  const amrex::MultiFab& xvel,
204  const amrex::MultiFab& yvel,
205  const amrex::MultiFab& zvel,
206  const amrex::MultiFab& source,
207  amrex::MultiFab* terrain_blank,
208  amrex::MultiFab* terrain_blank_xface,
209  amrex::MultiFab* terrain_blank_yface,
210  amrex::MultiFab* terrain_blank_zface,
211  const amrex::MultiFab* SmnSmn,
212  const amrex::MultiFab* eddyDiffs,
213  amrex::MultiFab* Hfx1,
214  amrex::MultiFab* Hfx2,
215  amrex::MultiFab* Hfx3,
216  amrex::MultiFab* Q1fx1,
217  amrex::MultiFab* Q1fx2,
218  amrex::MultiFab* Q1fx3,
219  amrex::MultiFab* Q2fx3,
220  amrex::MultiFab* Diss,
221  amrex::MultiFab* Tau13,
222  amrex::MultiFab* Tau23,
223  const amrex::Geometry geom,
224  const SolverChoice& solverChoice,
225  const amrex::Vector<std::unique_ptr<SurfaceLayer>>& SurfLayer,
226  const amrex::Gpu::DeviceVector<amrex::BCRec>& domain_bcs_type_d,
227  const amrex::Vector<amrex::BCRec>& domain_bcs_type,
228  std::unique_ptr<amrex::MultiFab>& z_phys_nd,
229  std::unique_ptr<amrex::MultiFab>& z_phys_cc,
230  std::unique_ptr<amrex::MultiFab>& ax,
231  std::unique_ptr<amrex::MultiFab>& ay,
232  std::unique_ptr<amrex::MultiFab>& az,
233  std::unique_ptr<amrex::MultiFab>& dJ_old,
234  amrex::MultiFab* dJ_new,
235  amrex::Gpu::DeviceVector<amrex::Real>& stretched_dz_d,
236  amrex::Vector<std::unique_ptr<amrex::MultiFab>>& mapfac,
237  const eb_& ebfact,
238 #ifdef ERF_USE_EAMXX_SHOC
239  SHOCInterface* eamxx_shoc_lev,
240 #endif
241  ShocDriver* native_shoc_lev,
242  amrex::YAFluxRegister* fr_as_crse,
243  amrex::YAFluxRegister* fr_as_fine,
244  std::unique_ptr<ReadBndryPlanes>& m_r2d,
245  const amrex::MultiFab* cloud_chamber_base_state,
246  const erf_cloud_chamber::Config* cloud_chamber_config,
247  CloudChamberBudget* cloud_budget,
248  erf_auxiliary::AuxiliaryInertTracer* auxiliary_inert_tracer,
249  erf_sbm::SBMStateManager* sbm_state_manager,
250  erf_sbm::SBMTransport* sbm_transport,
251  const amrex::MultiFab* ib_wall_face33 = nullptr,
252  const amrex::MultiFab* ib_wall_ktarget = nullptr);
253 
254 #endif
Declares the embedded-boundary factory manager used by ERF levels.
amrex::Real Real
Definition: ERF_ShocInterface.H:19
bool IsRefluxStage(const SolverChoice &solverChoice, int level, int finest_level, int nrk)
Definition: ERF_TI_slow_headers.H:85
amrex::Real StageFluxWeight(const SolverChoice &solverChoice, int level, int nrk)
Definition: ERF_TI_slow_headers.H:46
void erf_slow_rhs_post(int level, int finest_level, int nrk, double step_old_time, double input_time, double target_time, double dt, int n_qstate, amrex::Vector< amrex::MultiFab > &S_rhs, amrex::Vector< amrex::MultiFab > &S_old, amrex::Vector< amrex::MultiFab > &S_new, amrex::Vector< amrex::MultiFab > &S_data, const amrex::MultiFab &S_prim, amrex::MultiFab &avg_xmom, amrex::MultiFab &avg_ymom, amrex::MultiFab &avg_zmom, const amrex::MultiFab &xvel, const amrex::MultiFab &yvel, const amrex::MultiFab &zvel, const amrex::MultiFab &source, amrex::MultiFab *terrain_blank, amrex::MultiFab *terrain_blank_xface, amrex::MultiFab *terrain_blank_yface, amrex::MultiFab *terrain_blank_zface, const amrex::MultiFab *SmnSmn, const amrex::MultiFab *eddyDiffs, amrex::MultiFab *Hfx1, amrex::MultiFab *Hfx2, amrex::MultiFab *Hfx3, amrex::MultiFab *Q1fx1, amrex::MultiFab *Q1fx2, amrex::MultiFab *Q1fx3, amrex::MultiFab *Q2fx3, amrex::MultiFab *Diss, amrex::MultiFab *Tau13, amrex::MultiFab *Tau23, const amrex::Geometry geom, const SolverChoice &solverChoice, const amrex::Vector< std::unique_ptr< SurfaceLayer >> &SurfLayer, const amrex::Gpu::DeviceVector< amrex::BCRec > &domain_bcs_type_d, const amrex::Vector< amrex::BCRec > &domain_bcs_type, std::unique_ptr< amrex::MultiFab > &z_phys_nd, std::unique_ptr< amrex::MultiFab > &z_phys_cc, std::unique_ptr< amrex::MultiFab > &ax, std::unique_ptr< amrex::MultiFab > &ay, std::unique_ptr< amrex::MultiFab > &az, std::unique_ptr< amrex::MultiFab > &dJ_old, amrex::MultiFab *dJ_new, amrex::Gpu::DeviceVector< amrex::Real > &stretched_dz_d, amrex::Vector< std::unique_ptr< amrex::MultiFab >> &mapfac, const eb_ &ebfact, ShocDriver *native_shoc_lev, amrex::YAFluxRegister *fr_as_crse, amrex::YAFluxRegister *fr_as_fine, std::unique_ptr< ReadBndryPlanes > &m_r2d, const amrex::MultiFab *cloud_chamber_base_state, const erf_cloud_chamber::Config *cloud_chamber_config, CloudChamberBudget *cloud_budget, erf_auxiliary::AuxiliaryInertTracer *auxiliary_inert_tracer, erf_sbm::SBMStateManager *sbm_state_manager, erf_sbm::SBMTransport *sbm_transport, const amrex::MultiFab *ib_wall_face33=nullptr, const amrex::MultiFab *ib_wall_ktarget=nullptr)
void copy_surface_tau_for_implicit(amrex::Vector< std::unique_ptr< amrex::MultiFab >> &Tau_lev, amrex::Vector< std::unique_ptr< amrex::MultiFab >> &Tau_corr_lev)
amrex::Real RefluxStageWeight(const SolverChoice &solverChoice, int level, int finest_level, int nrk)
Definition: ERF_TI_slow_headers.H:72
void erf_make_tau_terms(int level, int nrk, const amrex::Vector< amrex::BCRec > &domain_bcs_type, const amrex::MultiFab &z_phys_nd, amrex::Vector< amrex::MultiFab > &S_data, const amrex::MultiFab &xvel, const amrex::MultiFab &yvel, const amrex::MultiFab &zvel, amrex::Vector< std::unique_ptr< amrex::MultiFab >> &Tau_lev, amrex::Vector< std::unique_ptr< amrex::MultiFab >> &Tau_corr_lev, amrex::MultiFab *SmnSmn, amrex::MultiFab *eddyDiffs, const amrex::Geometry geom, const SolverChoice &solverChoice, const amrex::Vector< std::unique_ptr< SurfaceLayer >> &SurfLayer, amrex::Gpu::DeviceVector< amrex::Real > &stretched_dz_d, const amrex::MultiFab &detJ, amrex::Vector< std::unique_ptr< amrex::MultiFab >> &mapfac, const amrex::MultiFab &ax, const amrex::MultiFab &ay, const amrex::MultiFab &az, const eb_ &ebfact, const amrex::MultiFab *ib_wall_face13=nullptr, const amrex::MultiFab *ib_wall_face23=nullptr)
void erf_slow_rhs_pre(int level, int finest_level, int nrk, double dt, amrex::Vector< amrex::MultiFab > &S_rhs, amrex::Vector< amrex::MultiFab > &S_old, amrex::Vector< amrex::MultiFab > &S_data, const amrex::MultiFab &S_prim, const amrex::MultiFab &qt, amrex::MultiFab &avg_xmom, amrex::MultiFab &avg_ymom, amrex::MultiFab &avg_zmom, const amrex::MultiFab &xvel, const amrex::MultiFab &yvel, const amrex::MultiFab &zvel, std::unique_ptr< amrex::MultiFab > &z_t, const amrex::MultiFab &cc_src, const amrex::MultiFab &xmom_src, const amrex::MultiFab &ymom_src, const amrex::MultiFab &zmom_src, const amrex::MultiFab &buoyancy, const amrex::MultiFab *zmom_crse_rhs, amrex::Vector< std::unique_ptr< amrex::MultiFab >> &Tau_lev, amrex::Vector< std::unique_ptr< amrex::MultiFab >> &Tau_corr_lev, amrex::Vector< amrex::Vector< std::unique_ptr< amrex::MultiFab >>> &Tau_EB, amrex::MultiFab *SmnSmn, amrex::MultiFab *eddyDiffs, amrex::MultiFab *Hfx1, amrex::MultiFab *Hfx2, amrex::MultiFab *Hfx3, amrex::MultiFab *Q1fx1, amrex::MultiFab *Q1fx2, amrex::MultiFab *Q1fx3, amrex::MultiFab *Q2fx3, amrex::MultiFab *Diss, amrex::MultiFab *mf_surface_fluxes, amrex::MultiFab *Hfx3_EB, const amrex::Geometry geom, const SolverChoice &solverChoice, const amrex::Vector< std::unique_ptr< SurfaceLayer >> &SurfLayer, const amrex::Gpu::DeviceVector< amrex::BCRec > &domain_bcs_type_d, const amrex::Vector< amrex::BCRec > &domain_bcs_type, const amrex::MultiFab &z_phys_nd, const amrex::MultiFab &z_phys_cc, const amrex::MultiFab &ax, const amrex::MultiFab &ay, const amrex::MultiFab &az, const amrex::MultiFab &dJ, amrex::Gpu::DeviceVector< amrex::Real > &stretched_dz_d, amrex::Vector< amrex::MultiFab > &gradp, amrex::Vector< std::unique_ptr< amrex::MultiFab >> &mapfac, const eb_ &ebfact, ShocDriver *native_shoc_lev, amrex::YAFluxRegister *fr_as_crse, amrex::YAFluxRegister *fr_as_fine, const amrex::MultiFab *cloud_chamber_base_state, const erf_cloud_chamber::Config *cloud_chamber_config, CloudChamberBudget *cloud_budget, const amrex::MultiFab *ib_wall_face13=nullptr, const amrex::MultiFab *ib_wall_face23=nullptr, const amrex::MultiFab *ib_wall_face33=nullptr, const amrex::MultiFab *ib_wall_hfx=nullptr)
Definition: ERF_CloudChamberBudget.H:31
Definition: ERF_ShocInterface.H:50
Definition: ERF_ShocDriver.H:40
Owns and exposes cell-centered and face-centered EB factories.
Definition: ERF_EB.H:26
Definition: ERF_AuxiliaryInertTracer.H:17
Definition: ERF_SBMStateManager.H:16
Definition: ERF_SBMTransport.H:27
@ qt
Definition: ERF_Kessler.H:30
@ xvel
Definition: ERF_IndexDefines.H:255
@ zvel
Definition: ERF_IndexDefines.H:257
@ yvel
Definition: ERF_IndexDefines.H:256
Definition: ERF_AuxiliaryInertTracer.cpp:15
Definition: ERF.H:113
Definition: ERF_DataStruct.H:715
CouplingType coupling_type
Multilevel coupling strategy.
Definition: ERF_DataStruct.H:2941
amrex::Vector< int > anelastic
Per-level flag selecting anelastic dynamics.
Definition: ERF_DataStruct.H:2629
amrex::Vector< AnelasticType > anelastic_type
Per-level two-stage scheme used by the anelastic integrator.
Definition: ERF_DataStruct.H:2630
Configuration parameters for cloud chamber initialization.
Definition: ERF_CloudChamber.H:41