Skip to content

Commit

Permalink
clean up, remove print statements meant for debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
mukul1992 committed Jul 30, 2024
1 parent 8e13439 commit 974fcaa
Show file tree
Hide file tree
Showing 12 changed files with 14 additions and 123 deletions.
3 changes: 1 addition & 2 deletions amr-wind/boundary_conditions/BCInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ void BCIface::set_bcfuncs()

if ((m_field.name() == "velocity") // only velocity for now
&& (bct == BC::mass_inflow_outflow)) {
amrex::Print() << "***** Registering MIO custom Neumann BC for "
<< m_field.name() << std::endl;

m_field.register_custom_bc<MassInflowOutflowBC>(ori);
}

Expand Down
11 changes: 0 additions & 11 deletions amr-wind/boundary_conditions/MassInflowOutflowBC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ void MassInflowOutflowBC::operator()(Field& /*field*/, const FieldState /*rho_st
const int nlevels = m_field.repo().num_active_levels();
const bool ib = (idim == 0), jb = (idim == 1), kb = (idim == 2);

amrex::Print() << "***** Applying MIO custom Neumann fills at orientation: " << idx << std::endl;
for (int lev = 0; lev < nlevels; ++lev) {
const auto& domain = repo.mesh().Geom(lev).Domain();

Expand All @@ -49,11 +48,6 @@ void MassInflowOutflowBC::operator()(Field& /*field*/, const FieldState /*rho_st
bc_a(i-ib, j-jb, k-kb, n) = bc_a(i, j, k, n);
}
}

/*for (int n = 0; n < ncomp; n++) {
amrex::Print() << i << " " << j << " " << k << " " << n << std::endl;
amrex::Print() << "result: " << vel(i-ib, j-jb, k-kb, idim) << " " << bc_a(i-ib, j-jb, k-kb, n) << " " << bc_a(i, j, k, n) << std::endl << std::endl;
}*/
});
}

Expand All @@ -66,11 +60,6 @@ void MassInflowOutflowBC::operator()(Field& /*field*/, const FieldState /*rho_st
bc_a(i, j, k, n) = bc_a(i-ib, j-jb, k-kb, n);
}
}

/*for (int n = 0; n < ncomp; n++) {
amrex::Print() << i << " " << j << " " << k << " " << n << std::endl;
amrex::Print() << "result: " << vel(i-ib, j-jb, k-kb, idim) << " " << bc_a(i-ib, j-jb, k-kb, n) << " " << bc_a(i, j, k, n) << std::endl << std::endl;
}*/
});
}
}
Expand Down
1 change: 0 additions & 1 deletion amr-wind/boundary_conditions/velocity_bcs.H
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ void register_inflow_vel_dirichlet(
mesh, time, InflowOp(field));
} else if (inflow_udf == "TwoLayer") {
using InflowOp = BCOpCreator<udf::TwoLayer, WallOp>;
amrex::Print() << "***** Registering TwoLayer UDF" << std::endl;
field.register_fill_patch_op<FieldFillPatchOps<InflowOp>>(
mesh, time, InflowOp(field));
} else {
Expand Down
2 changes: 0 additions & 2 deletions amr-wind/convection/incflo_godunov_advection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,6 @@ void godunov::compute_fluxes(
}

auto bc = pbc[n];
//if ((i==0) && (j==0) && (k==0))
// amrex::Print() << "***** now calling Godunov_cc_xbc_lo/hi from compute_fluxes" << std::endl;
Godunov_cc_xbc_lo(i, j, k, n, q, stl, sth, umac, bc.lo(0), dlo.x);
Godunov_cc_xbc_hi(i, j, k, n, q, stl, sth, umac, bc.hi(0), dhi.x);

Expand Down
24 changes: 6 additions & 18 deletions amr-wind/convection/incflo_godunov_ppm.H
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,18 @@ AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void Godunov_trans_xbc(
if (i <= domlo) {
if (bclo == BCType::ext_dir ||
(bclo == BCType::direction_dependent && velp >= 0.0)) {
//Print() << "trans_xbc_domlo_extdir triggered at " << i << " " << j << " " << k << " " << n
// << " as uedge is " << velp << std::endl;
// IAMR does this but it breaks lo/hi symmetry
// Real st = (uedge <= small_vel) ? hi : s(domlo-1,j,k,n);
// So here we do something simpler...
Real st = s(domlo - 1, j, k, n);
lo = st;
hi = st;
} else if (
}

else if (
bclo == BCType::foextrap || bclo == BCType::hoextrap ||
bclo == BCType::reflect_even ||
(bclo == BCType::direction_dependent && velp < 0.0)) {
//Print() << "trans_xbc_domlo_foextrap triggered at " << i << " " << j << " " << k << " " << n
// << " as uedge is " << velp << std::endl;
lo = hi;

} else if (bclo == BCType::reflect_odd) {
Expand All @@ -58,20 +56,18 @@ AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void Godunov_trans_xbc(
if (i > domhi) {
if (bchi == BCType::ext_dir ||
(bchi == BCType::direction_dependent && velm <= 0.0)) {
//Print() << "trans_xbc_domhi_extdir triggered at " << i << " " << j << " " << k << " " << n
// << " as uedge is " << velm << std::endl;
// IAMR does this but it breaks lo/hi symmetry
// Real st = (uedge >= -small_vel)? lo : s(domhi+1,j,k,n);
// So here we do something simpler...
Real st = s(domhi + 1, j, k, n);
lo = st;
hi = st;
} else if (
}

else if (
bchi == BCType::foextrap || bchi == BCType::hoextrap ||
bchi == BCType::reflect_even ||
(bchi == BCType::direction_dependent && velm > 0.0)) {
//Print() << "trans_xbc_domhi_foextrap triggered at " << i << " " << j << " " << k << " " << n
// << " as uedge is " << velm << std::endl;
hi = lo;

} else if (bchi == BCType::reflect_odd) {
Expand Down Expand Up @@ -228,17 +224,13 @@ AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void Godunov_cc_xbc_lo(
if (i == domlo) {
if ((bclo == BCType::ext_dir && uedge(i, j, k) >= 0.) ||
(bclo == BCType::direction_dependent && uedge(i, j, k) >= 0.)) {
//Print() << "cc_xbc_lo_extdir triggered at " << i << " " << j << " " << k << " " << n
// << " as uedge is " << uedge(i,j,k) << std::endl;
hi = s(domlo - 1, j, k, n);
lo = hi;
} else if (
bclo == BCType::foextrap || bclo == BCType::hoextrap ||
bclo == BCType::reflect_even ||
(bclo == BCType::ext_dir && uedge(i, j, k) < 0) ||
(bclo == BCType::direction_dependent && uedge(i, j, k) < 0)) {
//Print() << "cc_xbc_lo_foextrap triggered at " << i << " " << j << " " << k << " " << n
// << " as uedge is " << uedge(i,j,k) << std::endl;
lo = hi;

} else if (bclo == BCType::reflect_odd) {
Expand Down Expand Up @@ -267,17 +259,13 @@ AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void Godunov_cc_xbc_hi(
if (i == domhi + 1) {
if ((bchi == BCType::ext_dir && uedge(i, j, k) <= 0.) ||
(bchi == BCType::direction_dependent && uedge(i, j, k) <= 0.)) {
//Print() << "cc_xbc_hi_extdir triggered at " << i << " " << j << " " << k << " " << n
// << " as uedge is " << uedge(i,j,k) << std::endl;
lo = s(domhi + 1, j, k, n);
hi = lo;
} else if (
bchi == BCType::foextrap || bchi == BCType::hoextrap ||
bchi == BCType::reflect_even ||
(bchi == BCType::ext_dir && uedge(i, j, k) > 0) ||
(bchi == BCType::direction_dependent && uedge(i, j, k) > 0)) {
//Print() << "cc_xbc_hi_foextrap triggered at " << i << " " << j << " " << k << " " << n
// << " as uedge is " << uedge(i,j,k) << std::endl;
hi = lo;

} else if (bchi == BCType::reflect_odd) {
Expand Down
3 changes: 1 addition & 2 deletions amr-wind/convection/incflo_godunov_predict.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,7 @@ void godunov::predict_godunov(
stl += 0.5 * l_dt * f(i - 1, j, k, n);
sth += 0.5 * l_dt * f(i, j, k, n);
}
//if ((i==0) && (j==0) && (k==0))
// amrex::Print() << "***** now calling Godunov_cc_xbc_lo/hi from predict_godunov" << std::endl;

Godunov_cc_xbc_lo(i, j, k, n, q, stl, sth, u_ad, bc.lo(0), dlo.x);
Godunov_cc_xbc_hi(i, j, k, n, q, stl, sth, u_ad, bc.hi(0), dhi.x);

Expand Down
7 changes: 1 addition & 6 deletions amr-wind/convection/incflo_godunov_weno.H
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,13 @@ AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void Godunov_weno_xbc(
if (bclo == BCType::ext_dir || bclo == BCType::hoextrap
|| (bclo == BCType::direction_dependent && velm >= 0.0)) {
if (i == domlo) {
//Print() << "weno_xbc_domlo_extdir triggered at " << i << " " << j << " " << k << " " << n
// << " as velm is " << velm << std::endl;
sp = -0.2 * s(domlo - 1, j, k, n) + 0.75 * s(domlo, j, k, n) +
0.5 * s(domlo + 1, j, k, n) - 0.05 * s(domlo + 2, j, k, n);

sm = s(domlo - 1, j, k, n);

} else if (i == domlo + 1) {
//Print() << "weno_xbc_domlop1_extdir triggered at " << i << " " << j << " " << k << " " << n
// << " as velm is " << velm << std::endl;

sm = -0.2 * s(domlo - 1, j, k, n) + 0.75 * s(domlo, j, k, n) +
0.5 * s(domlo + 1, j, k, n) - 0.05 * s(domlo + 2, j, k, n);

Expand All @@ -94,8 +91,6 @@ AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void Godunov_weno_xbc(
if (bchi == BCType::ext_dir || bchi == BCType::hoextrap
|| (bchi == BCType::direction_dependent && velp <= 0.0)) {
if (i == domhi) {
//Print() << "weno_xbc_domhi_extdir triggered at " << i << " " << j << " " << k << " " << n
// << " as velp is " << velp << std::endl;
sm = -0.2 * s(domhi + 1, j, k, n) + 0.75 * s(domhi, j, k, n) +
0.5 * s(domhi - 1, j, k, n) - 0.05 * s(domhi - 2, j, k, n);

Expand Down
7 changes: 2 additions & 5 deletions amr-wind/equation_systems/icns/icns_advection.H
Original file line number Diff line number Diff line change
Expand Up @@ -302,18 +302,15 @@ struct AdvectionOp<ICNS, fvm::Godunov>

// MAC projection
m_macproj_op(fstate, dt);
//amrex::Print() << "!!! umac before fillpatch" << std::endl;
//amrex::Print() << u_mac(0)[0];
amrex::Print() << "Fill mac velocities using velocity BCs" << std::endl;

// Fill mac velocities using velocity BCs
if (fvm::Godunov::nghost_state > 0) {
amrex::Array<Field*, AMREX_SPACEDIM> mac_vel = {
AMREX_D_DECL(&u_mac, &v_mac, &w_mac)};
dof_field.fillpatch_sibling_fields(
time + 0.5 * dt, u_mac.num_grow(), mac_vel);
}
//amrex::Print() << "!!! umac after fillpatch" << std::endl;
//amrex::Print() << u_mac(0)[0];

for (int lev = 0; lev < repo.num_active_levels(); ++lev) {
u_mac(lev).FillBoundary(geom[lev].periodicity());
v_mac(lev).FillBoundary(geom[lev].periodicity());
Expand Down
24 changes: 1 addition & 23 deletions amr-wind/equation_systems/icns/icns_advection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@
#include "AMReX_MultiFabUtil.H"
#include "hydro_MacProjector.H"

// only for debugging
#include "AMReX_PlotFileUtil.H"
#include "AMReX_MultiFabUtil.H"
#include "AMReX_MultiFab.H"
//
namespace amr_wind::pde {

namespace {
Expand Down Expand Up @@ -73,7 +68,7 @@ void MacProjOp::enforce_inout_solvability (
auto& velocity = m_repo.get_field("velocity");
amrex::BCRec const* bc_type = velocity.bcrec_device().data();
const amrex::Vector<amrex::Geometry>& geom = m_repo.mesh().Geom();
amrex::Print() << "***** Calling enforceSolvability from AMR-Wind" << std::endl;

HydroUtils::enforceInOutSolvability(a_umac, bc_type, geom);
}

Expand Down Expand Up @@ -253,21 +248,8 @@ void MacProjOp::operator()(const FieldState fstate, const amrex::Real dt)
}
}

//amrex::Array<const amrex::MultiFab*, AMREX_SPACEDIM> mac_arr = {&u_mac(0), &v_mac(0), &w_mac(0)};
//amrex::MultiFab mac_vec_cc(amrex::convert((u_mac(0)).boxArray(), amrex::IntVect{0,0,0}), (u_mac(0)).DistributionMap(), 3, 0);

//amrex::average_face_to_cellcenter(mac_vec_cc, 0, mac_arr);
//amrex::WriteSingleLevelPlotfile("plt_macvel_precorrect", mac_vec_cc, {"umac","vmac","wmac"}, geom[0], 0.0, 0);
//amrex::Print() << "!!! umac precorrect" << std::endl;
//amrex::Print() << u_mac(0)[0];

enforce_inout_solvability(mac_vec);

//amrex::Print() << "!!! umac postcorrect" << std::endl;
//amrex::Print() << u_mac(0)[0];
//amrex::average_face_to_cellcenter(mac_vec_cc, 0, mac_arr);
//amrex::WriteSingleLevelPlotfile("plt_macvel_postcorrect", mac_vec_cc, {"umac","vmac","wmac"}, geom[0], 0.0, 0);

m_mac_proj->setUMAC(mac_vec);

if (m_has_overset) {
Expand All @@ -283,10 +265,6 @@ void MacProjOp::operator()(const FieldState fstate, const amrex::Real dt)
} else {
m_mac_proj->project(m_options.rel_tol, m_options.abs_tol);
}
//amrex::average_face_to_cellcenter(mac_vec_cc, 0, mac_arr);
//amrex::WriteSingleLevelPlotfile("plt_macvel_postproject", mac_vec_cc, {"umac","vmac","wmac"}, geom[0], 0.0, 0);
//amrex::Print() << "!!! umac postproject" << std::endl;
//amrex::Print() << u_mac(0)[0];

if (m_is_anelastic) {
for (int lev = 0; lev < m_repo.num_active_levels(); ++lev) {
Expand Down
35 changes: 2 additions & 33 deletions amr-wind/physics/udfs/TwoLayer.H
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ struct TwoLayer
{
struct DeviceOp
{
// clang-format off
// Declare parameters here if needed. For example:
// amrex::Real foo{1.0};
// amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> bar = {0.0};
// clang-format on

// velocities of the top and bottom layer respectively
//amrex::Real pvel{0.0}; amrex::Real mvel{0.0};
amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> pvel = {0.0};
Expand All @@ -36,49 +30,24 @@ struct TwoLayer
const int dcomp,
const int orig_comp) const
{
if ((iv[0] == -1) && (iv[1] == -1) && (iv[2] == 0))
amrex::Print() << "***** filling custom velocity at " << iv << "..." << std::endl;
if ((iv[0] == 1) && (iv[1] == 1) && (iv[2] == 1))
amrex::Print() << "***** filling custom velocity at " << iv << "..." << std::endl;

if ((iv[0] == -1) && (iv[1] == -1) && (iv[2] == 0))
amrex::Print() << "***** Time is " << time << "..." << std::endl;

// Compute quantities to set the field values. For example:
// clang-format off
const auto* problo = geom.ProbLo();
const auto* dx = geom.CellSize();
// const auto x = problo[0] + (iv[0] + 0.5) * dx[0];
// const auto y = problo[1] + (iv[1] + 0.5) * dx[1];
const auto z = problo[2] + (iv[2] + 0.5) * dx[2]; // not true for w-mac vels
// const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> vel = {1.0, 0.0, 0.0};

// Once the above is done, fill the field as:
amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> vel;
//vel = {((z >= 0.5) ? pvel : mvel), 0.0, 0.0};
if (z>=0.5) {
vel = {pvel[0], pvel[1], 0.0};
} else {
vel = {mvel[0], mvel[1], 0.0};
}

// perturb by some factor at time 0
if (time == 0.0) {
vel[0] *= 0.9;
vel[1] *= 0.9;
}
field(iv[0], iv[1], iv[2], dcomp + comp) = vel[orig_comp + comp];
/*
if (x <= 0.5) {
// at the low-x boundary, +ve vel in top portion, garbage in the rest
//vel = {((z >= 0.5) ? pvel : -1e10), 0.0, 0.0};
//vel = {((z >= 0.5) ? pvel : 0.0), 0.0, 0.0};
} else {
// at the high-x boundary, -ve vel in bottom portion, garbage in the rest
//vel = {((z < 0.5) ? mvel : 1e10), 0.0, 0.0};
//vel = {((z < 0.5) ? mvel : 0.0), 0.0, 0.0};
}*/

// clang-format on
field(iv[0], iv[1], iv[2], dcomp + comp) = vel[orig_comp + comp];
}
};
using DeviceType = DeviceOp;
Expand Down
11 changes: 0 additions & 11 deletions amr-wind/physics/udfs/TwoLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@ namespace amr_wind::udf {

TwoLayer::TwoLayer(const Field& fld)
{
// This is a where the user can set some user defined variables
// This capability can be activated with the following in the input file:
// xlo.type = "mass_inflow"
// xlo.velocity.inflow_type = CustomVelocity
// CustomVelocity.foo = 1.0

// clang-format off
{
const int ncomp = fld.num_comp();
amrex::ParmParse pp("TwoLayer");
Expand All @@ -33,10 +26,6 @@ TwoLayer::TwoLayer(const Field& fld)
m_op.mvel[i] = mvel[i];
}
}
// clang-format on
//amrex::Abort(
// "Please define the body of this function and the corresponding struct "
// "in the header file before using it. Then remove this message");
}

} // namespace amr_wind::udf
9 changes: 0 additions & 9 deletions amr-wind/projection/incflo_apply_nodal_projection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
#include "amr-wind/projection/nodal_projection_ops.H"
#include "hydro_utils.H"

// for debugging
#include "AMReX_PlotFileUtil.H"

using namespace amrex;

void amr_wind::nodal_projection::set_inflow_velocity(
Expand Down Expand Up @@ -338,8 +335,6 @@ void incflo::ApplyProjection(
vel[lev]->FillBoundary(geom[lev].periodicity());
}
}
//amrex::Print() << "*********** partition **********" << std::endl;
//amrex::Print() << velocity(0)[0];

// Need to apply custom Neumann funcs for inflow-outflow BC
// after setting the inflow vels above.
Expand All @@ -351,8 +346,6 @@ void incflo::ApplyProjection(
velocity, m_repo.mesh().Geom(), m_repo.num_active_levels());
}

//amrex::Print() << velocity(0)[0];

if (is_anelastic) {
for (int lev = 0; lev <= finest_level; ++lev) {
amrex::Multiply(
Expand Down Expand Up @@ -453,8 +446,6 @@ void incflo::ApplyProjection(
}
}

//amrex::WriteSingleLevelPlotfile("plt_vel_post_nodalproj", velocity(0), {"u","v","w"}, geom[0], 0.0, 0);

// Get phi and fluxes
auto phi = nodal_projector->getPhi();
auto gradphi = nodal_projector->getGradPhi();
Expand Down

0 comments on commit 974fcaa

Please sign in to comment.