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[Orientation(Direction::z, Orientation::low)] != 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  // erf.implicit_terrain_metric (terrain-fitted meshes): the map factors the
60  // terrain-metric coefficient needs at the cells and at the u and v faces
61  const bool l_implicit_metric = solverChoice.implicit_terrain_metric &&
62  l_use_terrain_fitted_coords;
63  const Array4<const Real> mf_mx = mapfac[level][MapFacType::m_x]->const_array(mfi);
64  const Array4<const Real> mf_my = mapfac[level][MapFacType::m_y]->const_array(mfi);
65  const Array4<const Real> mf_ux = mapfac[level][MapFacType::u_x]->const_array(mfi);
66  const Array4<const Real> mf_uy = mapfac[level][MapFacType::u_y]->const_array(mfi);
67  const Array4<const Real> mf_vx = mapfac[level][MapFacType::v_x]->const_array(mfi);
68  const Array4<const Real> mf_vy = mapfac[level][MapFacType::v_y]->const_array(mfi);
69 
70  const Array4<const Real>& mu_turb = l_use_turb ? eddyDiffs->const_array(mfi) : Array4<const Real>{};
71 
72  // Vertical extent of the grid column over each (i,j), with a one-cell halo
73  // so a box can also see the column on the other side of each of its faces
74  const Array4<const int>& col_kext = column_kextent[level]->const_array(mfi);
75 
76  const Array4<const Real> tau13 = Tau[level][TauType::tau13]->array(mfi);
77  const Array4<const Real> tau23 = Tau[level][TauType::tau23]->array(mfi);
78  [[maybe_unused]] const Array4<const Real> tau33 = Tau[level][TauType::tau33]->array(mfi);
79  const Array4<const Real>& hfx_z = Hfx3->const_array(mfi);
80  const bool l_use_mrf_cg = solverChoice.turbChoice[level].enable_mrf_countergradient
81  && (solverChoice.turbChoice[level].pbl_type == PBLType::MRF);
82  // NOTE: Only ComputeDiffusivityYSUNew fills EddyDiff::HGAMU_v/HGAMV_v;
83  // the legacy PBLType::YSU never writes them. Gating on YSU
84  // therefore both disabled the term where it is produced and read
85  // an unwritten component where it was not.
86  const bool l_use_ysu_mom_cg = solverChoice.turbChoice[level].enable_ysu_countergradient
87  && (solverChoice.turbChoice[level].pbl_type == PBLType::YSUNew);
88  if (l_use_stretched_dz) {
89  if (l_do_implicit_theta) {
90 
91  ImplicitDiffForStateLU_S(bx, fine_geom.Domain(), level, RhoTheta_comp,
92  stage_dt, l_bc_neumann_vals_d, cell_data,
93  stretched_dz_d[level], hfx_z,
94  mu_turb, solverChoice,
95  bc_ptr_h, l_use_SurfLayer, l_vert_implicit_fac,
96  l_use_mrf_cg);
97  }
98  if (l_do_implicit_mom) {
99  ImplicitDiffForMomLU_S<0>(tbx, fine_geom.Domain(), level, stage_dt,
100  col_kext,
101  cell_data, rho_u, tau13, tau13_corr,
102  stretched_dz_d[level],
103  mu_turb, solverChoice,
104  bc_ptr_h, l_use_SurfLayer, l_vert_implicit_fac,
105  l_use_ysu_mom_cg);
106 
107  ImplicitDiffForMomLU_S<1>(tby, fine_geom.Domain(), level, stage_dt,
108  col_kext,
109  cell_data, rho_v, tau23, tau23_corr,
110  stretched_dz_d[level],
111  mu_turb, solverChoice,
112  bc_ptr_h, l_use_SurfLayer, l_vert_implicit_fac,
113  l_use_ysu_mom_cg);
114 #ifdef ERF_IMPLICIT_W
115  ImplicitDiffForMomLU_S<2>(tbz, fine_geom.Domain(), level, stage_dt,
116  col_kext,
117  cell_data, rho_w, tau33, tau33_corr,
118  stretched_dz_d[level],
119  mu_turb, solverChoice,
120  bc_ptr_h, l_use_SurfLayer, l_vert_implicit_fac,
121  l_use_ysu_mom_cg);
122 #endif
123  }
124  } else if (l_use_terrain_fitted_coords) {
125  if (l_do_implicit_theta) {
126  ImplicitDiffForStateLU_T(bx, fine_geom.Domain(), level, RhoTheta_comp,
127  stage_dt, l_bc_neumann_vals_d, cell_data,
128  z_nd_arr, detJ_arr, dxInv, hfx_z,
129  mu_turb, solverChoice,
130  bc_ptr_h, l_use_SurfLayer, l_vert_implicit_fac,
131  l_use_mrf_cg,
132  mf_mx, mf_my, l_implicit_metric);
133  }
134  if (l_do_implicit_mom) {
135  ImplicitDiffForMomLU_T<0>(tbx, fine_geom.Domain(), level, stage_dt,
136  col_kext,
137  cell_data, rho_u, tau13, tau13_corr,
138  z_nd_arr, detJ_arr, dxInv,
139  mu_turb, solverChoice,
140  bc_ptr_h, l_use_SurfLayer, l_vert_implicit_fac,
141  l_use_ysu_mom_cg,
142  mf_ux, mf_uy, l_implicit_metric);
143 
144  ImplicitDiffForMomLU_T<1>(tby, fine_geom.Domain(), level, stage_dt,
145  col_kext,
146  cell_data, rho_v, tau23, tau23_corr,
147  z_nd_arr, detJ_arr, dxInv,
148  mu_turb, solverChoice,
149  bc_ptr_h, l_use_SurfLayer, l_vert_implicit_fac,
150  l_use_ysu_mom_cg,
151  mf_vx, mf_vy, l_implicit_metric);
152 #ifdef ERF_IMPLICIT_W
153  ImplicitDiffForMomLU_T<2>(tbz, fine_geom.Domain(), level, stage_dt,
154  col_kext,
155  cell_data, rho_w, tau33, tau33_corr,
156  z_nd_arr, detJ_arr, dxInv,
157  mu_turb, solverChoice,
158  bc_ptr_h, l_use_SurfLayer, l_vert_implicit_fac,
159  l_use_ysu_mom_cg,
160  mf_mx, mf_my, l_implicit_metric);
161 #endif
162  }
163  } else { // no terrain
164  if (l_do_implicit_theta) {
165  ImplicitDiffForStateLU_N(bx, fine_geom.Domain(), level, RhoTheta_comp,
166  stage_dt, l_bc_neumann_vals_d, cell_data,
167  dxInv, hfx_z, mu_turb, solverChoice,
168  bc_ptr_h, l_use_SurfLayer, l_vert_implicit_fac,
169  l_use_mrf_cg);
170  }
171  if (l_do_implicit_mom) {
172  ImplicitDiffForMomLU_N<0>(tbx, fine_geom.Domain(), level, stage_dt,
173  col_kext,
174  cell_data, rho_u, tau13, tau13_corr,
175  dxInv,
176  mu_turb, solverChoice,
177  bc_ptr_h, l_use_SurfLayer, l_vert_implicit_fac,
178  l_use_ysu_mom_cg);
179 
180  ImplicitDiffForMomLU_N<1>(tby, fine_geom.Domain(), level, stage_dt,
181  col_kext,
182  cell_data, rho_v, tau23, tau23_corr,
183  dxInv,
184  mu_turb, solverChoice,
185  bc_ptr_h, l_use_SurfLayer, l_vert_implicit_fac,
186  l_use_ysu_mom_cg);
187 #ifdef ERF_IMPLICIT_W
188  ImplicitDiffForMomLU_N<2>(tbz, fine_geom.Domain(), level, stage_dt,
189  col_kext,
190  cell_data, rho_w, tau33, tau33_corr,
191  dxInv,
192  mu_turb, solverChoice,
193  bc_ptr_h, l_use_SurfLayer, l_vert_implicit_fac,
194  l_use_ysu_mom_cg);
195 #endif
196  }
197  }
198  } // mfi
199 
200  } // if do implicit solve for diffusive contribution to (rho theta) update
@ tau23
Definition: ERF_DataStruct.H:48
@ tau33
Definition: ERF_DataStruct.H:48
@ tau13
Definition: ERF_DataStruct.H:48
@ v_x
Definition: ERF_DataStruct.H:37
@ u_y
Definition: ERF_DataStruct.H:38
@ v_y
Definition: ERF_DataStruct.H:38
@ m_y
Definition: ERF_DataStruct.H:38
@ u_x
Definition: ERF_DataStruct.H:37
@ m_x
Definition: ERF_DataStruct.H:37
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, const amrex::Array4< const amrex::Real > &mf_mx={}, const amrex::Array4< const amrex::Real > &mf_my={}, const bool implicit_metric=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:43
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:235
Here is the call graph for this function: