Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re arrange read time according to adjustable dt #298

Merged
merged 13 commits into from
Nov 28, 2023
30 changes: 15 additions & 15 deletions Adapter.C
Original file line number Diff line number Diff line change
Expand Up @@ -345,9 +345,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 @@ -364,7 +361,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 @@ -425,12 +422,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 @@ -458,9 +449,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 @@ -489,9 +482,10 @@ void preciceAdapter::Adapter::execute()
return;
}


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

return;
}
Expand Down Expand Up @@ -581,7 +575,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 @@ -677,6 +671,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 @@ -270,7 +270,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)