Skip to content

Commit

Permalink
Renaming fixed point iteration indices
Browse files Browse the repository at this point in the history
  • Loading branch information
itopcuoglu committed Oct 11, 2024
1 parent fca3d75 commit e00446a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 21 deletions.
7 changes: 4 additions & 3 deletions amr-wind/incflo.H
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public:
bool regrid_and_update();
void pre_advance_stage1();
void pre_advance_stage2();
void do_advance(const int inonlin);
void do_advance(const int ifixed_point_iteration);
void advance(int inonlin);
void prescribe_advance();
void post_advance_work();
Expand Down Expand Up @@ -133,8 +133,9 @@ public:
void ComputeDt(bool explicit_diffusion);
void ComputePrescribeDt();

void
ApplyPredictor(bool incremental_projection = false, const int inonlin = 0);
void ApplyPredictor(
bool incremental_projection = false,
const int ifixed_point_iteration = 0);
void ApplyCorrector();
void ApplyPrescribeStep();

Expand Down
13 changes: 7 additions & 6 deletions amr-wind/incflo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,9 @@ void incflo::Evolve()

amrex::Real time1 = amrex::ParallelDescriptor::second();
// Advance to time t + dt
for (int inonlin = 0; inonlin < m_adv_iters; ++inonlin)
do_advance(inonlin);
for (int iadvection_iteration = 0; iadvection_iteration < m_adv_iters;
++iadvection_iteration)
do_advance(iadvection_iteration);

amrex::Print() << std::endl;
amrex::Real time2 = amrex::ParallelDescriptor::second();
Expand Down Expand Up @@ -310,17 +311,17 @@ void incflo::Evolve()
}
}

void incflo::do_advance(const int inonlin)
void incflo::do_advance(const int ifixed_point_iteration)
{
if (m_sim.has_overset()) {
m_ovst_ops.pre_advance_work();
}
if (m_prescribe_vel && inonlin == 0) {
if (m_prescribe_vel && ifixed_point_iteration == 0) {
prescribe_advance();
} else {
amrex::Print() << "Iteration " << inonlin
amrex::Print() << "Iteration " << ifixed_point_iteration
<< " in advection iteration loop" << std::endl;
advance(inonlin);
advance(ifixed_point_iteration);
}
if (m_sim.has_overset()) {
m_ovst_ops.post_advance_work();
Expand Down
26 changes: 15 additions & 11 deletions amr-wind/incflo_advance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,19 @@ void incflo::pre_advance_stage2()
*
* \callgraph
*/
void incflo::advance(const int inonlin)
void incflo::advance(const int ifixed_point_iteration)
{
BL_PROFILE("amr-wind::incflo::advance");
if (inonlin == 0) {
if (ifixed_point_iteration == 0) {
m_sim.pde_manager().advance_states();
}

ApplyPredictor(false, inonlin);
ApplyPredictor(false, ifixed_point_iteration);

if (!m_use_godunov) {
AMREX_ALWAYS_ASSERT_WITH_MESSAGE(
inonlin == 0, "Advection iterations are not supported for MOL");
ifixed_point_iteration == 0,
"Advection iterations are not supported for MOL");

ApplyCorrector();
}
Expand Down Expand Up @@ -169,7 +170,8 @@ void incflo::advance(const int inonlin)
* <li> \ref incflo::ApplyProjection "Apply projection"
* </ol>
*/
void incflo::ApplyPredictor(bool incremental_projection, const int inonlin)
void incflo::ApplyPredictor(
bool incremental_projection, const int ifixed_point_iteration)
{
BL_PROFILE("amr-wind::incflo::ApplyPredictor");
// We use the new time value for things computed on the "*" state
Expand All @@ -193,7 +195,7 @@ void incflo::ApplyPredictor(bool incremental_projection, const int inonlin)
const auto& density_old = density_new.state(amr_wind::FieldState::Old);
auto& density_nph = density_new.state(amr_wind::FieldState::NPH);

if (inonlin > 0) {
if (ifixed_point_iteration > 0) {
icns().fields().field.fillpatch(m_time.current_time());
// Get n + 1/2 velocity
amr_wind::field_ops::lincomb(
Expand Down Expand Up @@ -281,8 +283,9 @@ void incflo::ApplyPredictor(bool incremental_projection, const int inonlin)
}

// Extrapolate and apply MAC projection for advection velocities
const auto fstate_preadv =
(inonlin == 0) ? amr_wind::FieldState::Old : amr_wind::FieldState::NPH;
const auto fstate_preadv = (ifixed_point_iteration == 0)
? amr_wind::FieldState::Old
: amr_wind::FieldState::NPH;
icns().pre_advection_actions(fstate_preadv);

// For scalars only first
Expand Down Expand Up @@ -351,8 +354,9 @@ void incflo::ApplyPredictor(bool incremental_projection, const int inonlin)
}

// With scalars computed, compute advection of momentum
const auto fstate =
(inonlin == 0) ? amr_wind::FieldState::Old : amr_wind::FieldState::NPH;
const auto fstate = (ifixed_point_iteration == 0)
? amr_wind::FieldState::Old
: amr_wind::FieldState::NPH;
icns().compute_advection_term(fstate);

// *************************************************************************************
Expand Down Expand Up @@ -415,7 +419,7 @@ void incflo::ApplyPredictor(bool incremental_projection, const int inonlin)
PrintMaxVelLocations("after nodal projection");
}
// ScratchField to store the old np1
if (inonlin > 0 && m_verbose > 0) {
if (ifixed_point_iteration > 0 && m_verbose > 0) {
auto vel_np1_old = m_repo.create_scratch_field(
"vel_np1_old", AMREX_SPACEDIM, 1, amr_wind::FieldLoc::CELL);

Expand Down
2 changes: 1 addition & 1 deletion amr-wind/utilities/console_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ void print_nonlinear_residual(
}
}

amrex::Print() << "Norm of change over advection iterations in u: "
amrex::Print() << "Norm of change over fixed point iterations in u: "
<< rms_vel[0] << ", v: " << rms_vel[1]
<< ", w: " << rms_vel[2] << std::endl;
}
Expand Down

0 comments on commit e00446a

Please sign in to comment.