1 #ifndef ERF_CLOUD_CHAMBER_WALL_STRESS_H_
2 #define ERF_CLOUD_CHAMBER_WALL_STRESS_H_
4 #include <AMReX_Array4.H>
6 #include <AMReX_GpuContainers.H>
15 using amrex::GpuArray;
21 for (
const auto& wall : walls) {
33 template <
int DIR,
bool HIGH>
38 amrex::ignore_unused(DIR);
39 return HIGH ? -traction : traction;
42 template <
int DIR,
bool HIGH>
45 GpuArray<Real, AMREX_SPACEDIM>
48 const Array4<const Real>& state,
49 const Array4<const Real>& base_state,
50 const Array4<const Real>& u,
51 const Array4<const Real>& v,
52 const Array4<const Real>&
w,
54 const GpuArray<Real, AMREX_SPACEDIM>& dx_inv,
56 const bool cloudy) noexcept
62 const bool most_momentum =
66 rho, u_t, U_t,
Real(0.5) / dx_inv[DIR],
71 DIR == 2 ? (HIGH ? -1 : 1) : 0};
79 template <
int DIR,
int TANGENT,
bool HIGH>
85 const Array4<const Real>& state,
86 const Array4<const Real>& base_state,
87 const Array4<const Real>& u,
88 const Array4<const Real>& v,
89 const Array4<const Real>&
w,
91 const GpuArray<Real, AMREX_SPACEDIM>& dx_inv,
93 const bool cloudy) noexcept
95 int cell_lo[AMREX_SPACEDIM] = {i, j, k};
96 int cell_hi[AMREX_SPACEDIM] = {i, j, k};
97 const int node = cell_lo[TANGENT];
98 cell_lo[TANGENT] = amrex::max(domain.smallEnd(TANGENT), node - 1);
99 cell_hi[TANGENT] = amrex::min(domain.bigEnd(TANGENT), node);
100 cell_lo[DIR] = HIGH ? domain.bigEnd(DIR) : domain.smallEnd(DIR);
101 cell_hi[DIR] = cell_lo[DIR];
103 const auto traction_lo = wall_traction_at_cell<DIR,HIGH>(
104 cell_lo[0], cell_lo[1], cell_lo[2], state, base_state, u, v,
w, wall,
105 dx_inv,
rdOcp, cloudy);
106 const auto traction_hi = wall_traction_at_cell<DIR,HIGH>(
107 cell_hi[0], cell_hi[1], cell_hi[2], state, base_state, u, v,
w, wall,
108 dx_inv,
rdOcp, cloudy);
109 return Real(0.5) * (traction_lo[TANGENT] + traction_hi[TANGENT]);
112 template <
int DIR,
int TANGENT,
bool HIGH>
117 const Array4<const Real>& state,
118 const Array4<const Real>& base_state,
119 const Array4<const Real>& u,
120 const Array4<const Real>& v,
121 const Array4<const Real>&
w,
122 const Array4<Real>& tau,
124 const GpuArray<Real, AMREX_SPACEDIM>& dx_inv,
128 Box target = amrex::surroundingNodes(amrex::surroundingNodes(bx, DIR), TANGENT);
129 const int face = HIGH ? domain.bigEnd(DIR) + 1 : domain.smallEnd(DIR);
130 target.setSmall(DIR, face);
131 target.setBig(DIR, face);
132 target.setSmall(TANGENT,
133 amrex::max(target.smallEnd(TANGENT), domain.smallEnd(TANGENT)));
134 target.setBig(TANGENT,
135 amrex::min(target.bigEnd(TANGENT), domain.bigEnd(TANGENT) + 1));
136 if (target.isEmpty()) {
return; }
139 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept
141 const Real traction = averaged_physical_traction_component<DIR,TANGENT,HIGH>(
142 i, j, k, domain, state, base_state, u, v,
w, wall, dx_inv,
144 tau(i,j,k) = stored_tau_from_physical_traction<DIR,HIGH>(traction);
148 template <
int DIR,
bool HIGH>
153 const Array4<const Real>& state,
154 const Array4<const Real>& base_state,
155 const Array4<const Real>& u,
156 const Array4<const Real>& v,
157 const Array4<const Real>&
w,
158 const Array4<Real>&
tau12,
159 const Array4<Real>&
tau13,
160 const Array4<Real>&
tau23,
161 const GpuArray<Real, AMREX_SPACEDIM>& dx_inv,
166 if constexpr (HIGH) {
167 if (bx.bigEnd(DIR) != domain.bigEnd(DIR)) {
return; }
169 if (bx.smallEnd(DIR) != domain.smallEnd(DIR)) {
return; }
172 const auto wall = walls[2*DIR + (HIGH ? 1 : 0)];
177 if constexpr (DIR == 0) {
178 apply_tangent_stress<DIR,1,HIGH>(bx, domain, state, base_state, u, v,
w,
180 apply_tangent_stress<DIR,2,HIGH>(bx, domain, state, base_state, u, v,
w,
182 }
else if constexpr (DIR == 1) {
183 apply_tangent_stress<DIR,0,HIGH>(bx, domain, state, base_state, u, v,
w,
185 apply_tangent_stress<DIR,2,HIGH>(bx, domain, state, base_state, u, v,
w,
188 apply_tangent_stress<DIR,0,HIGH>(bx, domain, state, base_state, u, v,
w,
190 apply_tangent_stress<DIR,1,HIGH>(bx, domain, state, base_state, u, v,
w,
198 const Array4<const Real>& state,
199 const Array4<const Real>& base_state,
200 const Array4<const Real>& u,
201 const Array4<const Real>& v,
202 const Array4<const Real>&
w,
203 const Array4<Real>&
tau12,
204 const Array4<Real>&
tau13,
205 const Array4<Real>&
tau23,
206 const GpuArray<Real, AMREX_SPACEDIM>& dx_inv,
216 "Cloud Chamber MOST momentum stress requires valid thermodynamic and base-state arrays");
217 apply_face<0,false>(bx, domain, state, base_state, u, v,
w,
tau12,
tau13,
tau23, dx_inv, walls,
rdOcp, cloudy);
218 apply_face<0,true >(bx, domain, state, base_state, u, v,
w,
tau12,
tau13,
tau23, dx_inv, walls,
rdOcp, cloudy);
219 apply_face<1,false>(bx, domain, state, base_state, u, v,
w,
tau12,
tau13,
tau23, dx_inv, walls,
rdOcp, cloudy);
220 apply_face<1,true >(bx, domain, state, base_state, u, v,
w,
tau12,
tau13,
tau23, dx_inv, walls,
rdOcp, cloudy);
221 apply_face<2,false>(bx, domain, state, base_state, u, v,
w,
tau12,
tau13,
tau23, dx_inv, walls,
rdOcp, cloudy);
222 apply_face<2,true >(bx, domain, state, base_state, u, v,
w,
tau12,
tau13,
tau23, dx_inv, walls,
rdOcp, cloudy);
228 const Array4<const Real>& state,
229 const Array4<const Real>& u,
230 const Array4<const Real>& v,
231 const Array4<const Real>&
w,
232 const Array4<Real>&
tau12,
233 const Array4<Real>&
tau13,
234 const Array4<Real>&
tau23,
235 const GpuArray<Real, AMREX_SPACEDIM>& dx_inv,
240 "Cloud Chamber MOST momentum requires the base-state-aware wall-stress overload");
241 apply(bx, domain, state, Array4<const Real>{}, u, v,
w,
248 for (
const auto& wall : walls) {
@ tau12
Definition: ERF_DataStruct.H:40
@ tau23
Definition: ERF_DataStruct.H:40
@ tau13
Definition: ERF_DataStruct.H:40
#define Rho_comp
Definition: ERF_IndexDefines.H:39
#define RhoTheta_comp
Definition: ERF_IndexDefines.H:40
#define RhoQ1_comp
Definition: ERF_IndexDefines.H:45
const Real rdOcp
Definition: ERF_InitCustomPert_ABL.H:72
AMREX_ALWAYS_ASSERT_WITH_MESSAGE(m_cloud_chamber_config.active, "Cloud Chamber: initializer reached without a parsed configuration")
ParallelFor(fab_box, [=] AMREX_GPU_DEVICE(int i, int j, int k) { qrcuten_arr(i, j, k)=Real(0);qscuten_arr(i, j, k)=Real(0);qicuten_arr(i, j, k)=Real(0);})
Real w
Definition: ERF_Plotfile2DInterpolator.cpp:22
amrex::Real Real
Definition: ERF_ShocInterface.H:19
@ p0_comp
Definition: ERF_IndexDefines.H:77
@ rho
Definition: ERF_Kessler.H:25
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real tangential_magnitude(const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &u_t) noexcept
Definition: ERF_CloudChamberWallFlux.H:651
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE WallFlux evaluate_momentum_traction(const erf_wall_thermodynamics::FaceWall &wall, const MomentumWallSample &sample) noexcept
Definition: ERF_CloudChamberWallFlux.H:730
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > relative_tangential_velocity_cell_centered(int dir, int i, int j, int k, const amrex::Array4< const amrex::Real > &u, const amrex::Array4< const amrex::Real > &v, const amrex::Array4< const amrex::Real > &w, const erf_wall_thermodynamics::FaceWall &wall) noexcept
Definition: ERF_CloudChamberWallFlux.H:630
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool requires_tangential_momentum(const erf_wall_thermodynamics::FaceWall &wall) noexcept
Definition: ERF_CloudChamberWallFlux.H:465
Definition: ERF_CloudChamberWallStress.H:11
AMREX_FORCE_INLINE void apply_face(const Box &bx, const Box &domain, const Array4< const Real > &state, const Array4< const Real > &base_state, const Array4< const Real > &u, const Array4< const Real > &v, const Array4< const Real > &w, const Array4< Real > &tau12, const Array4< Real > &tau13, const Array4< Real > &tau23, const GpuArray< Real, AMREX_SPACEDIM > &dx_inv, const erf_wall_thermodynamics::Boundary &walls, const Real rdOcp, const bool cloudy)
Definition: ERF_CloudChamberWallStress.H:150
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real stored_tau_from_physical_traction(Real traction) noexcept
Definition: ERF_CloudChamberWallStress.H:36
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE GpuArray< Real, AMREX_SPACEDIM > wall_traction_at_cell(int i, int j, int k, const Array4< const Real > &state, const Array4< const Real > &base_state, const Array4< const Real > &u, const Array4< const Real > &v, const Array4< const Real > &w, const erf_wall_thermodynamics::FaceWall &wall, const GpuArray< Real, AMREX_SPACEDIM > &dx_inv, const Real rdOcp, const bool cloudy) noexcept
Definition: ERF_CloudChamberWallStress.H:46
bool wall_stress_requires_most_state(const erf_wall_thermodynamics::Boundary &walls) noexcept
Definition: ERF_CloudChamberWallStress.H:18
void apply(const Box &bx, const Box &domain, const Array4< const Real > &state, const Array4< const Real > &base_state, const Array4< const Real > &u, const Array4< const Real > &v, const Array4< const Real > &w, const Array4< Real > &tau12, const Array4< Real > &tau13, const Array4< Real > &tau23, const GpuArray< Real, AMREX_SPACEDIM > &dx_inv, const erf_wall_thermodynamics::Boundary &walls, const Real rdOcp, const bool cloudy)
Definition: ERF_CloudChamberWallStress.H:195
bool has_momentum_wall(const erf_wall_thermodynamics::Boundary &walls) noexcept
Definition: ERF_CloudChamberWallStress.H:245
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real averaged_physical_traction_component(int i, int j, int k, const Box &domain, const Array4< const Real > &state, const Array4< const Real > &base_state, const Array4< const Real > &u, const Array4< const Real > &v, const Array4< const Real > &w, const erf_wall_thermodynamics::FaceWall &wall, const GpuArray< Real, AMREX_SPACEDIM > &dx_inv, const Real rdOcp, const bool cloudy) noexcept
Definition: ERF_CloudChamberWallStress.H:82
AMREX_FORCE_INLINE void apply_tangent_stress(const Box &bx, const Box &domain, const Array4< const Real > &state, const Array4< const Real > &base_state, const Array4< const Real > &u, const Array4< const Real > &v, const Array4< const Real > &w, const Array4< Real > &tau, const erf_wall_thermodynamics::FaceWall &wall, const GpuArray< Real, AMREX_SPACEDIM > &dx_inv, const Real rdOcp, const bool cloudy)
Definition: ERF_CloudChamberWallStress.H:114
amrex::GpuArray< FaceWall, 2 *AMREX_SPACEDIM > Boundary
Definition: ERF_WallThermodynamics.H:70
Definition: ERF_CloudChamberWallFlux.H:82
Definition: ERF_WallThermodynamics.H:61