Skip to content

Commit

Permalink
define internal inout bndry flag in Field class instead of BCIface
Browse files Browse the repository at this point in the history
  • Loading branch information
mukul1992 committed Aug 2, 2024
1 parent 59a54e5 commit 3910fe5
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 22 deletions.
5 changes: 0 additions & 5 deletions amr-wind/boundary_conditions/BCInterface.H
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ public:
//! User-defined functions for Dirichlet-type boundaries
amrex::Array<const std::string, 3> get_dirichlet_udfs();

//! Check if any of the boundaries is a mass-inflow-outflow
bool has_inout_bndry() const { return m_inout_bndry; }

protected:
//! Setup AMReX mathematical BC types
virtual void set_bcrec() = 0;
Expand Down Expand Up @@ -90,8 +87,6 @@ protected:
}
}

bool m_inout_bndry{false};

//! Field instance where BC is being set
Field& m_field;
};
Expand Down
4 changes: 2 additions & 2 deletions amr-wind/boundary_conditions/BCInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ void BCVelocity::set_bcrec()
break;

case BC::mass_inflow_outflow:
m_inout_bndry = true;
m_field.set_inout_bndry();
if (side == amrex::Orientation::low) {
set_bcrec_lo(dir, amrex::BCType::direction_dependent);
} else {
Expand Down Expand Up @@ -325,7 +325,7 @@ void BCScalar::set_bcrec()
break;

case BC::mass_inflow_outflow:
m_inout_bndry = true;
m_field.set_inout_bndry();
if (side == amrex::Orientation::low) {
set_bcrec_lo(dir, amrex::BCType::direction_dependent);
} else {
Expand Down
9 changes: 9 additions & 0 deletions amr-wind/core/Field.H
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,12 @@ public:
inline bool& in_uniform_space() { return m_mesh_mapped; }
inline bool in_uniform_space() const { return m_mesh_mapped; }

//! Check if any of the boundaries is a mass-inflow-outflow
inline bool has_inout_bndry() const { return m_inout_bndry; }

//! Set the inout_bndry flag
void set_inout_bndry() { m_inout_bndry = true; }

protected:
Field(
FieldRepo& repo,
Expand Down Expand Up @@ -411,6 +417,9 @@ protected:

//! Flag to track mesh mapping (to uniform space) of field
bool m_mesh_mapped{false};

//! Flag to indicate whether any of the boundaries is mass-inflow-outflow
bool m_inout_bndry{false};
};

} // namespace amr_wind
Expand Down
2 changes: 0 additions & 2 deletions amr-wind/equation_systems/BCOps.H
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ struct BCOp<PDE, std::enable_if_t<std::is_base_of_v<ScalarTransport, PDE>>>
const auto udfs = bc.get_dirichlet_udfs();
scalar_bc::register_scalar_dirichlet(
m_fields.field, m_fields.repo.mesh(), m_time, udfs);
has_inout_bndry = bc.has_inout_bndry();

// Used for fillpatch operation on the source term
BCSrcTerm bc_src(m_fields.src_term);
Expand Down Expand Up @@ -55,7 +54,6 @@ struct BCOp<PDE, std::enable_if_t<std::is_base_of_v<ScalarTransport, PDE>>>

PDEFields& m_fields;
const SimTime& m_time;
bool has_inout_bndry{false};
};

} // namespace amr_wind::pde
Expand Down
4 changes: 2 additions & 2 deletions amr-wind/equation_systems/PDE.H
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public:
m_adv_op.reset(new AdvectionOp<PDE, Scheme>(
m_fields, m_sim.has_overset(), variable_density,
m_sim.has_mesh_mapping(), m_sim.is_anelastic(),
m_bc_op.has_inout_bndry));
m_fields.field.has_inout_bndry()));
m_src_op.init_source_terms(m_sim);

// Post-solve operations should also apply after initialization
Expand All @@ -94,7 +94,7 @@ public:
m_adv_op.reset(new AdvectionOp<PDE, Scheme>(
m_fields, m_sim.has_overset(), variable_density,
m_sim.has_mesh_mapping(), m_sim.is_anelastic(),
m_bc_op.has_inout_bndry));
m_fields.field.has_inout_bndry()));

// Post-solve operations should also apply after a regrid
m_post_solve_op(m_time.current_time());
Expand Down
4 changes: 3 additions & 1 deletion amr-wind/equation_systems/icns/icns_advection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,9 @@ void MacProjOp::operator()(const FieldState fstate, const amrex::Real dt)
}
}

if (m_has_inout_bndry) { enforce_inout_solvability(mac_vec); }
if (m_has_inout_bndry) {
enforce_inout_solvability(mac_vec);
}

m_mac_proj->setUMAC(mac_vec);

Expand Down
2 changes: 0 additions & 2 deletions amr-wind/equation_systems/icns/icns_bcop.H
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ struct BCOp<ICNS>
const auto udfs = bc.get_dirichlet_udfs();
vel_bc::register_velocity_dirichlet(
m_fields.field, m_fields.repo.mesh(), m_time, udfs);
has_inout_bndry = bc.has_inout_bndry();

auto& density = m_fields.repo.get_field("density");
const amrex::Real density_default = 1.0;
Expand Down Expand Up @@ -67,7 +66,6 @@ struct BCOp<ICNS>

PDEFields& m_fields;
const SimTime& m_time;
bool has_inout_bndry{false};
};

} // namespace amr_wind::pde
Expand Down
1 change: 0 additions & 1 deletion amr-wind/equation_systems/vof/vof_bcop.H
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ struct BCOp<VOF>

PDEFields& m_fields;
const SimTime& m_time;
bool has_inout_bndry{false};
};

} // namespace amr_wind::pde
Expand Down
3 changes: 0 additions & 3 deletions amr-wind/incflo.H
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,6 @@ private:
// Prescribe advection velocity
bool m_prescribe_vel = false;

// Account for mass-inflow-outflow boundary
bool has_inout_bndry = false;

//! number of cells on all levels including covered cells
amrex::Long m_cell_count{-1};

Expand Down
6 changes: 3 additions & 3 deletions amr-wind/projection/incflo_apply_nodal_projection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,14 +337,14 @@ void incflo::ApplyProjection(

// Need to apply custom Neumann funcs for inflow-outflow BC
// after setting the inflow vels above.
if (!proj_for_small_dt and !incremental) {
if (!proj_for_small_dt and !incremental and velocity.has_inout_bndry()) {
velocity.apply_bc_funcs(amr_wind::FieldState::New);
}

//if (has_inout_bndry) {
if (velocity.has_inout_bndry()) {
amr_wind::nodal_projection::enforce_inout_solvability(
velocity, m_repo.mesh().Geom(), m_repo.num_active_levels());
//}
}

if (is_anelastic) {
for (int lev = 0; lev <= finest_level; ++lev) {
Expand Down
2 changes: 1 addition & 1 deletion unit_tests/equation_systems/test_icns_cstdens.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ICNSConstDensTest : public MeshTest

// Initialize MAC projection operator
const auto& mco =
amr_wind::pde::MacProjOp(sim().repo(), false, false, false, false);
amr_wind::pde::MacProjOp(sim().repo(), false, false, false, false, false);
// Get background density and check
const amrex::Real rho0 = mco.rho0();
EXPECT_EQ(rho0, m_rho_0);
Expand Down

0 comments on commit 3910fe5

Please sign in to comment.