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

Functions

void NumericalDiffusion (const Box &bx, const int start_comp, const int num_comp, const Real dt, const Real num_diff_coeff, const Array4< const Real > &data, const Array4< Real > &rhs, const Array4< const Real > &mf_x, const Array4< const Real > &mf_y, const bool avg_mf_x_y, const bool avg_mf_y_x)
 
void NumericalDiffusionVert (const Box &bx, const int start_comp, const int num_comp, const Real dt, const Real num_diff_coeff, const Array4< const Real > &data, const Array4< Real > &rhs)
 

Function Documentation

◆ NumericalDiffusion()

void NumericalDiffusion ( const Box &  bx,
const int  start_comp,
const int  num_comp,
const Real  dt,
const Real  num_diff_coeff,
const Array4< const Real > &  data,
const Array4< Real > &  rhs,
const Array4< const Real > &  mf_x,
const Array4< const Real > &  mf_y,
const bool  avg_mf_x_y,
const bool  avg_mf_y_x 
)

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]datavariables used to compute RHS
[out]rhsstore the right hand side
[in]mf_xmap factor at x-face
[in]mf_ymap factor at y-face
[in]avg_mf_x_yflag to average map factor x in y-dir
[in]avg_mf_y_xflag to average map factor y in x-dir
31 {
32  BL_PROFILE_VAR("NumericalDiffusion()",NumericalDiffusion);
33 
34  // Average map factors to correct locations
35  Box planebx(bx); planebx.setSmall(2,0); planebx.setBig(2,0);
36  FArrayBox mf_x_bar; mf_x_bar.resize(planebx,1,The_Async_Arena());
37  FArrayBox mf_y_bar; mf_y_bar.resize(planebx,1,The_Async_Arena());
38  const Array4<Real>& mfx_arr = mf_x_bar.array();
39  const Array4<Real>& mfy_arr = mf_y_bar.array();
40  ParallelFor(planebx, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
41  {
42  if (avg_mf_x_y) {
43  mfx_arr(i,j,k) = 0.5 * ( mf_x(i,j-1,k) + mf_x(i,j,k) );
44  } else {
45  mfx_arr(i,j,k) = mf_x(i,j,k);
46  }
47  if (avg_mf_y_x) {
48  mfy_arr(i,j,k) = 0.5 * ( mf_y(i-1,j,k) + mf_y(i,j,k) );
49  } else {
50  mfy_arr(i,j,k) = mf_y(i,j,k);
51  }
52  });
53 
54  // Capture diffusion coeff
55  Real coeff6 = num_diff_coeff / (2.0 * dt);
56 
57  // Compute 5th order derivative and augment RHS
58  ParallelFor(bx, num_comp, [=] AMREX_GPU_DEVICE (int i, int j, int k, int m) noexcept
59  {
60  int n = start_comp + m;
61  Real xflux_lo = 10. * (data(i ,j,k,n) - data(i-1,j,k,n))
62  - 5. * (data(i+1,j,k,n) - data(i-2,j,k,n))
63  + (data(i+2,j,k,n) - data(i-3,j,k,n));
64  if ( (xflux_lo * (data(i,j,k,n) - data(i-1,j,k,n)) ) < 0.) xflux_lo = 0.;
65  Real xflux_hi = 10. * (data(i+1,j,k,n) - data(i ,j,k,n))
66  - 5. * (data(i+2,j,k,n) - data(i-1,j,k,n))
67  + (data(i+3,j,k,n) - data(i-2,j,k,n));
68  if ( (xflux_hi * (data(i+1,j,k,n) - data(i,j,k,n)) ) < 0.) xflux_hi = 0.;
69  Real yflux_lo = 10. * (data(i,j ,k,n) - data(i,j-1,k,n))
70  - 5. * (data(i,j+1,k,n) - data(i,j-2,k,n))
71  + (data(i,j+2,k,n) - data(i,j-3,k,n));
72  if ( (yflux_lo * (data(i,j,k,n) - data(i,j-1,k,n)) ) < 0.) yflux_lo = 0.;
73  Real yflux_hi = 10. * (data(i,j+1,k,n) - data(i,j ,k,n))
74  - 5. * (data(i,j+2,k,n) - data(i,j-1,k,n))
75  + (data(i,j+3,k,n) - data(i,j-2,k,n));
76  if ( (yflux_hi * (data(i,j+1,k,n) - data(i,j,k,n)) ) < 0.) yflux_hi = 0.;
77  rhs(i,j,k,n) += coeff6 * ( (xflux_hi - xflux_lo) * mfx_arr(i,j,0)
78  + (yflux_hi - yflux_lo) * mfy_arr(i,j,0) );
79  });
80 }
void NumericalDiffusion(const Box &bx, const int start_comp, const int num_comp, const Real dt, const Real num_diff_coeff, const Array4< const Real > &data, const Array4< Real > &rhs, const Array4< const Real > &mf_x, const Array4< const Real > &mf_y, const bool avg_mf_x_y, const bool avg_mf_y_x)
Definition: ERF_NumericalDiffusion.cpp:20

Referenced by make_mom_sources(), and make_sources().

Here is the caller graph for this function:

◆ NumericalDiffusionVert()

void NumericalDiffusionVert ( const Box &  bx,
const int  start_comp,
const int  num_comp,
const Real  dt,
const Real  num_diff_coeff,
const Array4< const Real > &  data,
const Array4< Real > &  rhs 
)

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]datavariables used to compute RHS
[out]rhsstore the right hand side
100 {
101  BL_PROFILE_VAR("NumericalDiffusionVert()",NumericalDiffusionVert);
102 
103  // Capture diffusion coeff
104  Real coeff6 = num_diff_coeff / (2.0 * dt);
105 
106  // Compute 5th order derivative and augment RHS
107  ParallelFor(bx, num_comp, [=] AMREX_GPU_DEVICE (int i, int j, int k, int m) noexcept
108  {
109  int n = start_comp + m;
110  Real zflux_lo = 10. * (data(i,j,k ,n) - data(i,j,k-1,n))
111  - 5. * (data(i,j,k+1,n) - data(i,j,k-2,n))
112  + (data(i,j,k+2,n) - data(i,j,k-3,n));
113  if ( (zflux_lo * (data(i,j,k,n) - data(i,j,k-1,n)) ) < 0.) zflux_lo = 0.;
114  Real zflux_hi = 10. * (data(i,j,k+1,n) - data(i,j,k ,n))
115  - 5. * (data(i,j,k+2,n) - data(i,j,k-1,n))
116  + (data(i,j,k+3,n) - data(i,j,k-2,n));
117  if ( (zflux_hi * (data(i,j,k+1,n) - data(i,j,k,n)) ) < 0.) zflux_hi = 0.;
118  rhs(i,j,k,n) += coeff6 * ( (zflux_hi - zflux_lo) );
119  });
120 }
void NumericalDiffusionVert(const Box &bx, const int start_comp, const int num_comp, const Real dt, const Real num_diff_coeff, const Array4< const Real > &data, const Array4< Real > &rhs)
Definition: ERF_NumericalDiffusion.cpp:93