ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_InitCustomPert_ScalarAdvDiff.H File Reference

Go to the source code of this file.

Functions

ParmParse pp ("prob")
 
pp query ("rho_0", rho_0)
 
pp query ("A_0", A_0)
 
pp query ("B_0", B_0)
 
pp query ("rad_0", rad_0)
 
pp query ("xc_frac", xc_frac)
 
pp query ("yc_frac", yc_frac)
 
pp query ("zc_frac", zc_frac)
 
pp query ("prob_type", prob_type)
 
 ParallelFor (bx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept { const Real *prob_lo=geomdata.ProbLo();const Real *prob_hi=geomdata.ProbHi();const Real *dx=geomdata.CellSize();const Real x=prob_lo[0]+(i+0.5) *dx[0];const Real y=prob_lo[1]+(j+0.5) *dx[1];const Real z=prob_lo[2]+(k+0.5) *dx[2];const Real xc=xc_frac *(prob_lo[0]+prob_hi[0]);const Real yc=yc_frac *(prob_lo[1]+prob_hi[1]);const Real zc=zc_frac *(prob_lo[2]+prob_hi[2]);const Real r0=rad_0 *(prob_hi[0] - prob_lo[0]);const Real r3d=std::sqrt((x-xc) *(x-xc)+(y-yc) *(y-yc)+(z-zc) *(z-zc));const Real r2d_xy=std::sqrt((x-xc) *(x-xc)+(y-yc) *(y-yc));const Real r2d_xz=std::sqrt((x-xc) *(x-xc)+(z-zc) *(z-zc));if(prob_type==10) { state_pert(i, j, k, RhoScalar_comp)=A_0 *exp(-10.*r3d *r3d)+B_0 *sin(x);} else if(prob_type==11) { state_pert(i, j, k, RhoScalar_comp)=A_0 *0.25 *(1.0+std::cos(PI *std::min(r2d_xy, r0)/r0));} else if(prob_type==12) { state_pert(i, j, k, RhoScalar_comp)=A_0 *0.25 *(1.0+std::cos(PI *std::min(r2d_xz, r0)/r0));} else if(prob_type==13) { const Real r0_z=rad_0 *(prob_hi[2] - prob_lo[2]);const Real r2d_xz_ell=std::sqrt((x-xc) *(x-xc)/(r0 *r0)+(z-zc) *(z-zc)/(r0_z *r0_z));state_pert(i, j, k, RhoScalar_comp)=A_0 *0.25 *(1.0+std::cos(PI *std::min(r2d_xz_ell, r0_z)/r0_z));} else if(prob_type==14) { state_pert(i, j, k, RhoScalar_comp)=std::cos(PI *x);} else { if(r3d< r0) { state_pert(i, j, k, RhoScalar_comp)=A_0;} else { state_pert(i, j, k, RhoScalar_comp)=0.0;} } state_pert(i, j, k, RhoScalar_comp) *=rho_0;})
 

Variables

Real rho_0 = 1.0
 
Real A_0 = 1.0
 
Real B_0 = 0.0
 
Real rad_0 = 0.0
 
Real xc_frac = 0.5
 
Real yc_frac = 0.5
 
Real zc_frac = 0.5
 
int prob_type = -1
 

Function Documentation

◆ ParallelFor()

ParallelFor ( bx  ,
[=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept { const Real *prob_lo=geomdata.ProbLo();const Real *prob_hi=geomdata.ProbHi();const Real *dx=geomdata.CellSize();const Real x=prob_lo[0]+(i+0.5) *dx[0];const Real y=prob_lo[1]+(j+0.5) *dx[1];const Real z=prob_lo[2]+(k+0.5) *dx[2];const Real xc=xc_frac *(prob_lo[0]+prob_hi[0]);const Real yc=yc_frac *(prob_lo[1]+prob_hi[1]);const Real zc=zc_frac *(prob_lo[2]+prob_hi[2]);const Real r0=rad_0 *(prob_hi[0] - prob_lo[0]);const Real r3d=std::sqrt((x-xc) *(x-xc)+(y-yc) *(y-yc)+(z-zc) *(z-zc));const Real r2d_xy=std::sqrt((x-xc) *(x-xc)+(y-yc) *(y-yc));const Real r2d_xz=std::sqrt((x-xc) *(x-xc)+(z-zc) *(z-zc));if(prob_type==10) { state_pert(i, j, k, RhoScalar_comp)=A_0 *exp(-10.*r3d *r3d)+B_0 *sin(x);} else if(prob_type==11) { state_pert(i, j, k, RhoScalar_comp)=A_0 *0.25 *(1.0+std::cos(PI *std::min(r2d_xy, r0)/r0));} else if(prob_type==12) { state_pert(i, j, k, RhoScalar_comp)=A_0 *0.25 *(1.0+std::cos(PI *std::min(r2d_xz, r0)/r0));} else if(prob_type==13) { const Real r0_z=rad_0 *(prob_hi[2] - prob_lo[2]);const Real r2d_xz_ell=std::sqrt((x-xc) *(x-xc)/(r0 *r0)+(z-zc) *(z-zc)/(r0_z *r0_z));state_pert(i, j, k, RhoScalar_comp)=A_0 *0.25 *(1.0+std::cos(PI *std::min(r2d_xz_ell, r0_z)/r0_z));} else if(prob_type==14) { state_pert(i, j, k, RhoScalar_comp)=std::cos(PI *x);} else { if(r3d< r0) { state_pert(i, j, k, RhoScalar_comp)=A_0;} else { state_pert(i, j, k, RhoScalar_comp)=0.0;} } state_pert(i, j, k, RhoScalar_comp) *=rho_0;}   
)

◆ pp()

ParmParse pp ( "prob"  )

◆ query() [1/8]

pp query ( "A_0"  ,
A_0   
)

◆ query() [2/8]

pp query ( "B_0"  ,
B_0   
)

◆ query() [3/8]

pp query ( "prob_type"  ,
prob_type   
)

◆ query() [4/8]

pp query ( "rad_0"  ,
rad_0   
)

◆ query() [5/8]

pp query ( "rho_0"  ,
rho_0   
)

◆ query() [6/8]

pp query ( "xc_frac"  ,
xc_frac   
)

◆ query() [7/8]

pp query ( "yc_frac"  ,
yc_frac   
)

◆ query() [8/8]

pp query ( "zc_frac"  ,
zc_frac   
)

Variable Documentation

◆ A_0

Real A_0 = 1.0

Referenced by ParallelFor().

◆ B_0

Real B_0 = 0.0

Referenced by ParallelFor().

◆ prob_type

int prob_type = -1

Referenced by ParallelFor().

◆ rad_0

Real rad_0 = 0.0

Referenced by ParallelFor().

◆ rho_0

Real rho_0 = 1.0

Referenced by ParallelFor().

◆ xc_frac

Real xc_frac = 0.5

Referenced by ParallelFor().

◆ yc_frac

Real yc_frac = 0.5

Referenced by ParallelFor().

◆ zc_frac

Real zc_frac = 0.5

Referenced by ParallelFor().