ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_ComputeStress_S.cpp File Reference
#include <ERF_Diffusion.H>
#include <ERF_TerrainMetrics.H>
Include dependency graph for ERF_ComputeStress_S.cpp:

Functions

void ComputeStressConsVisc_S (Box bxcc, Box tbxxy, Box tbxxz, Box tbxyz, Real mu_eff, const Array4< const Real > &cell_data, Array4< Real > &tau11, Array4< Real > &tau22, Array4< Real > &tau33, Array4< Real > &tau12, Array4< Real > &tau21, Array4< Real > &tau13, Array4< Real > &tau31, Array4< Real > &tau23, Array4< Real > &tau32, const Array4< const Real > &er_arr, const Array4< const Real > &mf_mx, const Array4< const Real > &mf_ux, const Array4< const Real > &mf_vx, const Array4< const Real > &mf_my, const Array4< const Real > &mf_uy, const Array4< const Real > &mf_vy)
 
void ComputeStressVarVisc_S (Box bxcc, Box tbxxy, Box tbxxz, Box tbxyz, Real mu_eff, const Array4< const Real > &mu_turb, const Array4< const Real > &cell_data, Array4< Real > &tau11, Array4< Real > &tau22, Array4< Real > &tau33, Array4< Real > &tau12, Array4< Real > &tau21, Array4< Real > &tau13, Array4< Real > &tau31, Array4< Real > &tau23, Array4< Real > &tau32, const Array4< const Real > &er_arr, const Array4< const Real > &mf_mx, const Array4< const Real > &mf_ux, const Array4< const Real > &mf_vx, const Array4< const Real > &mf_my, const Array4< const Real > &mf_uy, const Array4< const Real > &mf_vy)
 

Function Documentation

◆ ComputeStressConsVisc_S()

void ComputeStressConsVisc_S ( Box  bxcc,
Box  tbxxy,
Box  tbxxz,
Box  tbxyz,
Real  mu_eff,
const Array4< const Real > &  cell_data,
Array4< Real > &  tau11,
Array4< Real > &  tau22,
Array4< Real > &  tau33,
Array4< Real > &  tau12,
Array4< Real > &  tau21,
Array4< Real > &  tau13,
Array4< Real > &  tau31,
Array4< Real > &  tau23,
Array4< Real > &  tau32,
const Array4< const Real > &  er_arr,
const Array4< const Real > &  mf_mx,
const Array4< const Real > &  mf_ux,
const Array4< const Real > &  mf_vx,
const Array4< const Real > &  mf_my,
const Array4< const Real > &  mf_uy,
const Array4< const Real > &  mf_vy 
)

Function for computing the stress with constant viscosity and with terrain.

Parameters
[in]bxcccell center box for tau_ii
[in]tbxxynodal xy box for tau_12
[in]tbxxznodal xz box for tau_13
[in]tbxyznodal yz box for tau_23
[in]mu_effconstant molecular viscosity
[in]cell_datato access rho if ConstantAlpha
[in,out]tau1111 strain -> stress
[in,out]tau2222 strain -> stress
[in,out]tau3333 strain -> stress
[in,out]tau1212 strain -> stress
[in,out]tau1313 strain -> stress
[in,out]tau2121 strain -> stress
[in,out]tau2323 strain -> stress
[in,out]tau3131 strain -> stress
[in,out]tau3232 strain -> stress
[in]er_arrexpansion rate
[in]z_ndnodal array of physical z heights
41 {
42  // Handle constant alpha case, in which the provided mu_eff is actually
43  // "alpha" and the viscosity needs to be scaled by rho. This can be further
44  // optimized with if statements below instead of creating a new FAB,
45  // but this is implementation is cleaner.
46  FArrayBox temp;
47  Box gbx = bxcc; // Note: bxcc have been grown in x/y only.
48  gbx.grow(IntVect(0,0,1));
49  temp.resize(gbx,1, The_Async_Arena());
50  Array4<Real> rhoAlpha = temp.array();
51  if (cell_data) {
52  ParallelFor(gbx,
53  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
54  rhoAlpha(i,j,k) = cell_data(i, j, k, Rho_comp) * mu_eff;
55  });
56  } else {
57  ParallelFor(gbx,
58  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
59  rhoAlpha(i,j,k) = mu_eff;
60  });
61  }
62 
63  // First block: cell centered stresses
64  //***********************************************************************************
65  Real OneThird = (1./3.);
66  ParallelFor(bxcc, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
67  {
68  Real mfx = mf_mx(i,j,0);
69  Real mfy = mf_my(i,j,0);
70 
71  Real mu_tot = rhoAlpha(i,j,k);
72 
73  tau11(i,j,k) = -mu_tot / mfy * ( tau11(i,j,k) - OneThird*er_arr(i,j,k) );
74  tau22(i,j,k) = -mu_tot / mfx * ( tau22(i,j,k) - OneThird*er_arr(i,j,k) );
75  tau33(i,j,k) = -mu_tot * ( tau33(i,j,k) - OneThird*er_arr(i,j,k) );
76  });
77 
78  // Second block: off diagonal stresses
79  //***********************************************************************************
80  ParallelFor(tbxxy,tbxxz,tbxyz,
81  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
82  {
83  Real mfx = 0.5 * (mf_ux(i,j,0) + mf_ux(i,j-1,0));
84  Real mfy = 0.5 * (mf_vy(i,j,0) + mf_vy(i-1,j,0));
85 
86  Real mu_tot = 0.25*( rhoAlpha(i-1, j , k) + rhoAlpha(i, j , k)
87  + rhoAlpha(i-1, j-1, k) + rhoAlpha(i, j-1, k) );
88 
89  tau12(i,j,k) *= -mu_tot / mfx;
90  tau21(i,j,k) *= -mu_tot / mfy;
91  },
92  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
93  {
94  Real mfy = mf_uy(i,j,0);
95 
96  Real mu_tot = 0.25 * ( rhoAlpha(i-1, j , k ) + rhoAlpha(i , j , k )
97  + rhoAlpha(i-1, j , k-1) + rhoAlpha(i , j , k-1) );
98 
99  tau13(i,j,k) *= -mu_tot;
100  tau31(i,j,k) *= -mu_tot / mfy;
101  },
102  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
103  {
104  Real mfx = mf_vx(i,j,0);
105 
106  Real mu_tot = 0.25 * ( rhoAlpha(i , j-1, k ) + rhoAlpha(i , j , k )
107  + rhoAlpha(i , j-1, k-1) + rhoAlpha(i , j , k-1) );
108 
109  tau23(i,j,k) *= -mu_tot;
110  tau32(i,j,k) *= -mu_tot / mfx;
111  });
112 }
@ tau12
Definition: ERF_DataStruct.H:30
@ tau23
Definition: ERF_DataStruct.H:30
@ tau33
Definition: ERF_DataStruct.H:30
@ tau22
Definition: ERF_DataStruct.H:30
@ tau11
Definition: ERF_DataStruct.H:30
@ tau32
Definition: ERF_DataStruct.H:30
@ tau31
Definition: ERF_DataStruct.H:30
@ tau21
Definition: ERF_DataStruct.H:30
@ tau13
Definition: ERF_DataStruct.H:30
#define Rho_comp
Definition: ERF_IndexDefines.H:36
amrex::Real Real
Definition: ERF_ShocInterface.H:19

Referenced by erf_make_tau_terms().

Here is the caller graph for this function:

◆ ComputeStressVarVisc_S()

void ComputeStressVarVisc_S ( Box  bxcc,
Box  tbxxy,
Box  tbxxz,
Box  tbxyz,
Real  mu_eff,
const Array4< const Real > &  mu_turb,
const Array4< const Real > &  cell_data,
Array4< Real > &  tau11,
Array4< Real > &  tau22,
Array4< Real > &  tau33,
Array4< Real > &  tau12,
Array4< Real > &  tau21,
Array4< Real > &  tau13,
Array4< Real > &  tau31,
Array4< Real > &  tau23,
Array4< Real > &  tau32,
const Array4< const Real > &  er_arr,
const Array4< const Real > &  mf_mx,
const Array4< const Real > &  mf_ux,
const Array4< const Real > &  mf_vx,
const Array4< const Real > &  mf_my,
const Array4< const Real > &  mf_uy,
const Array4< const Real > &  mf_vy 
)

Function for computing the stress with constant viscosity and with terrain.

