Skip to content

Commit

Permalink
Merge branch 'development' into LandSeaTemplate
Browse files Browse the repository at this point in the history
  • Loading branch information
AMLattanzi authored Jun 25, 2024
2 parents fa73cb6 + e571ffe commit c109bfe
Show file tree
Hide file tree
Showing 7 changed files with 457 additions and 325 deletions.
94 changes: 52 additions & 42 deletions Exec/DevTests/MovingTerrain/prob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,47 +155,57 @@ Problem::init_custom_terrain (const Geometry& geom,
MultiFab& z_phys_nd,
const Real& time)
{
// Domain cell size and real bounds
auto dx = geom.CellSizeArray();

// Domain valid box (z_nd is nodal)
const amrex::Box& domain = geom.Domain();
int domlo_x = domain.smallEnd(0); int domhi_x = domain.bigEnd(0) + 1;
int domlo_z = domain.smallEnd(2);

// Number of ghost cells
int ngrow = z_phys_nd.nGrow();

// Populate bottom plane
int k0 = domlo_z;

Real Ampl = parms.Ampl;
Real wavelength = 100.;
Real kp = 2.0 * PI / wavelength;
Real g = CONST_GRAV;
Real omega = std::sqrt(g * kp);

for (MFIter mfi(z_phys_nd,amrex::TilingIfNotGPU()); mfi.isValid(); ++mfi)
{
// Grown box with no z range
amrex::Box xybx = mfi.growntilebox(ngrow);
xybx.setRange(2,0);

amrex::Array4<Real> const& z_arr = z_phys_nd.array(mfi);

ParallelFor(xybx, [=] AMREX_GPU_DEVICE (int i, int j, int) {

// Clip indices for ghost-cells
int ii = amrex::min(amrex::max(i,domlo_x),domhi_x);

// Location of nodes
Real x = ii * dx[0];

// Wave height
Real height = Ampl * std::sin(kp * x - omega * time);

// Populate terrain height
z_arr(i,j,k0) = height;
});
// Check if a valid csv file exists for the terrain
std::string fname;
amrex::ParmParse pp("erf");
auto valid_fname = pp.query("terrain_file_name",fname);
if (valid_fname) {
this->read_custom_terrain(fname,geom,z_phys_nd,time);
} else {

// Domain cell size and real bounds
auto dx = geom.CellSizeArray();

// Domain valid box (z_nd is nodal)
const amrex::Box& domain = geom.Domain();
int domlo_x = domain.smallEnd(0); int domhi_x = domain.bigEnd(0) + 1;
int domlo_z = domain.smallEnd(2);

// Number of ghost cells
int ngrow = z_phys_nd.nGrow();

// Populate bottom plane
int k0 = domlo_z;

Real Ampl = parms.Ampl;
Real wavelength = 100.;
Real kp = 2.0 * PI / wavelength;
Real g = CONST_GRAV;
Real omega = std::sqrt(g * kp);

for (MFIter mfi(z_phys_nd,amrex::TilingIfNotGPU()); mfi.isValid(); ++mfi)
{
// Grown box with no z range
amrex::Box xybx = mfi.growntilebox(ngrow);
xybx.setRange(2,0);

amrex::Array4<Real> const& z_arr = z_phys_nd.array(mfi);

ParallelFor(xybx, [=] AMREX_GPU_DEVICE (int i, int j, int)
{

// Clip indices for ghost-cells
int ii = amrex::min(amrex::max(i,domlo_x),domhi_x);

// Location of nodes
Real x = ii * dx[0];

// Wave height
Real height = Ampl * std::sin(kp * x - omega * time);

// Populate terrain height
z_arr(i,j,k0) = height;
});
}
}
}
106 changes: 58 additions & 48 deletions Exec/RegTests/ParticlesOverWoA/prob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,54 +126,64 @@ void
Problem::init_custom_terrain(
const Geometry& geom,
MultiFab& z_phys_nd,
const Real& /*time*/)
const Real& time)
{
// Domain cell size and real bounds
auto dx = geom.CellSizeArray();
auto ProbLoArr = geom.ProbLoArray();
auto ProbHiArr = geom.ProbHiArray();

// Domain valid box (z_nd is nodal)
const amrex::Box& domain = geom.Domain();
int domlo_x = domain.smallEnd(0); int domhi_x = domain.bigEnd(0) + 1;
// int domlo_y = domain.smallEnd(1); int domhi_y = domain.bigEnd(1) + 1;
int domlo_z = domain.smallEnd(2);

// User function parameters
Real a = 0.5;
Real num = 8 * a * a * a;
Real xcen = 0.5 * (ProbLoArr[0] + ProbHiArr[0]);
// Real ycen = 0.5 * (ProbLoArr[1] + ProbHiArr[1]);

// Number of ghost cells
int ngrow = z_phys_nd.nGrow();

// Populate bottom plane
int k0 = domlo_z;

for ( amrex::MFIter mfi(z_phys_nd,amrex::TilingIfNotGPU()); mfi.isValid(); ++mfi )
{
// Grown box with no z range
amrex::Box xybx = mfi.growntilebox(ngrow);
xybx.setRange(2,0);

amrex::Array4<Real> const& z_arr = z_phys_nd.array(mfi);

ParallelFor(xybx, [=] AMREX_GPU_DEVICE (int i, int j, int) {

// Clip indices for ghost-cells
int ii = amrex::min(amrex::max(i,domlo_x),domhi_x);
// int jj = amrex::min(amrex::max(j,domlo_y),domhi_y);

// Location of nodes
Real x = (ii * dx[0] - xcen);
// Real y = (jj * dx[1] - ycen);

// WoA Hill in x-direction
Real height = num / (x*x + 4 * a * a);

// Populate terrain height
z_arr(i,j,k0) = height;
});
// Check if a valid csv file exists for the terrain
std::string fname;
amrex::ParmParse pp("erf");
auto valid_fname = pp.query("terrain_file_name",fname);
if (valid_fname) {
this->read_custom_terrain(fname,geom,z_phys_nd,time);
} else {

// Domain cell size and real bounds
auto dx = geom.CellSizeArray();
auto ProbLoArr = geom.ProbLoArray();
auto ProbHiArr = geom.ProbHiArray();

// Domain valid box (z_nd is nodal)
const amrex::Box& domain = geom.Domain();
int domlo_x = domain.smallEnd(0); int domhi_x = domain.bigEnd(0) + 1;
// int domlo_y = domain.smallEnd(1); int domhi_y = domain.bigEnd(1) + 1;
int domlo_z = domain.smallEnd(2);

// User function parameters
Real a = 0.5;
Real num = 8 * a * a * a;
Real xcen = 0.5 * (ProbLoArr[0] + ProbHiArr[0]);
// Real ycen = 0.5 * (ProbLoArr[1] + ProbHiArr[1]);

// Number of ghost cells
int ngrow = z_phys_nd.nGrow();

// Populate bottom plane
int k0 = domlo_z;

for ( amrex::MFIter mfi(z_phys_nd,amrex::TilingIfNotGPU()); mfi.isValid(); ++mfi )
{
// Grown box with no z range
amrex::Box xybx = mfi.growntilebox(ngrow);
xybx.setRange(2,0);

amrex::Array4<Real> const& z_arr = z_phys_nd.array(mfi);

ParallelFor(xybx, [=] AMREX_GPU_DEVICE (int i, int j, int)
{

// Clip indices for ghost-cells
int ii = amrex::min(amrex::max(i,domlo_x),domhi_x);
// int jj = amrex::min(amrex::max(j,domlo_y),domhi_y);

// Location of nodes
Real x = (ii * dx[0] - xcen);
// Real y = (jj * dx[1] - ycen);

// WoA Hill in x-direction
Real height = num / (x*x + 4 * a * a);

// Populate terrain height
z_arr(i,j,k0) = height;
});
}
}
}
106 changes: 58 additions & 48 deletions Exec/RegTests/Terrain2d_Cylinder/prob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,54 +87,64 @@ void
Problem::init_custom_terrain(
const Geometry& geom,
MultiFab& z_phys_nd,
const Real& /*time*/)
const Real& time)
{
// Domain cell size and real bounds
auto dx = geom.CellSizeArray();
auto ProbLoArr = geom.ProbLoArray();
auto ProbHiArr = geom.ProbHiArray();

// Domain valid box (z_nd is nodal)
const amrex::Box& domain = geom.Domain();
int domlo_x = domain.smallEnd(0); int domhi_x = domain.bigEnd(0) + 1;
// int domlo_y = domain.smallEnd(1); int domhi_y = domain.bigEnd(1) + 1;
int domlo_z = domain.smallEnd(2);

// User function parameters
Real a = 0.5;
Real num = 8 * a * a * a;
Real xcen = 0.5 * (ProbLoArr[0] + ProbHiArr[0]);
Real ycen = 0.5 * (ProbLoArr[1] + ProbHiArr[1]);

// Number of ghost cells
int ngrow = z_phys_nd.nGrow();

// Populate bottom plane
int k0 = domlo_z;

for ( amrex::MFIter mfi(z_phys_nd,amrex::TilingIfNotGPU()); mfi.isValid(); ++mfi )
{
// Grown box with no z range
amrex::Box xybx = mfi.growntilebox(ngrow);
xybx.setRange(2,0);

amrex::Array4<Real> const& z_arr = z_phys_nd.array(mfi);

ParallelFor(xybx, [=] AMREX_GPU_DEVICE (int i, int j, int) {

// Clip indices for ghost-cells
int ii = amrex::min(amrex::max(i,domlo_x),domhi_x);

// Location of nodes
Real x = (ii * dx[0] - xcen);

if(fabs(x)<a){
z_arr(i,j,k0) = pow(a*a - x*x, 0.5);
}
else{
z_arr(i,j,k0) = 0.0;
}

});
// Check if a valid csv file exists for the terrain
std::string fname;
amrex::ParmParse pp("erf");
auto valid_fname = pp.query("terrain_file_name",fname);
if (valid_fname) {
this->read_custom_terrain(fname,geom,z_phys_nd,time);
} else {

// Domain cell size and real bounds
auto dx = geom.CellSizeArray();
auto ProbLoArr = geom.ProbLoArray();
auto ProbHiArr = geom.ProbHiArray();

// Domain valid box (z_nd is nodal)
const amrex::Box& domain = geom.Domain();
int domlo_x = domain.smallEnd(0); int domhi_x = domain.bigEnd(0) + 1;
// int domlo_y = domain.smallEnd(1); int domhi_y = domain.bigEnd(1) + 1;
int domlo_z = domain.smallEnd(2);

// User function parameters
Real a = 0.5;
Real num = 8 * a * a * a;
Real xcen = 0.5 * (ProbLoArr[0] + ProbHiArr[0]);
Real ycen = 0.5 * (ProbLoArr[1] + ProbHiArr[1]);

// Number of ghost cells
int ngrow = z_phys_nd.nGrow();

// Populate bottom plane
int k0 = domlo_z;

for ( amrex::MFIter mfi(z_phys_nd,amrex::TilingIfNotGPU()); mfi.isValid(); ++mfi )
{
// Grown box with no z range
amrex::Box xybx = mfi.growntilebox(ngrow);
xybx.setRange(2,0);

amrex::Array4<Real> const& z_arr = z_phys_nd.array(mfi);

ParallelFor(xybx, [=] AMREX_GPU_DEVICE (int i, int j, int)
{

// Clip indices for ghost-cells
int ii = amrex::min(amrex::max(i,domlo_x),domhi_x);

// Location of nodes
Real x = (ii * dx[0] - xcen);

if(fabs(x)<a){
z_arr(i,j,k0) = pow(a*a - x*x, 0.5);
}
else{
z_arr(i,j,k0) = 0.0;
}

});
}
}
}
Loading

0 comments on commit c109bfe

Please sign in to comment.