Skip to content

Commit

Permalink
Perform prepare_boundaries at correct times (#1302)
Browse files Browse the repository at this point in the history
* add fillphysbc for nph_fields in prepare_boundaries
* replace intended interp time with actual interp time
* replace hard-coded new_time() in ABLFillInflow with actual time argument
  • Loading branch information
mbkuhn authored Oct 21, 2024
1 parent eec57d1 commit 2aa7fcd
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 15 deletions.
4 changes: 2 additions & 2 deletions amr-wind/equation_systems/PDEBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ void PDEMgr::prepare_boundaries()
field_ops::copy(
nph_field, new_field, 0, 0, new_field.num_comp(),
new_field.num_grow());
// Insert fill physical boundary condition call here
nph_field.fillphysbc(nph_time);
}
for (auto& eqn : scalar_eqns()) {
eqn->fields().field.advance_states();
Expand All @@ -125,7 +125,7 @@ void PDEMgr::prepare_boundaries()
field_ops::copy(
nph_field, new_field, 0, 0, new_field.num_comp(),
new_field.num_grow());
// Insert fill physical boundary condition call here
nph_field.fillphysbc(nph_time);
}
}

Expand Down
5 changes: 1 addition & 4 deletions amr-wind/wind_energy/ABLBoundaryPlane.H
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,7 @@ public:

bool is_data_newer_than(const amrex::Real time) const
{
// Will replace with m_in_data.tinterp()
return (m_intended_interp_time - time > 1e-12);
return (m_in_data.tinterp() - time > 1e-12);
}

io_mode mode() const { return m_io_mode; }
Expand Down Expand Up @@ -195,8 +194,6 @@ private:
//! Start outputting after this time
amrex::Real m_out_start_time{0.0};

amrex::Real m_intended_interp_time{0.0};

#ifdef AMR_WIND_USE_NETCDF
//! NetCDF time output counter
size_t m_out_counter{0};
Expand Down
5 changes: 1 addition & 4 deletions amr-wind/wind_energy/ABLBoundaryPlane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -767,15 +767,13 @@ void ABLBoundaryPlane::read_file(const bool nph_target_time)
}

// populate planes and interpolate
const amrex::Real time = m_time.new_time();
const amrex::Real conditional_time =
const amrex::Real time =
m_time.new_time() + (nph_target_time ? 0.5 : 0.0) *
(m_time.current_time() - m_time.new_time());
AMREX_ALWAYS_ASSERT((m_in_times[0] <= time) && (time < m_in_times.back()));

// return early if current data files can still be interpolated in time
if ((m_in_data.tn() <= time) && (time < m_in_data.tnp1())) {
m_intended_interp_time = conditional_time;
m_in_data.interpolate(time);
return;
}
Expand Down Expand Up @@ -871,7 +869,6 @@ void ABLBoundaryPlane::read_file(const bool nph_target_time)
}
}

m_intended_interp_time = conditional_time;
m_in_data.interpolate(time);
}

Expand Down
7 changes: 2 additions & 5 deletions amr-wind/wind_energy/ABLFillInflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void ABLFillInflow::fillphysbc(
FieldFillPatchOps<FieldBCDirichlet>::fillphysbc(
lev, time, mfab, nghost, fstate);

m_bndry_plane.populate_data(lev, m_time.new_time(), m_field, mfab);
m_bndry_plane.populate_data(lev, time, m_field, mfab);
}

void ABLFillInflow::fillpatch_sibling_fields(
Expand Down Expand Up @@ -105,10 +105,7 @@ void ABLFillInflow::fillpatch_sibling_fields(

if (!plane_data_unchanged) {
for (int i = 0; i < static_cast<int>(mfabs.size()); i++) {
// use new_time to populate boundary data instead of half-time
// to avoid interpolating from precursor data
m_bndry_plane.populate_data(
lev, m_time.new_time(), m_field, *mfabs[i], 0, i);
m_bndry_plane.populate_data(lev, time, m_field, *mfabs[i], 0, i);
}
}
}
Expand Down

0 comments on commit 2aa7fcd

Please sign in to comment.