Skip to content

Commit 61c6593

Browse files
committed
check for fixed dt upon initialization; do other work for consistent dt only when needed
1 parent 89b2ea9 commit 61c6593

File tree

7 files changed

+25
-2
lines changed

7 files changed

+25
-2
lines changed

src/AMRWind.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ void AMRWind::set_timestep_size(const double dt)
9898
m_incflo.sim().time().delta_t() = dt;
9999
}
100100

101+
bool AMRWind::is_fixed_timestep_size()
102+
{
103+
return (!m_incflo.sim().time().adaptive_timestep());
104+
}
105+
101106
void AMRWind::advance_timestep(size_t inonlin) { m_incflo.do_advance(inonlin); }
102107

103108
void AMRWind::post_advance() { m_incflo.post_advance_work(); }

src/AMRWind.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class AMRWind : public ExawindSolver
2727
~AMRWind();
2828
bool is_unstructured() override { return false; }
2929
bool is_amr() override { return true; }
30+
bool is_fixed_timestep_size() override;
3031
int overset_update_interval() override;
3132
int time_index() override;
3233
std::string identifier() override { return "AMR-Wind"; }

src/ExawindSolver.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ class ExawindSolver
113113

114114
virtual bool is_unstructured() { return false; };
115115
virtual bool is_amr() { return false; };
116+
virtual bool is_fixed_timestep_size() = 0;
116117
virtual int overset_update_interval() { return 100000000; };
117118
virtual int time_index() = 0;
118119
virtual std::string identifier() { return "ExawindSolver"; }

src/NaluWind.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@ void NaluWind::set_timestep_size(const double dt)
107107
m_sim.timeIntegrator_->set_time_step(dt);
108108
}
109109

110+
bool NaluWind::is_fixed_timestep_size()
111+
{
112+
return m_sim.timeIntegrator_->get_is_fixed_time_step();
113+
}
114+
110115
void NaluWind::advance_timestep(size_t /*inonlin*/)
111116
{
112117
for (auto* realm : m_sim.timeIntegrator_->realmVec_) {

src/NaluWind.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class NaluWind : public ExawindSolver
5050
~NaluWind();
5151
bool is_unstructured() override { return true; }
5252
bool is_amr() override { return false; }
53+
bool is_fixed_timestep_size() override;
5354
int overset_update_interval() override;
5455
int time_index() override;
5556
std::string identifier() override

src/OversetSimulation.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,13 @@ void OversetSimulation::initialize()
8282
}
8383
m_last_timestep = m_solvers.at(0)->time_index();
8484

85+
// Determine if any of the solvers have adaptive timestepping
86+
for (auto& ss : m_solvers) {
87+
m_fixed_dt = m_fixed_dt && ss->is_fixed_timestep_size();
88+
}
89+
MPI_Allreduce(MPI_IN_PLACE, &m_fixed_dt, 1, MPI_C_BOOL, MPI_LAND, m_comm);
90+
91+
// Should be able to remove this because of the Allreduce, right?
8592
MPI_Barrier(m_comm);
8693
m_initialized = true;
8794
}
@@ -153,12 +160,12 @@ void OversetSimulation::run_timesteps(
153160
double dt{1e8};
154161
for (auto& ss : m_solvers) {
155162
ss->call_pre_advance_stage0(inonlin, increment_timer);
156-
if (inonlin < 1) {
163+
if (inonlin < 1 && !m_fixed_dt) {
157164
dt = std::min(dt, ss->call_get_timestep_size());
158165
}
159166
}
160167

161-
if (inonlin < 1) {
168+
if (inonlin < 1 && !m_fixed_dt) {
162169
MPI_Allreduce(
163170
MPI_IN_PLACE, &dt, 1, MPI_DOUBLE, MPI_MIN, m_comm);
164171
for (auto& ss : m_solvers) ss->call_set_timestep_size(dt);

src/OversetSimulation.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ class OversetSimulation
3030
int m_overset_update_interval{100000000};
3131
//! Last timestep run during this simulation
3232
int m_last_timestep{0};
33+
//! Flag indicating whether all solvers use fixed dt. If any solver uses
34+
//! adaptive dt, then this flag will be false
35+
bool m_fixed_dt{true};
3336
//! Flag indicating whether initialization tasks have been performed
3437
bool m_initialized{false};
3538
//! Flag indicating if complementary comms have been initialized

0 commit comments

Comments
 (0)