Convert velocity to momentum by multiplying by density averaged onto faces.
41 const BCRec* bc_ptr_h = domain_bcs_type_h.data();
45 #pragma omp parallel if (amrex::Gpu::notInLaunchRegion())
47 for ( MFIter mfi(density,TilingIfNotGPU()); mfi.isValid(); ++mfi)
50 const Box& bx = mfi.tilebox();
53 tbx = mfi.tilebox(IntVect(1,0,0),xvel_ngrow);
54 tby = mfi.tilebox(IntVect(0,1,0),yvel_ngrow);
55 tbz = mfi.tilebox(IntVect(0,0,1),zvel_ngrow);
58 if (tbz.smallEnd(2) < domain.smallEnd(2)) tbz.setSmall(2,domain.smallEnd(2));
59 if (tbz.bigEnd(2) > domain.bigEnd(2)+1) tbz.setBig(2,domain.bigEnd(2)+1);
62 const Array4<const Real>& dens_arr = density.array(mfi);
65 Array4<Real>
const& momx =
xmom.array(mfi);
66 Array4<Real>
const& momy =
ymom.array(mfi);
67 Array4<Real>
const& momz =
zmom.array(mfi);
70 const Array4<Real const>& velx = xvel_in.const_array(mfi);
71 const Array4<Real const>& vely = yvel_in.const_array(mfi);
72 const Array4<Real const>& velz = zvel_in.const_array(mfi);
76 ParallelFor(tbx, tby, tbz,
77 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) {
78 momx(i,j,k) = velx(i,j,k) * 0.5 * (dens_arr(i,j,k,
Rho_comp) + dens_arr(i-1,j,k,
Rho_comp));
80 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) {
81 momy(i,j,k) = vely(i,j,k) * 0.5 * (dens_arr(i,j,k,
Rho_comp) + dens_arr(i,j-1,k,
Rho_comp));
83 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) {
84 momz(i,j,k) = velz(i,j,k) * 0.5 * (dens_arr(i,j,k,
Rho_comp) + dens_arr(i,j,k-1,
Rho_comp));
89 if ( (bx.smallEnd(0) == domain.smallEnd(0)) &&
91 ParallelFor(makeSlab(tbx,0,domain.smallEnd(0)), [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) {
92 momx(i,j,k) = velx(i,j,k) * dens_arr(i-1,j,k,
Rho_comp);
95 if ( (bx.bigEnd(0) == domain.bigEnd(0)) &&
97 ParallelFor(makeSlab(tbx,0,domain.bigEnd(0)+1), [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) {
98 momx(i,j,k) = velx(i,j,k) * dens_arr(i,j,k,
Rho_comp);
101 if ( (bx.smallEnd(1) == domain.smallEnd(1)) &&
103 ParallelFor(makeSlab(tby,1,domain.smallEnd(1)), [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) {
104 momy(i,j,k) = vely(i,j,k) * dens_arr(i,j-1,k,
Rho_comp);
107 if ( (bx.bigEnd(1) == domain.bigEnd(1)) &&
109 ParallelFor(makeSlab(tby,1,domain.bigEnd(1)+1), [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) {
110 momy(i,j,k) = vely(i,j,k) * dens_arr(i,j,k,
Rho_comp);
#define Rho_comp
Definition: ERF_IndexDefines.H:36
void VelocityToMomentum(const MultiFab &xvel_in, const IntVect &xvel_ngrow, const MultiFab &yvel_in, const IntVect &yvel_ngrow, const MultiFab &zvel_in, const IntVect &zvel_ngrow, const MultiFab &density, MultiFab &xmom, MultiFab &ymom, MultiFab &zmom, const Box &domain, const Vector< BCRec > &domain_bcs_type_h)
Definition: ERF_VelocityToMomentum.cpp:28
@ cons_bc
Definition: ERF_IndexDefines.H:76
@ ext_dir
Definition: ERF_IndexDefines.H:180
@ ymom
Definition: ERF_IndexDefines.H:141
@ zmom
Definition: ERF_IndexDefines.H:142
@ xmom
Definition: ERF_IndexDefines.H:140