Skip to content

Commit

Permalink
Fix time handling for restarts
Browse files Browse the repository at this point in the history
  • Loading branch information
ndevelder committed Jul 28, 2023
1 parent 2913050 commit c8d87b7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 4 additions & 0 deletions amr-wind/utilities/sampling/DTUSpinnerSampler.H
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,12 @@ public:
const size_t /*unused*/) const override;

private:
// Number of subsamples in this timestep
int m_ns{1};

// Max number of subsamples in all timesteps
int m_ntotal{1};

int m_update_count{0};
amrex::Real radtodeg{180.0 / M_PI};
amrex::Real pi{M_PI};
Expand Down
7 changes: 3 additions & 4 deletions amr-wind/utilities/sampling/DTUSpinnerSampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,23 +319,22 @@ void DTUSpinnerSampler::update_sampling_locations()
}
#endif

// amrex::Real time = m_sim.time().current_time();
// Sampling called in post_advance so time should be new_time
// Not current_time()
amrex::Real time = m_sim.time().new_time();
amrex::Real start_time = m_sim.time().start_time();
amrex::Real dt_sim = m_sim.time().deltaT();
amrex::Real ts_diff = time - m_time_sampling;
const amrex::Real dt_s = m_scan_time / m_num_samples;

// amrex::Print() << "Running update sampling locations at time: " << time
// << std::endl;

// Initialize the sampling time to the first time in the simulation
if (time == start_time && m_update_count == 0) {
m_time_sampling = time;
m_hub_location_init = m_hub_location;
}

amrex::Real ts_diff = time - m_time_sampling;

// Correction for time mismatch
int time_corr = (ts_diff > dt_s) ? int(ts_diff / dt_s) : 0;

Expand Down

0 comments on commit c8d87b7

Please sign in to comment.