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

For explicit diffusion operations, use designated state of the variable #1304

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
4 changes: 2 additions & 2 deletions amr-wind/core/Field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,11 +266,11 @@ void Field::fillphysbc(const amrex::Real time) noexcept
fillphysbc(time, num_grow());
}

void Field::apply_bc_funcs(const FieldState rho_state) noexcept
void Field::apply_bc_funcs(const FieldState state) noexcept
{
BL_ASSERT(m_info->bc_initialized() && m_info->m_bc_copied_to_device);
for (const auto& func : m_info->m_bc_func) {
(*func)(*this, rho_state);
(*func)(*this, state);
}
}

Expand Down
13 changes: 6 additions & 7 deletions amr-wind/equation_systems/BCOps.H
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,20 @@ struct BCOp<PDE, std::enable_if_t<std::is_base_of_v<ScalarTransport, PDE>>>

/**
*/
void apply_bcs(const FieldState rho_state)
void apply_bcs(const FieldState state)
{
amrex::IntVect ng_diff(1);
auto& field = m_fields.field;
const auto bc_time = (rho_state == FieldState::Old)
? m_time.current_time()
: m_time.new_time();
if ((rho_state != FieldState::Old && rho_state != FieldState::New)) {
auto& field = m_fields.field.state(state);
const auto bc_time = (state == FieldState::Old) ? m_time.current_time()
: m_time.new_time();
if ((state != FieldState::Old && state != FieldState::New)) {
amrex::Abort(
"BCOps.H apply_bcs(): a state other than New or Old was used. "
"The method of setting bc_time must be evaluated before using "
"a different state for this routine.");
}
field.fillphysbc(bc_time, ng_diff);
field.apply_bc_funcs(rho_state);
field.apply_bc_funcs(state);
}

PDEFields& m_fields;
Expand Down
2 changes: 1 addition & 1 deletion amr-wind/equation_systems/DiffusionOps.H
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ struct DiffusionOp<
amrex::MLMG mlmg(*this->m_applier);
mlmg.apply(
this->m_pdefields.diff_term.state(tau_state).vec_ptrs(),
this->m_pdefields.field.vec_ptrs());
this->m_pdefields.field.state(fstate).vec_ptrs());
}
};

Expand Down
13 changes: 6 additions & 7 deletions amr-wind/equation_systems/icns/icns_bcop.H
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,20 @@ struct BCOp<ICNS>

/** Apply boundary conditions before a linear solve
*/
void apply_bcs(const FieldState rho_state)
void apply_bcs(const FieldState state)
{
amrex::IntVect ng_diff(1);
auto& field = m_fields.field;
const auto bc_time = (rho_state == FieldState::Old)
? m_time.current_time()
: m_time.new_time();
if ((rho_state != FieldState::Old && rho_state != FieldState::New)) {
auto& field = m_fields.field.state(state);
const auto bc_time = (state == FieldState::Old) ? m_time.current_time()
: m_time.new_time();
if ((state != FieldState::Old && state != FieldState::New)) {
amrex::Abort(
"icns_bcop.H apply_bcs(): a state other than New or Old was "
"used. The method of setting bc_time must be evaluated before "
"using a different state for this routine.\n");
}
field.fillphysbc(bc_time, ng_diff);
field.apply_bc_funcs(rho_state);
field.apply_bc_funcs(state);
}

PDEFields& m_fields;
Expand Down
9 changes: 6 additions & 3 deletions amr-wind/equation_systems/icns/icns_diffusion.H
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ public:
auto& divtau = this->m_pdefields.diff_term.state(tau_state);

amrex::MLMG mlmg(*this->m_applier);
mlmg.apply(divtau.vec_ptrs(), this->m_pdefields.field.vec_ptrs());
mlmg.apply(
divtau.vec_ptrs(),
this->m_pdefields.field.state(fstate).vec_ptrs());
}
};

Expand Down Expand Up @@ -162,7 +164,8 @@ public:
}

amrex::MLMG mlmg(*m_applier_scalar);
mlmg.apply(divtau.vec_ptrs(), m_pdefields.field.vec_ptrs());
mlmg.apply(
divtau.vec_ptrs(), m_pdefields.field.state(fstate).vec_ptrs());

if (!diff_for_RHS) {
for (int lev = 0; lev < nlevels; ++lev) {
Expand Down Expand Up @@ -390,7 +393,7 @@ public:
}

auto divtau_comp = divtau.subview(i);
auto vel_comp = m_pdefields.field.subview(i);
auto vel_comp = m_pdefields.field.state(fstate).subview(i);

amrex::MLMG mlmg(*m_applier_scalar[i]);
mlmg.apply(divtau_comp.vec_ptrs(), vel_comp.vec_ptrs());
Expand Down
2 changes: 1 addition & 1 deletion amr-wind/equation_systems/sdr/sdr_ops.H
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ struct DiffusionOp<SDR, Scheme> : public DiffSolverIface<typename SDR::MLDiffOp>
amrex::MLMG mlmg(*this->m_applier);
mlmg.apply(
this->m_pdefields.diff_term.state(tau_state).vec_ptrs(),
this->m_pdefields.field.vec_ptrs());
this->m_pdefields.field.state(fstate).vec_ptrs());
}

void
Expand Down
2 changes: 1 addition & 1 deletion amr-wind/equation_systems/tke/tke_ops.H
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ struct DiffusionOp<TKE, Scheme> : public DiffSolverIface<typename TKE::MLDiffOp>
amrex::MLMG mlmg(*this->m_applier);
mlmg.apply(
this->m_pdefields.diff_term.state(tau_state).vec_ptrs(),
this->m_pdefields.field.vec_ptrs());
this->m_pdefields.field.state(fstate).vec_ptrs());
}

void
Expand Down
Loading