ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_ImplicitPre.H File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

 if (l_vert_implicit_fac > zero)
 

Function Documentation

◆ if()

if ( l_vert_implicit_fac  ,
zero   
)
7  {
8 
9  const bool l_do_implicit_theta = solverChoice.implicit_thermal_diffusion;
10  const bool l_do_implicit_mom = solverChoice.implicit_momentum_diffusion;
11 
12  // If we're doing an implicit solve for momenta (u and v only),
13  // then we use the explicit solution at this point to derive
14  // the surface velocity gradient -- to be consistent with the
15  // hoextrap used with the surface layer BC. We then subtract
16  // out the contribution from the gradient of tau_corr times
17  // (1 - implicit_fac) and add in the implicit solution scaled
18  // by implicit_fac.
19  MultiFab* Tau13corr = (l_do_implicit_mom) ? Tau_corr[level][0].get() : nullptr;
20  MultiFab* Tau23corr = (l_do_implicit_mom) ? Tau_corr[level][1].get() : nullptr;
21 #ifdef ERF_IMPLICIT_W
22  MultiFab* Tau33corr = (l_do_implicit_mom) ? Tau_corr[level][2].get() : nullptr;
23 #endif
24 
25  // BCs
26  const BCRec* bc_ptr_h = domain_bcs_type.data();
27  GpuArray<Real, AMREX_SPACEDIM*2> l_bc_neumann_vals_d;
28  for (int ori = 0; ori < 2*AMREX_SPACEDIM; ori++) {
29  l_bc_neumann_vals_d[ori] = m_bc_neumann_vals[RhoTheta_comp][ori];
30  }
31  const bool l_use_SurfLayer = (m_SurfaceLayer != nullptr);
32 
33  const bool l_use_turb = solverChoice.turbChoice[level].use_kturb;
34 
35  const bool l_use_stretched_dz = (solverChoice.mesh_type == MeshType::StretchedDz);
36 
37  for ( MFIter mfi(S_old[IntVars::cons],TileNoZ()); mfi.isValid(); ++mfi)
38  {
39  Box bx = mfi.tilebox();
40  Box tbx = mfi.nodaltilebox(0);
41  Box tby = mfi.nodaltilebox(1);
42 
43  const Array4< Real>& cell_data = scratch.array(mfi);
44 
45  const Array4< Real>& rho_u = (l_do_implicit_mom) ? scratch_xmom.array(mfi) : Array4<Real>{};
46  const Array4< Real>& rho_v = (l_do_implicit_mom) ? scratch_ymom.array(mfi) : Array4<Real>{};
47  const Array4<const Real>& tau13_corr = (l_do_implicit_mom) ? Tau13corr->array(mfi) : Array4<Real>{};
48  const Array4<const Real>& tau23_corr = (l_do_implicit_mom) ? Tau23corr->array(mfi) : Array4<Real>{};
49 
50 #ifdef ERF_IMPLICIT_W
51  Box tbz = mfi.nodaltilebox(2);
52  const Array4< Real>& rho_w = (l_do_implicit_mom) ? scratch_zmom.array(mfi) : Array4<Real>{};
53  const Array4<const Real>& tau33_corr = (l_do_implicit_mom) ? Tau33corr->array(mfi) : Array4<Real>{};
54 #endif
55 
56  const Array4<const Real>& z_nd_arr = z_phys_nd[level]->const_array(mfi);
57  const Array4<const Real>& detJ_arr = detJ_cc[level]->const_array(mfi);
58 
59  const Array4<const Real>& mu_turb = l_use_turb ? eddyDiffs->const_array(mfi) : Array4<const Real>{};
60 
61  const Array4<const Real> tau13 = Tau[level][TauType::tau13]->array(mfi);
62  const Array4<const Real> tau23 = Tau[level][TauType::tau23]->array(mfi);
63  [[maybe_unused]] const Array4<const Real> tau33 = Tau[level][TauType::tau33]->array(mfi);
64  const Array4<const Real>& hfx_z = Hfx3->const_array(mfi);
65  const bool l_use_mrf_cg = solverChoice.turbChoice[level].enable_mrf_countergradient
66  && (solverChoice.turbChoice[level].pbl_type == PBLType::MRF);
67  // NOTE: Only ComputeDiffusivityYSUNew fills EddyDiff::HGAMU_v/HGAMV_v;
68  // the legacy PBLType::YSU never writes them. Gating on YSU
69  // therefore both disabled the term where it is produced and read
70  // an unwritten component where it was not.
71  const bool l_use_ysu_mom_cg = solverChoice.turbChoice[level].enable_ysu_countergradient
72  && (solverChoice.turbChoice[level].pbl_type == PBLType::YSUNew);
73  if (l_use_stretched_dz) {
74  if (l_do_implicit_theta) {
75 
76  ImplicitDiffForStateLU_S(bx, fine_geom.Domain(), level, RhoTheta_comp,
77  stage_dt, l_bc_neumann_vals_d, cell_data,
78  stretched_dz_d[level], hfx_z,
79  mu_turb, solverChoice,
80  bc_ptr_h, l_use_SurfLayer, l_vert_implicit_fac,
81  l_use_mrf_cg);
82  }
83  if (l_do_implicit_mom) {
84  ImplicitDiffForMomLU_S<0>(tbx, fine_geom.Domain(), level, stage_dt,
85  cell_data, rho_u, tau13, tau13_corr,
86  stretched_dz_d[level],
87  mu_turb, solverChoice,
88  bc_ptr_h, l_use_SurfLayer, l_vert_implicit_fac,
89  l_use_ysu_mom_cg);
90 
91  ImplicitDiffForMomLU_S<1>(tby, fine_geom.Domain(), level, stage_dt,
92  cell_data, rho_v, tau23, tau23_corr,
93  stretched_dz_d[level],
94  mu_turb, solverChoice,
95  bc_ptr_h, l_use_SurfLayer, l_vert_implicit_fac,
96  l_use_ysu_mom_cg);
97 #ifdef ERF_IMPLICIT_W
98  ImplicitDiffForMomLU_S<2>(tbz, fine_geom.Domain(), level, stage_dt,
99  cell_data, rho_w, tau33, tau33_corr,
100  stretched_dz_d[level],
101  mu_turb, solverChoice,
102  bc_ptr_h, l_use_SurfLayer, l_vert_implicit_fac,
103  l_use_ysu_mom_cg);
104 #endif
105  }
106  } else if (l_use_terrain_fitted_coords) {
107  if (l_do_implicit_theta) {
108  ImplicitDiffForStateLU_T(bx, fine_geom.Domain(), level, RhoTheta_comp,
109  stage_dt, l_bc_neumann_vals_d, cell_data,
110  z_nd_arr, detJ_arr, dxInv, hfx_z,
111  mu_turb, solverChoice,
112  bc_ptr_h, l_use_SurfLayer, l_vert_implicit_fac,
113  l_use_mrf_cg);
114  }
115  if (l_do_implicit_mom) {
116  ImplicitDiffForMomLU_T<0>(tbx, fine_geom.Domain(), level, stage_dt,
117  cell_data, rho_u, tau13, tau13_corr,
118  z_nd_arr, detJ_arr, dxInv,
119  mu_turb, solverChoice,
120  bc_ptr_h, l_use_SurfLayer, l_vert_implicit_fac,
121  l_use_ysu_mom_cg);
122 
123  ImplicitDiffForMomLU_T<1>(tby, fine_geom.Domain(), level, stage_dt,
124  cell_data, rho_v, tau23, tau23_corr,
125  z_nd_arr, detJ_arr, dxInv,
126  mu_turb, solverChoice,
127  bc_ptr_h, l_use_SurfLayer, l_vert_implicit_fac,
128  l_use_ysu_mom_cg);
129 #ifdef ERF_IMPLICIT_W
130  ImplicitDiffForMomLU_T<2>(tbz, fine_geom.Domain(), level, stage_dt,
131  cell_data, rho_w, tau33, tau33_corr,
132  z_nd_arr, detJ_arr, dxInv,
133  mu_turb, solverChoice,
134  bc_ptr_h, l_use_SurfLayer, l_vert_implicit_fac,
135  l_use_ysu_mom_cg);
136 #endif
137  }
138  } else { // no terrain
139  if (l_do_implicit_theta) {
140  ImplicitDiffForStateLU_N(bx, fine_geom.Domain(), level, RhoTheta_comp,
141  stage_dt, l_bc_neumann_vals_d, cell_data,
142  dxInv, hfx_z, mu_turb, solverChoice,
143  bc_ptr_h, l_use_SurfLayer, l_vert_implicit_fac,
144  l_use_mrf_cg);
145  }
146  if (l_do_implicit_mom) {
147  ImplicitDiffForMomLU_N<0>(tbx, fine_geom.Domain(), level, stage_dt,
148  cell_data, rho_u, tau13, tau13_corr,
149  dxInv,
150  mu_turb, solverChoice,
151  bc_ptr_h, l_use_SurfLayer, l_vert_implicit_fac,
152  l_use_ysu_mom_cg);
153 
154  ImplicitDiffForMomLU_N<1>(tby, fine_geom.Domain(), level, stage_dt,
155  cell_data, rho_v, tau23, tau23_corr,
156  dxInv,
157  mu_turb, solverChoice,
158  bc_ptr_h, l_use_SurfLayer, l_vert_implicit_fac,
159  l_use_ysu_mom_cg);
160 #ifdef ERF_IMPLICIT_W
161  ImplicitDiffForMomLU_N<2>(tbz, fine_geom.Domain(), level, stage_dt,
162  cell_data, rho_w, tau33, tau33_corr,
163  dxInv,
164  mu_turb, solverChoice,
165  bc_ptr_h, l_use_SurfLayer, l_vert_implicit_fac,
166  l_use_ysu_mom_cg);
167 #endif
168  }
169  }
170  } // mfi
171 
172  } // if do implicit solve for diffusive contribution to (rho theta) update
@ tau23
Definition: ERF_DataStruct.H:39
@ tau33
Definition: ERF_DataStruct.H:39
@ tau13
Definition: ERF_DataStruct.H:39
void ImplicitDiffForStateLU_N(const amrex::Box &bx, const amrex::Box &domain, const int level, const int n, const double dt, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM *2 > &bc_neumann_vals, const amrex::Array4< amrex::Real > &cell_data, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &hfx_z, const amrex::Array4< const amrex::Real > &mu_turb, const SolverChoice &solverChoice, const amrex::BCRec *bc_ptr, const bool use_SurfLayer, const amrex::Real implicit_fac, const bool use_mrf_countergradient=false)
Apply implicit vertical state diffusion on a uniform grid without terrain.
void ImplicitDiffForStateLU_T(const amrex::Box &bx, const amrex::Box &domain, const int level, const int n, const double dt, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM *2 > &bc_neumann_vals, const amrex::Array4< amrex::Real > &cell_data, const amrex::Array4< const amrex::Real > &z_nd, const amrex::Array4< const amrex::Real > &detJ, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &hfx_z, const amrex::Array4< const amrex::Real > &mu_turb, const SolverChoice &solverChoice, const amrex::BCRec *bc_ptr, const bool use_SurfLayer, const amrex::Real implicit_fac, const bool use_mrf_countergradient=false)
Apply implicit vertical state diffusion on terrain-following coordinates.
void ImplicitDiffForStateLU_S(const amrex::Box &bx, const amrex::Box &domain, const int level, const int n, const double dt, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM *2 > &bc_neumann_vals, const amrex::Array4< amrex::Real > &cell_data, const amrex::Gpu::DeviceVector< amrex::Real > &stretched_dz_d, const amrex::Array4< const amrex::Real > &hfx_z, const amrex::Array4< const amrex::Real > &mu_turb, const SolverChoice &solverChoice, const amrex::BCRec *bc_ptr, const bool use_SurfLayer, const amrex::Real implicit_fac, const bool use_mrf_countergradient=false)
Apply implicit vertical state diffusion on a vertically stretched grid.
const Real l_vert_implicit_fac
Definition: ERF_ImplicitPost.H:6
#define RhoTheta_comp
Definition: ERF_IndexDefines.H:40
amrex::GpuArray< Real, AMREX_SPACEDIM > dxInv
Definition: ERF_InitCustomPertVels_ParticleTests.H:17
pp get("wavelength", wavelength)
AMREX_FORCE_INLINE amrex::IntVect TileNoZ()
Definition: ERF_TileNoZ.H:11
@ cons
Definition: ERF_IndexDefines.H:232
Here is the call graph for this function: