ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_NumericalDiffusion.cpp File Reference
Include dependency graph for ERF_NumericalDiffusion.cpp:

Functions

void NumericalDiffusion_Scal (const Box &bx, const int start_comp, const int num_comp, const Real dt, const Real num_diff_coeff, const Array4< const Real > &prim_data, const Array4< const Real > &cell_data, const Array4< Real > &rhs, const Array4< const Real > &mf_arr)
 
void NumericalDiffusion_Xmom (const Box &bx, const Real dt, const Real num_diff_coeff, const Array4< const Real > &prim_data, const Array4< const Real > &cell_data, const Array4< Real > &rhs, const Array4< const Real > &mf_arr)
 
void NumericalDiffusion_Ymom (const Box &bx, const Real dt, const Real num_diff_coeff, const Array4< const Real > &prim_data, const Array4< const Real > &cell_data, const Array4< Real > &rhs, const Array4< const Real > &mf_arr)
 

Function Documentation

◆ NumericalDiffusion_Scal()

void NumericalDiffusion_Scal ( const Box &  bx,
const int  start_comp,
const int  num_comp,
const Real  dt,
const Real  num_diff_coeff,
const Array4< const Real > &  prim_data,
const Array4< const Real > &  cell_data,
const Array4< Real > &  rhs,
const Array4< const Real > &  mf_arr 
)

Function to compute 6th order numerical diffusion RHS.

Parameters
[in]bxbox to loop over
[in]start_compstaring component index
[in]num_compnumber of total components
[in]num_diff_coeff
[in]prim_dataprimitive variables
[in]cell_datacell center variables
[out]rhsstore the right hand side
[in]mfmap factor
27 {
28  BL_PROFILE_VAR("NumericalDiffusion_Scal()",NumericalDiffusion_Scal);
29 
30  // Capture diffusion coeff
31  Real coeff6 = num_diff_coeff / (2.0 * dt);
32 
33  // Compute 5th order derivative and augment RHS
34  ParallelFor(bx, num_comp, [=] AMREX_GPU_DEVICE (int i, int j, int k, int m) noexcept
35  {
36  int n = start_comp + m; // conserved index
37  int nm1 = (n==0) ? 0 : n - 1; // prim index
38  Real rho_x_lo = (n==0) ? 1.0 : 0.5 * ( cell_data(i-1,j,k,Rho_comp) + cell_data(i ,j,k,Rho_comp) );
39  Real xflux_lo = rho_x_lo * calc_fifth_order_deriv(prim_data(i+2,j,k,nm1), prim_data(i+1,j,k,nm1),
40  prim_data(i ,j,k,nm1), prim_data(i-1,j,k,nm1),
41  prim_data(i-2,j,k,nm1), prim_data(i-3,j,k,nm1));
42  if ( (xflux_lo * (prim_data(i,j,k,nm1) - prim_data(i-1,j,k,nm1)) ) < 0.) xflux_lo = 0.;
43 
44 
45  Real rho_x_hi = (n==0) ? 1.0 : 0.5 * ( cell_data(i+1,j,k,Rho_comp) + cell_data(i ,j,k,Rho_comp) );
46  Real xflux_hi = rho_x_hi * calc_fifth_order_deriv(prim_data(i+3,j,k,nm1), prim_data(i+2,j,k,nm1),
47  prim_data(i+1,j,k,nm1), prim_data(i ,j,k,nm1),
48  prim_data(i-1,j,k,nm1), prim_data(i-2,j,k,nm1));
49  if ( (xflux_hi * (prim_data(i+1,j,k,nm1) - prim_data(i,j,k,nm1)) ) < 0.) xflux_hi = 0.;
50 
51 
52  Real rho_y_lo = (n==0) ? 1.0 : 0.5 * ( cell_data(i,j-1,k,Rho_comp) + cell_data(i,j ,k,Rho_comp) );
53  Real yflux_lo = rho_y_lo * calc_fifth_order_deriv(prim_data(i,j+2,k,nm1), prim_data(i,j+1,k,nm1),
54  prim_data(i,j ,k,nm1), prim_data(i,j-1,k,nm1),
55  prim_data(i,j-2,k,nm1), prim_data(i,j-3,k,nm1));
56  if ( (yflux_lo * (prim_data(i,j,k,nm1) - prim_data(i,j-1,k,nm1)) ) < 0.) yflux_lo = 0.;
57 
58 
59  Real rho_y_hi = (n==0) ? 1.0 : 0.5 * ( cell_data(i,j+1,k,Rho_comp) + cell_data(i,j ,k,Rho_comp) );
60  Real yflux_hi = rho_y_hi * calc_fifth_order_deriv(prim_data(i,j+3,k,nm1), prim_data(i,j+2,k,nm1),
61  prim_data(i,j+1,k,nm1), prim_data(i,j ,k,nm1),
62  prim_data(i,j-1,k,nm1), prim_data(i,j-2,k,nm1));
63  if ( (yflux_hi * (prim_data(i,j+1,k,nm1) - prim_data(i,j,k,nm1)) ) < 0.) yflux_hi = 0.;
64 
65 
66  rhs(i,j,k,n) += coeff6 * mf_arr(i,j,0) * ( (xflux_hi - xflux_lo)
67  + (yflux_hi - yflux_lo) );
68  });
69 }
#define Rho_comp
Definition: ERF_IndexDefines.H:36
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real calc_fifth_order_deriv(const amrex::Real &dnp2, const amrex::Real &dnp1, const amrex::Real &dn, const amrex::Real &dnm1, const amrex::Real &dnm2, const amrex::Real &dnm3)
Definition: ERF_NumericalDiffusion.H:11
void NumericalDiffusion_Scal(const Box &bx, const int start_comp, const int num_comp, const Real dt, const Real num_diff_coeff, const Array4< const Real > &prim_data, const Array4< const Real > &cell_data, const Array4< Real > &rhs, const Array4< const Real > &mf_arr)
Definition: ERF_NumericalDiffusion.cpp:18

Referenced by make_sources().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ NumericalDiffusion_Xmom()

void NumericalDiffusion_Xmom ( const Box &  bx,
const Real  dt,
const Real  num_diff_coeff,
const Array4< const Real > &  prim_data,
const Array4< const Real > &  cell_data,
const Array4< Real > &  rhs,
const Array4< const Real > &  mf_arr 
)

Function to compute 6th order numerical diffusion RHS.

Parameters
[in]bxbox to loop over
[in]start_compstaring component index
[in]num_compnumber of total components
[in]num_diff_coeff
[in]prim_dataprimitive variables
[in]cell_datacell center variables
[out]rhsstore the right hand side
[in]mfmap factor
91 {
92  BL_PROFILE_VAR("NumericalDiffusion_Xmom()",NumericalDiffusion_Xmom);
93 
94  // Capture diffusion coeff
95  Real coeff6 = num_diff_coeff / (2.0 * dt);
96 
97  // Compute 5th order derivative and augment RHS
98  ParallelFor(bx, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
99  {
100  Real rho_x_lo = cell_data(i-1,j,k,Rho_comp);
101  Real xflux_lo = rho_x_lo * calc_fifth_order_deriv(prim_data(i+2,j,k), prim_data(i+1,j,k),
102  prim_data(i ,j,k), prim_data(i-1,j,k),
103  prim_data(i-2,j,k), prim_data(i-3,j,k));
104  if ( (xflux_lo * (prim_data(i,j,k) - prim_data(i-1,j,k)) ) < 0.) xflux_lo = 0.;
105 
106 
107  Real rho_x_hi = cell_data(i ,j,k,Rho_comp);
108  Real xflux_hi = rho_x_hi * calc_fifth_order_deriv(prim_data(i+3,j,k), prim_data(i+2,j,k),
109  prim_data(i+1,j,k), prim_data(i ,j,k),
110  prim_data(i-1,j,k), prim_data(i-2,j,k));
111  if ( (xflux_hi * (prim_data(i+1,j,k) - prim_data(i,j,k)) ) < 0.) xflux_hi = 0.;
112 
113 
114  Real rho_y_lo = 0.25 * ( cell_data(i ,j ,k,Rho_comp) + cell_data(i-1,j ,k,Rho_comp)
115  + cell_data(i ,j-1,k,Rho_comp) + cell_data(i-1,j-1,k,Rho_comp) );
116  Real yflux_lo = rho_y_lo * calc_fifth_order_deriv(prim_data(i,j+2,k), prim_data(i,j+1,k),
117  prim_data(i,j ,k), prim_data(i,j-1,k),
118  prim_data(i,j-2,k), prim_data(i,j-3,k));
119  if ( (yflux_lo * (prim_data(i,j,k) - prim_data(i,j-1,k)) ) < 0.) yflux_lo = 0.;
120 
121 
122  Real rho_y_hi = 0.25 * ( cell_data(i ,j ,k,Rho_comp) + cell_data(i-1,j ,k,Rho_comp)
123  + cell_data(i ,j+1,k,Rho_comp) + cell_data(i-1,j+1,k,Rho_comp) );
124  Real yflux_hi = rho_y_hi * calc_fifth_order_deriv(prim_data(i,j+3,k), prim_data(i,j+2,k),
125  prim_data(i,j+1,k), prim_data(i,j ,k),
126  prim_data(i,j-1,k), prim_data(i,j-2,k));
127  if ( (yflux_hi * (prim_data(i,j+1,k) - prim_data(i,j,k)) ) < 0.) yflux_hi = 0.;
128 
129 
130  rhs(i,j,k) += coeff6 * mf_arr(i,j,0) * ( (xflux_hi - xflux_lo)
131  + (yflux_hi - yflux_lo) );
132  });
133 }
void NumericalDiffusion_Xmom(const Box &bx, const Real dt, const Real num_diff_coeff, const Array4< const Real > &prim_data, const Array4< const Real > &cell_data, const Array4< Real > &rhs, const Array4< const Real > &mf_arr)
Definition: ERF_NumericalDiffusion.cpp:84

Referenced by make_mom_sources().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ NumericalDiffusion_Ymom()

void NumericalDiffusion_Ymom ( const Box &  bx,
const Real  dt,
const Real  num_diff_coeff,
const Array4< const Real > &  prim_data,
const Array4< const Real > &  cell_data,
const Array4< Real > &  rhs,
const Array4< const Real > &  mf_arr 
)

Function to compute 6th order numerical diffusion RHS.

Parameters
[in]bxbox to loop over
[in]start_compstaring component index
[in]num_compnumber of total components
[in]num_diff_coeff
[in]prim_dataprimitive variables
[in]cell_datacell center variables
[out]rhsstore the right hand side
[in]mfmap factor
156 {
157  BL_PROFILE_VAR("NumericalDiffusion_Ymom()",NumericalDiffusion_Ymom);
158 
159  // Capture diffusion coeff
160  Real coeff6 = num_diff_coeff / (2.0 * dt);
161 
162  // Compute 5th order derivative and augment RHS
163  ParallelFor(bx, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
164  {
165  Real rho_x_lo = 0.25 * ( cell_data(i ,j ,k,Rho_comp) + cell_data(i ,j-1,k,Rho_comp)
166  + cell_data(i-1,j ,k,Rho_comp) + cell_data(i-1,j-1,k,Rho_comp) );
167  Real xflux_lo = rho_x_lo * calc_fifth_order_deriv(prim_data(i+2,j,k), prim_data(i+1,j,k),
168  prim_data(i ,j,k), prim_data(i-1,j,k),
169  prim_data(i-2,j,k), prim_data(i-3,j,k));
170  if ( (xflux_lo * (prim_data(i,j,k) - prim_data(i-1,j,k)) ) < 0.) xflux_lo = 0.;
171 
172 
173  Real rho_x_hi = 0.25 * ( cell_data(i ,j ,k,Rho_comp) + cell_data(i ,j-1,k,Rho_comp)
174  + cell_data(i+1,j ,k,Rho_comp) + cell_data(i+1,j-1,k,Rho_comp) );
175  Real xflux_hi = rho_x_hi * calc_fifth_order_deriv(prim_data(i+3,j,k), prim_data(i+2,j,k),
176  prim_data(i+1,j,k), prim_data(i ,j,k),
177  prim_data(i-1,j,k), prim_data(i-2,j,k));
178  if ( (xflux_hi * (prim_data(i+1,j,k) - prim_data(i,j,k)) ) < 0.) xflux_hi = 0.;
179 
180 
181  Real rho_y_lo = cell_data(i,j-1,k,Rho_comp);
182  Real yflux_lo = rho_y_lo * calc_fifth_order_deriv(prim_data(i,j+2,k), prim_data(i,j+1,k),
183  prim_data(i,j ,k), prim_data(i,j-1,k),
184  prim_data(i,j-2,k), prim_data(i,j-3,k));
185  if ( (yflux_lo * (prim_data(i,j,k) - prim_data(i,j-1,k)) ) < 0.) yflux_lo = 0.;
186 
187 
188  Real rho_y_hi = cell_data(i,j ,k,Rho_comp);
189  Real yflux_hi = rho_y_hi * calc_fifth_order_deriv(prim_data(i,j+3,k), prim_data(i,j+2,k),
190  prim_data(i,j+1,k), prim_data(i,j ,k),
191  prim_data(i,j-1,k), prim_data(i,j-2,k));
192  if ( (yflux_hi * (prim_data(i,j ,k) - prim_data(i,j,k)) ) < 0.) yflux_hi = 0.;
193 
194 
195  rhs(i,j,k) += coeff6 * mf_arr(i,j,0) * ( (xflux_hi - xflux_lo)
196  + (yflux_hi - yflux_lo) );
197  });
198 }
void NumericalDiffusion_Ymom(const Box &bx, const Real dt, const Real num_diff_coeff, const Array4< const Real > &prim_data, const Array4< const Real > &cell_data, const Array4< Real > &rhs, const Array4< const Real > &mf_arr)
Definition: ERF_NumericalDiffusion.cpp:149

Referenced by make_mom_sources().

Here is the call graph for this function:
Here is the caller graph for this function: