Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

patches from orlanski bcs #277

Merged
merged 1 commit into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 61 additions & 61 deletions Exec/Channel_Test/prob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@ init_custom_bathymetry (int /*lev*/, const Geometry& geom,

for ( MFIter mfi(mf_h, TilingIfNotGPU()); mfi.isValid(); ++mfi )
{
Array4<Real> const& h = (mf_h).array(mfi);
Array4<Real> const& h = (mf_h).array(mfi);

Box bx = mfi.tilebox();
Box bx = mfi.tilebox();

Box bxD = bx;
bxD.makeSlab(2,0);
Box bxD = bx;
bxD.makeSlab(2,0);

Gpu::streamSynchronize();
Gpu::streamSynchronize();

ParallelForRNG(bxD, [=] AMREX_GPU_DEVICE (int i, int j, int , auto engine)
ParallelForRNG(bxD, [=] AMREX_GPU_DEVICE (int i, int j, int , auto engine)
{
h(i,j,0) = 50.0_rt;
});
Expand Down Expand Up @@ -100,7 +100,7 @@ init_custom_prob(

auto T0 = m_solverChoice.T0;
auto S0 = m_solverChoice.S0;
ParallelFor(bx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept
ParallelFor(grow(grow(bx,0,1),1,1), [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept
{
const auto prob_lo = geomdata.ProbLo();
const auto prob_hi = geomdata.ProbHi();
Expand All @@ -124,42 +124,42 @@ init_custom_prob(
state(i, j, k, Scalar_comp) = 0.0_rt;
});

const Box& xbx = surroundingNodes(bx,0);
const Box& ybx = surroundingNodes(bx,1);
const Box& zbx = surroundingNodes(bx,2);

ParallelFor(xbx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept
{
// Create bounding box for x and y to make spatially-dependent T and S
const auto prob_lo = geomdata.ProbLo();
const auto prob_hi = geomdata.ProbHi();
const auto dx = geomdata.CellSize();

const Real xcent = 0.5*(prob_lo[0] + prob_hi[0]);
const Real ycent = 0.5*(prob_lo[1] + prob_hi[1]);

const Real z = z_r(i,j,k);
// h(i,j,0) = -geomdata.ProbLo(2);
const Real depth = 50.0_rt;

const Real x = prob_lo[0] + (i + 0.5) * dx[0];// - xcent;
const Real y = prob_lo[1] + (j + 0.5) * dx[1];// - ycent;

const Real val1 = x * 6.28318530718_rt * 1.0e-5_rt;
const Real val2 = y * 6.28318530718_rt * 1.0e-5_rt;
x_vel(i, j, k) = (depth + z) * 0.01_rt + 0.05_rt * std::sin(val1) * std::sin(val2);
});
ParallelFor(ybx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept
{
y_vel(i, j, k) = 0.0_rt;
});

ParallelFor(zbx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept
{
z_vel(i, j, k) = 0.0_rt;
});

Gpu::streamSynchronize();
const Box& xbx = surroundingNodes(bx,0);
const Box& ybx = surroundingNodes(bx,1);
const Box& zbx = surroundingNodes(bx,2);

ParallelFor(grow(grow(xbx,1,1),0,1), [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept
{
// Create bounding box for x and y to make spatially-dependent T and S
const auto prob_lo = geomdata.ProbLo();
const auto prob_hi = geomdata.ProbHi();
const auto dx = geomdata.CellSize();

const Real xcent = 0.5*(prob_lo[0] + prob_hi[0]);
const Real ycent = 0.5*(prob_lo[1] + prob_hi[1]);

const Real z = z_r(i,j,k);
// h(i,j,0) = -geomdata.ProbLo(2);
const Real depth = 50.0_rt;

const Real x = prob_lo[0] + (i + 0.5) * dx[0];// - xcent;
const Real y = prob_lo[1] + (j + 0.5) * dx[1];// - ycent;

const Real val1 = x * 6.28318530718_rt * 1.0e-5_rt;
const Real val2 = y * 6.28318530718_rt * 1.0e-5_rt;
x_vel(i, j, k) = (depth + z) * 0.01_rt + 0.05_rt * std::sin(val1) * std::sin(val2);
});
ParallelFor(ybx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept
{
y_vel(i, j, k) = 0.0_rt;
});

ParallelFor(zbx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept
{
z_vel(i, j, k) = 0.0_rt;
});

Gpu::streamSynchronize();
}

void
Expand All @@ -168,21 +168,21 @@ init_custom_vmix(const Geometry& /*geom*/, MultiFab& mf_Akv, MultiFab& mf_Akt,
{
for ( MFIter mfi((mf_Akv), TilingIfNotGPU()); mfi.isValid(); ++mfi )
{
Array4<Real> const& Akv = (mf_Akv).array(mfi);
Array4<Real> const& Akt = (mf_Akt).array(mfi);
Array4<Real> const& z_w = (mf_z_w).array(mfi);
Box bx = mfi.tilebox();
bx.grow(IntVect(NGROW,NGROW,0));
Gpu::streamSynchronize();
amrex::ParallelFor(bx,
[=] AMREX_GPU_DEVICE (int i, int j, int k)
{
Akv(i,j,k) = 2.0e-03_rt+8.0e-03_rt*std::exp(z_w(i,j,k)/150.0_rt);
Array4<Real> const& Akv = (mf_Akv).array(mfi);
Array4<Real> const& Akt = (mf_Akt).array(mfi);
Array4<Real> const& z_w = (mf_z_w).array(mfi);
Box bx = mfi.tilebox();
bx.grow(IntVect(NGROW,NGROW,0));
Gpu::streamSynchronize();
amrex::ParallelFor(bx,
[=] AMREX_GPU_DEVICE (int i, int j, int k)
{
Akv(i,j,k) = 2.0e-03_rt+8.0e-03_rt*std::exp(z_w(i,j,k)/150.0_rt);

Akt(i,j,k,Temp_comp) = 1.0e-6_rt;
Akt(i,j,k,Salt_comp) = 1.0e-6_rt;
Akt(i,j,k,Scalar_comp) = 0.0_rt;
});
Akt(i,j,k,Temp_comp) = 1.0e-6_rt;
Akt(i,j,k,Salt_comp) = 1.0e-6_rt;
Akt(i,j,k,Scalar_comp) = 0.0_rt;
});
}
}

Expand All @@ -203,11 +203,11 @@ init_custom_hmix(const Geometry& /*geom*/, MultiFab& mf_visc2_p, MultiFab& mf_vi

amrex::ParallelFor(bx, [=] AMREX_GPU_DEVICE (int i, int j, int k)
{
visc2_p(i,j,k) = 2.0_rt;
visc2_r(i,j,k) = 2.0_rt;
visc2_p(i,j,k) = 2.0_rt;
visc2_r(i,j,k) = 2.0_rt;

for (int n = 0; n < ncomp; n++) {
diff2(i,j,k,n) = 0.0_rt;
for (int n = 0; n < ncomp; n++) {
diff2(i,j,k,n) = 0.0_rt;
}
});
}
Expand Down
8 changes: 4 additions & 4 deletions Source/BoundaryConditions/BoundaryConditions_cons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ void REMORAPhysBCFunct::impose_cons_bcs (const Array4<Real>& dest_arr, const Box
if (!is_periodic_in_x)
{
Box bx_xlo(bx); bx_xlo.setBig (0,dom_lo.x-1);
bx_xlo.setSmall(1,valid_bx.smallEnd(1)); bx_xlo.setBig(1,valid_bx.bigEnd(1));
bx_xlo.setSmall(1,valid_bx.smallEnd(1)-1); bx_xlo.setBig(1,valid_bx.bigEnd(1)+1);
Box bx_xhi(bx); bx_xhi.setSmall(0,dom_hi.x+1);
bx_xhi.setSmall(1,valid_bx.smallEnd(1)); bx_xhi.setBig(1,valid_bx.bigEnd(1));
bx_xhi.setSmall(1,valid_bx.smallEnd(1)-1); bx_xhi.setBig(1,valid_bx.bigEnd(1)+1);
ParallelFor(
bx_xlo, ncomp, [=] AMREX_GPU_DEVICE (int i, int j, int k, int n) {
if (bc_ptr[n].lo(0) == REMORABCType::ext_dir) {
Expand Down Expand Up @@ -109,9 +109,9 @@ void REMORAPhysBCFunct::impose_cons_bcs (const Array4<Real>& dest_arr, const Box
if (!is_periodic_in_y)
{
Box bx_ylo(bx); bx_ylo.setBig (1,dom_lo.y-1);
bx_ylo.setSmall(0,valid_bx.smallEnd(0)); bx_ylo.setBig(0,valid_bx.bigEnd(0));
bx_ylo.setSmall(0,valid_bx.smallEnd(0)-1); bx_ylo.setBig(0,valid_bx.bigEnd(0)+1);
Box bx_yhi(bx); bx_yhi.setSmall(1,dom_hi.y+1);
bx_yhi.setSmall(0,valid_bx.smallEnd(0)); bx_yhi.setBig(0,valid_bx.bigEnd(0));
bx_yhi.setSmall(0,valid_bx.smallEnd(0)-1); bx_yhi.setBig(0,valid_bx.bigEnd(0)+1);
ParallelFor(
bx_ylo, ncomp, [=] AMREX_GPU_DEVICE (int i, int j, int k, int n) {
if (bc_ptr[n].lo(1) == REMORABCType::ext_dir) {
Expand Down
2 changes: 1 addition & 1 deletion Source/BoundaryConditions/BoundaryConditions_yvel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void REMORAPhysBCFunct::impose_yvel_bcs (const Array4<Real>& dest_arr, const Box
dest_arr(i,j,k) = l_bc_extdir_vals_d[n][3]*mskv(i,j,0);
} else if (bc_ptr[n].hi(0) == REMORABCType::foextrap || bc_ptr[n].hi(0) == REMORABCType::clamped) {
dest_arr(i,j,k) = dest_arr(dom_hi.x,j,k)*mskv(i,j,0);
} else if (bc_ptr[n].lo(0) == REMORABCType::orlanski_rad) {
} else if (bc_ptr[n].hi(0) == REMORABCType::orlanski_rad) {
Real grad_hi = calc_arr(dom_hi.x ,j+1,k) - calc_arr(dom_hi.x ,j ,k);
Real grad_hi_ip1 = calc_arr(dom_hi.x+1,j+1,k) - calc_arr(dom_hi.x+1,j ,k);
Real grad_hi_jm1 = calc_arr(dom_hi.x ,j ,k) - calc_arr(dom_hi.x ,j-1,k);
Expand Down
28 changes: 14 additions & 14 deletions Source/TimeIntegration/REMORA_rhs_t_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,21 @@ REMORA::rhs_t_3d (const Box& bx, const Box& gbx,
bool is_periodic_in_y = geomdata.isPeriodic(1);

//copy the tilebox
Box tbxp1 = bx;
Box tbxp1x = bx;
Box tbxp1y = bx;
Box tbxp2 = bx;

//make only gbx be grown to match multifabs
tbxp2.grow(IntVect(NGROW,NGROW,0));
tbxp1.grow(IntVect(NGROW-1,NGROW-1,0));
tbxp1x.grow(IntVect(NGROW-1,0,0));
tbxp1y.grow(IntVect(0,NGROW-1,0));

// Because grad, curv, FX, FE, are all local, do surroundinNodes
Box utbxp1 = surroundingNodes(tbxp1, 0);
Box vtbxp1 = surroundingNodes(tbxp1, 1);
Box utbxp1 = surroundingNodes(tbxp1x, 0);
Box vtbxp1 = surroundingNodes(tbxp1y, 1);
Box ubx = surroundingNodes(bx, 0);
Box vbx = surroundingNodes(bx, 1);

BoxArray ba_gbx1 = intersect(BoxArray(tbxp1),gbx);
AMREX_ASSERT((ba_gbx1.size() == 1));

//
// Scratch space
Expand Down Expand Up @@ -111,7 +111,7 @@ REMORA::rhs_t_3d (const Box& bx, const Box& gbx,

if (solverChoice.tracer_Hadv_scheme == AdvectionScheme::upstream3) {

ParallelFor(tbxp1, [=] AMREX_GPU_DEVICE (int i, int j, int k)
ParallelFor(tbxp1x, [=] AMREX_GPU_DEVICE (int i, int j, int k)
{
//Upstream3
curv(i,j,k)=-FX(i,j,k)+FX(i+1,j,k);
Expand All @@ -127,7 +127,7 @@ REMORA::rhs_t_3d (const Box& bx, const Box& gbx,

} else if (solverChoice.tracer_Hadv_scheme == AdvectionScheme::centered4) {

ParallelFor(tbxp1, [=] AMREX_GPU_DEVICE (int i, int j, int k)
ParallelFor(tbxp1x, [=] AMREX_GPU_DEVICE (int i, int j, int k)
{
//Centered4
grad(i,j,k)=0.5_rt*(FX(i,j,k)+FX(i+1,j,k));
Expand All @@ -147,7 +147,7 @@ REMORA::rhs_t_3d (const Box& bx, const Box& gbx,

if (solverChoice.tracer_Hadv_scheme == AdvectionScheme::upstream3) {

ParallelFor(tbxp1, [=] AMREX_GPU_DEVICE (int i, int j, int k)
ParallelFor(tbxp1x, [=] AMREX_GPU_DEVICE (int i, int j, int k)
{
//Upstream3
curv(i,j,k)=-FX(i,j,k)+FX(i+1,j,k);
Expand All @@ -164,7 +164,7 @@ REMORA::rhs_t_3d (const Box& bx, const Box& gbx,

} else if (solverChoice.tracer_Hadv_scheme == AdvectionScheme::centered4) {

ParallelFor(tbxp1, [=] AMREX_GPU_DEVICE (int i, int j, int k)
ParallelFor(tbxp1x, [=] AMREX_GPU_DEVICE (int i, int j, int k)
{
//Centered4
grad(i,j,k)=0.5_rt*(FX(i,j,k)+FX(i+1,j,k));
Expand Down Expand Up @@ -208,7 +208,7 @@ REMORA::rhs_t_3d (const Box& bx, const Box& gbx,

if (solverChoice.tracer_Hadv_scheme == AdvectionScheme::upstream3) {

ParallelFor(tbxp1, [=] AMREX_GPU_DEVICE (int i, int j, int k)
ParallelFor(tbxp1y, [=] AMREX_GPU_DEVICE (int i, int j, int k)
{
curv(i,j,k)=-FE(i,j,k)+FE(i,j+1,k);
});
Expand All @@ -224,7 +224,7 @@ REMORA::rhs_t_3d (const Box& bx, const Box& gbx,

} else if (solverChoice.tracer_Hadv_scheme == AdvectionScheme::centered4) {

ParallelFor(tbxp1, [=] AMREX_GPU_DEVICE (int i, int j, int k)
ParallelFor(tbxp1y, [=] AMREX_GPU_DEVICE (int i, int j, int k)
{
grad(i,j,k)=0.5_rt*(FE(i,j,k)+FE(i,j+1,k));
});
Expand All @@ -242,7 +242,7 @@ REMORA::rhs_t_3d (const Box& bx, const Box& gbx,
} else {

if (solverChoice.tracer_Hadv_scheme == AdvectionScheme::upstream3) {
ParallelFor(tbxp1, [=] AMREX_GPU_DEVICE (int i, int j, int k)
ParallelFor(tbxp1y, [=] AMREX_GPU_DEVICE (int i, int j, int k)
{
curv(i,j,k)=-FE(i,j,k)+FE(i,j+1,k);
});
Expand All @@ -259,7 +259,7 @@ REMORA::rhs_t_3d (const Box& bx, const Box& gbx,

} else if (solverChoice.tracer_Hadv_scheme == AdvectionScheme::centered4) {

ParallelFor(tbxp1, [=] AMREX_GPU_DEVICE (int i, int j, int k)
ParallelFor(tbxp1y, [=] AMREX_GPU_DEVICE (int i, int j, int k)
{
grad(i,j,k)=0.5_rt*(FE(i,j,k)+FE(i,j+1,k));
});
Expand Down
Loading