Skip to content

Commit

Permalink
clean up print messages etc for draft PR
Browse files Browse the repository at this point in the history
  • Loading branch information
mukul1992 committed May 18, 2024
1 parent 0dcbb5d commit 0fdf77a
Show file tree
Hide file tree
Showing 14 changed files with 50 additions and 66 deletions.
4 changes: 2 additions & 2 deletions amr-wind/boundary_conditions/BCInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ void BCIface::set_bcfuncs()
m_field.register_custom_bc<FixedGradientBC>(ori);
}

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

Expand Down
4 changes: 2 additions & 2 deletions amr-wind/boundary_conditions/MassInflowOutflowBC.H
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

namespace amr_wind {

/** Can handle both inflow and outflow cells in the same boundary
/** Custom Neumann fills for the inflow-outflow BC
* \ingroup field_bc
*
*
* Used to fill the outflow boundary cells for mass-inflow-outflow BC
*/
class MassInflowOutflowBC : public FieldBCIface
{
Expand Down
5 changes: 2 additions & 3 deletions amr-wind/boundary_conditions/MassInflowOutflowBC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ 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;
//amrex::Print() << nlevels << " level(s)" << std::endl << std::endl;
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 @@ -37,7 +36,7 @@ void MassInflowOutflowBC::operator()(Field& /*field*/, const FieldState /*rho_st
#endif
for (amrex::MFIter mfi(m_field(lev), mfi_info); mfi.isValid(); ++mfi) {
auto bx = mfi.validbox();
bx.grow({!ib, !jb, !kb}); // how to manage corner cells??
//bx.grow({!ib, !jb, !kb}); // how to manage corner cells??
const auto& bc_a = m_field(lev).array(mfi);
const auto& vel = velocity(lev).array(mfi);

Expand Down
4 changes: 2 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,8 @@ 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;
//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
19 changes: 10 additions & 9 deletions amr-wind/convection/incflo_godunov_ppm.H
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void Godunov_trans_xbc(
const int domhi)
{
using namespace amrex;
// is the "inverse" use of velm and velp justified?

// for MIO BC, use vel+ at bclo and vel- at bchi for determining ext_dir/foextrap treatment
// Low X
if (i <= domlo) {
if (bclo == BCType::ext_dir ||
Expand Down Expand Up @@ -217,17 +218,17 @@ 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::user_1 && 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;
//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::user_1 && 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;
//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 @@ -256,17 +257,17 @@ 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::user_1 && 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;
//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::user_1 && 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;
//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
9 changes: 3 additions & 6 deletions amr-wind/convection/incflo_godunov_predict.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@ void godunov::make_trans_velocities(
lo = Ipx(i - 1, j, k, n);
hi = Imx(i, j, k, n);
}
/*if (((i==0) || (i==16)) && (j==3) && ((k==1) || (k==14))) {
Print() << "lo hi at " << i << " " << j << " " << k << " " << n << " "
<< lo << " " << hi << std::endl;
}*/

auto bc = pbc[n];
Godunov_trans_xbc(
i, j, k, n, vel, lo, hi, lo, hi, bc.lo(0), bc.hi(0), dlo.x, dhi.x);
Expand Down Expand Up @@ -332,8 +329,8 @@ 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;
//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
20 changes: 8 additions & 12 deletions amr-wind/convection/incflo_godunov_weno.H
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,16 @@ AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void Godunov_weno_xbc(
if (bclo == BCType::ext_dir || bclo == BCType::hoextrap
|| (bclo == BCType::user_1 && velm >= 0.0)) {
if (i == domlo) {
//Print() << "weno_xbc_domlo_extdir triggered at " << i << " " << j << " " << k << " " << n
// << " as velm is " << velm << std::endl;
//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;
//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,16 +94,16 @@ AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void Godunov_weno_xbc(
if (bchi == BCType::ext_dir || bchi == BCType::hoextrap
|| (bchi == BCType::user_1 && velp <= 0.0)) {
if (i == domhi) {
//Print() << "weno_xbc_domhi_extdir triggered at " << i << " " << j << " " << k << " " << n
// << " as velp is " << velp << std::endl;
//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);

sp = s(domhi + 1, j, k, n);

} else if (i == domhi - 1) {
//Print() << "weno_xbc_domhim1_extdir triggered at " << i << " " << j << " " << k << " " << n
// << " as velp is " << velp << std::endl;
//Print() << "weno_xbc_domhim1_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 Expand Up @@ -278,10 +278,6 @@ AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void Godunov_weno_pred_x(
Ip(i, j, k, n) = S(i, j, k, n);
Im(i, j, k, n) = S(i, j, k, n);
}
/*if (((i==0) || (i==15)) && (j==3) && ((k==1) || (k==14))) {
Print() << "Im Ip at " << i << " " << j << " " << k << " " << n << " "
<< Im(i, j, k, n) << " " << Ip(i, j, k, n) << std::endl;
}*/
}

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void Godunov_weno_pred_y(
Expand Down
18 changes: 11 additions & 7 deletions amr-wind/equation_systems/icns/icns_advection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
#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 @@ -68,7 +69,7 @@ void MacProjOp::enforce_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;
amrex::Print() << "***** Calling enforceSolvability from AMR-Wind" << std::endl;
m_mac_proj->enforceSolvability(a_umac, bc_type, geom);
}

Expand Down Expand Up @@ -248,14 +249,17 @@ 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::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::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);

enforce_solvability(mac_vec);
amrex::average_face_to_cellcenter(mac_vec_cc, 0, mac_arr);

//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 @@ -271,7 +275,7 @@ amrex::average_face_to_cellcenter(mac_vec_cc, 0, mac_arr);
} 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::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);

if (m_is_anelastic) {
Expand Down
4 changes: 2 additions & 2 deletions amr-wind/equation_systems/icns/icns_bcop.H
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ struct BCOp<ICNS>
{
amrex::IntVect ng_diff(1);
auto& field = m_fields.field;
amrex::Print() << "****** filling physical BCs ******" << std::endl;
amrex::Print() << "***** Filling physical BCs" << std::endl;
field.fillphysbc(m_time.new_time(), ng_diff);
amrex::Print() << "****** applying BC funcs ******" << std::endl;
amrex::Print() << "***** Applying BC funcs" << std::endl;
field.apply_bc_funcs(rho_state);
}

Expand Down
12 changes: 0 additions & 12 deletions amr-wind/physics/ChannelFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "AMReX_ParmParse.H"
#include "amr-wind/utilities/trig_ops.H"
#include "amr-wind/utilities/DirectionSelector.H"
#include "amr-wind/boundary_conditions/MassInflowOutflowBC.H"

namespace amr_wind::channel_flow {

Expand Down Expand Up @@ -443,17 +442,6 @@ void ChannelFlow::post_init_actions()
"Wall normal direction should be 2 if using a wall model");
velocity.register_custom_bc<VelWallFunc>(m_wall_func);
}
/*
const auto& ibctype = velocity.bc_type();
for (amrex::OrientationIter oit; oit != nullptr; ++oit) {
auto ori = oit();
const auto bct = ibctype[ori];
if (bct == BC::mass_inflow_outflow) {
amrex::Print() << "howdyyyyyyyyyyyy" << std::endl;
velocity.register_custom_bc<MassInflowOutflowBC>(ori);
}
}*/
}

void ChannelFlow::post_advance_work()
Expand Down
9 changes: 5 additions & 4 deletions amr-wind/projection/incflo_apply_nodal_projection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
#include "amr-wind/core/field_ops.H"
#include "amr-wind/wind_energy/ABL.H"

#include "amr-wind/utilities/IOManager.H"

// for debugging
#include "AMReX_PlotFileUtil.H"

using namespace amrex;
Expand Down Expand Up @@ -314,11 +313,13 @@ void incflo::ApplyProjection(
//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
// Need to apply custom Neumann funcs for inflow-outflow BC
// after setting the inflow vels above.
if (!proj_for_small_dt and !incremental) {
velocity.apply_bc_funcs(amr_wind::FieldState::New);
}
// Currently doing this after setting the non-inflow boundaries to zero
// is causing issues at the corner cells.

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

Expand Down
2 changes: 0 additions & 2 deletions amr-wind/setup/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@ void incflo::InitialIterations()
{
auto& vel = icns().fields().field;
vel.copy_state(amr_wind::FieldState::Old, amr_wind::FieldState::New);
amrex::Print() << "****** starting fillpatch from InitialIterations()" << std::endl;
vel.state(amr_wind::FieldState::Old).fillpatch(m_time.current_time());
amrex::Print() << "****** completed fillpatch from InitialIterations()" << std::endl;

if (m_sim.pde_manager().constant_density()) {
auto& rho = density();
Expand Down
4 changes: 2 additions & 2 deletions bctest/input_inflow
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# SIMULATION STOP #
#.......................................#
time.stop_time = 2.00 # Max (simulated) time to evolve
time.max_step = 1 #-1000 # Max number of time steps
time.max_step = -1 #-1000 # Max number of time steps

#¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨#
# TIME STEP COMPUTATION #
Expand All @@ -26,7 +26,7 @@ incflo.use_godunov = 1
incflo.diffusion_type = 1
incflo.godunov_type = "weno_z"

incflo.initial_iterations = 1
#incflo.initial_iterations = 1
#incflo.do_initial_proj = false
incflo.verbose = 3

Expand Down
2 changes: 1 addition & 1 deletion bctest/input_inout
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ incflo.use_godunov = 1
incflo.diffusion_type = 1
incflo.godunov_type = "weno_z"

incflo.initial_iterations = 1
#incflo.initial_iterations = 1
#incflo.do_initial_proj = false
incflo.verbose = 3

Expand Down

0 comments on commit 0fdf77a

Please sign in to comment.