Skip to content

Commit

Permalink
Re arrange read time according to adjustable dt (#298)
Browse files Browse the repository at this point in the history
Co-authored-by: Gerasimos Chourdakis <[email protected]>
  • Loading branch information
davidscn and MakisH authored Nov 28, 2023
1 parent c396868 commit 99421f7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
30 changes: 15 additions & 15 deletions Adapter.C
Original file line number Diff line number Diff line change
Expand Up @@ -363,9 +363,6 @@ void preciceAdapter::Adapter::configure()
// Initialize preCICE and exchange the first coupling data
initialize();

// Read the received coupling data
readCouplingData(runTime_.deltaT().value());

// If checkpointing is required, specify the checkpointed fields
// and write the first checkpoint
if (requiresWritingCheckpoint())
Expand All @@ -382,7 +379,7 @@ void preciceAdapter::Adapter::configure()
// Adjust the timestep for the first iteration, if it is fixed
if (!adjustableTimestep_)
{
adjustSolverTimeStep();
adjustSolverTimeStepAndReadData();
}

// If the solver tries to end before the coupling is complete,
Expand Down Expand Up @@ -443,12 +440,6 @@ void preciceAdapter::Adapter::execute()
readCheckpoint();
}

// Adjust the timestep, if it is fixed
if (!adjustableTimestep_)
{
adjustSolverTimeStep();
}

// Write checkpoint if required
if (requiresWritingCheckpoint())
{
Expand Down Expand Up @@ -476,9 +467,11 @@ void preciceAdapter::Adapter::execute()
}
ACCUMULATE_TIMER(timeInWriteResults_);

// Read the received coupling data from the buffer
// Fits to an implicit Euler
readCouplingData(runTime_.deltaT().value());
// Adjust the timestep, if it is fixed
if (!adjustableTimestep_)
{
adjustSolverTimeStepAndReadData();
}

// If the coupling is not going to continue, tear down everything
// and stop the simulation.
Expand Down Expand Up @@ -507,9 +500,10 @@ void preciceAdapter::Adapter::execute()
return;
}


void preciceAdapter::Adapter::adjustTimeStep()
{
adjustSolverTimeStep();
adjustSolverTimeStepAndReadData();

return;
}
Expand Down Expand Up @@ -599,7 +593,7 @@ void preciceAdapter::Adapter::advance()
return;
}

void preciceAdapter::Adapter::adjustSolverTimeStep()
void preciceAdapter::Adapter::adjustSolverTimeStepAndReadData()
{
DEBUG(adapterInfo("Adjusting the solver's timestep..."));

Expand Down Expand Up @@ -695,6 +689,12 @@ void preciceAdapter::Adapter::adjustSolverTimeStep()
// TODO: Keep this in mind if any relevant problem appears.
const_cast<Time&>(runTime_).setDeltaT(timestepSolver_, false);

DEBUG(adapterInfo("Reading coupling data associated to the calculated time-step size..."));

// Read the received coupling data from the buffer
// Fits to an implicit Euler
readCouplingData(runTime_.deltaT().value());

return;
}

Expand Down
3 changes: 2 additions & 1 deletion Adapter.H
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,8 @@ private:
void writeCouplingData();

//- Adjust the timestep of the solver according to preCICE
void adjustSolverTimeStep();
// and read data associated to the calculated time step length
void adjustSolverTimeStepAndReadData();

//- Determine if the coupling is still happening
bool isCouplingOngoing();
Expand Down
1 change: 1 addition & 0 deletions changelog-entries/298.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Renamed the `adjustSolverTimeStep()` method to `adjustSolverTimeStepAndReadData()`, changing the behavior to always read data at the determined time step size. [#298](https://github.com/precice/openfoam-adapter/pull/298)

0 comments on commit 99421f7

Please sign in to comment.