Parameters
[in]bxcccell center box for tau_ii
[in]tbxxynodal xy box for tau_12
[in]tbxxznodal xz box for tau_13
[in]tbxyznodal yz box for tau_23
[in]mu_effconstant molecular viscosity
[in]mu_turbvariable turbulent viscosity
[in]cell_datato access rho if ConstantAlpha
[in,out]tau1111 strain -> stress
[in,out]tau2222 strain -> stress
[in,out]tau3333 strain -> stress
[in,out]tau1212 strain -> stress
[in,out]tau1313 strain -> stress
[in,out]tau2121 strain -> stress
[in,out]tau2323 strain -> stress
[in,out]tau3131 strain -> stress
[in,out]tau3232 strain -> stress
[in]er_arrexpansion rate
[in]z_ndnodal array of physical z heights
151 {
152  // Handle constant alpha case, in which the provided mu_eff is actually
153  // "alpha" and the viscosity needs to be scaled by rho. This can be further
154  // optimized with if statements below instead of creating a new FAB,
155  // but this is implementation is cleaner.
156  FArrayBox temp;
157  Box gbx = bxcc; // Note: bxcc have been grown in x/y only.
158  gbx.grow(IntVect(0,0,1));
159  temp.resize(gbx,1, The_Async_Arena());
160  Array4<Real> rhoAlpha = temp.array();
161  if (cell_data) {
162  ParallelFor(gbx,
163  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
164  rhoAlpha(i,j,k) = cell_data(i, j, k, Rho_comp) * mu_eff;
165  });
166  } else {
167  ParallelFor(gbx,
168  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
169  rhoAlpha(i,j,k) = mu_eff;
170  });
171  }
172 
173  // First block: cell centered stresses
174  //***********************************************************************************
175  Real OneThird = (1./3.);
176  ParallelFor(bxcc, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
177  {
178  Real mfx = mf_mx(i,j,0);
179  Real mfy = mf_my(i,j,0);
180 
181  Real mu_tot = rhoAlpha(i,j,k) + 2.0*mu_turb(i, j, k, EddyDiff::Mom_h);
182 
183  tau11(i,j,k) = -mu_tot / mfy * ( tau11(i,j,k) - OneThird*er_arr(i,j,k) );
184  tau22(i,j,k) = -mu_tot / mfx * ( tau22(i,j,k) - OneThird*er_arr(i,j,k) );
185  tau33(i,j,k) = -mu_tot * ( tau33(i,j,k) - OneThird*er_arr(i,j,k) );
186  });
187 
188  // Second block: off diagonal stresses
189  //***********************************************************************************
190  ParallelFor(tbxxy,tbxxz,tbxyz,
191  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
192  {
193  Real mfx = 0.5 * (mf_ux(i,j,0) + mf_ux(i,j-1,0));
194  Real mfy = 0.5 * (mf_vy(i,j,0) + mf_vy(i-1,j,0));
195 
196  Real mu_bar = 0.25*( mu_turb(i-1, j , k, EddyDiff::Mom_h) + mu_turb(i, j , k, EddyDiff::Mom_h)
197  + mu_turb(i-1, j-1, k, EddyDiff::Mom_h) + mu_turb(i, j-1, k, EddyDiff::Mom_h) );
198  Real rhoAlpha_bar = 0.25*( rhoAlpha(i-1, j , k) + rhoAlpha(i, j , k)
199  + rhoAlpha(i-1, j-1, k) + rhoAlpha(i, j-1, k) );
200  Real mu_tot = rhoAlpha_bar + 2.0*mu_bar;
201 
202  tau12(i,j,k) *= -mu_tot / mfx;
203  tau21(i,j,k) *= -mu_tot / mfy;
204  },
205  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
206  {
207  Real mfy = mf_uy(i,j,0);
208 
209  Real mu_bar = 0.25*( mu_turb(i-1, j, k , EddyDiff::Mom_v) + mu_turb(i, j, k , EddyDiff::Mom_v)
210  + mu_turb(i-1, j, k-1, EddyDiff::Mom_v) + mu_turb(i, j, k-1, EddyDiff::Mom_v) );
211  Real rhoAlpha_bar = 0.25*( rhoAlpha(i-1, j, k ) + rhoAlpha(i, j, k )
212  + rhoAlpha(i-1, j, k-1) + rhoAlpha(i, j, k-1) );
213  Real mu_tot = rhoAlpha_bar + 2.0*mu_bar;
214 
215  tau13(i,j,k) *= -mu_tot;
216  tau31(i,j,k) *= -mu_tot / mfy;
217  },
218  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
219  {
220  Real mfx = mf_vx(i,j,0);
221 
222  Real mu_bar = 0.25*( mu_turb(i, j-1, k , EddyDiff::Mom_v) + mu_turb(i, j, k , EddyDiff::Mom_v)
223  + mu_turb(i, j-1, k-1, EddyDiff::Mom_v) + mu_turb(i, j, k-1, EddyDiff::Mom_v) );
224  Real rhoAlpha_bar = 0.25*( rhoAlpha(i, j-1, k ) + rhoAlpha(i, j, k )
225  + rhoAlpha(i, j-1, k-1) + rhoAlpha(i, j, k-1) );
226  Real mu_tot = rhoAlpha_bar + 2.0*mu_bar;
227 
228  tau23(i,j,k) *= -mu_tot;
229  tau32(i,j,k) *= -mu_tot / mfx;
230  });
231 }
@ Mom_h
Definition: ERF_IndexDefines.H:170
@ Mom_v
Definition: ERF_IndexDefines.H:175

Referenced by erf_make_tau_terms().

Here is the caller graph for this function: