Skip to content

Fix adjustableRunTIme bug in the FoamTimeStepper#123

Open
mattfalcone1997 wants to merge 7 commits into
aurora-multiphysics:mainfrom
mattfalcone1997:fix-timestepper-memory-issue
Open

Fix adjustableRunTIme bug in the FoamTimeStepper#123
mattfalcone1997 wants to merge 7 commits into
aurora-multiphysics:mainfrom
mattfalcone1997:fix-timestepper-memory-issue

Conversation

@mattfalcone1997

Copy link
Copy Markdown
Collaborator

Summary

The mooseDeltaT function object is searfched in Foam::Time rather than a reference stored and it is now recreated if it is cleared by Foam::Time::adjustDeltaT

Related Issue

Resolves #122

Checklist

  • Tests have been written for the new/changed behaviour.
  • Documentation/examples have been added/updated for the new changes.

@mattfalcone1997 mattfalcone1997 requested a review from k-collie June 17, 2026 14:48

@k-collie k-collie left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First set of comments, looks good so far

Comment thread include/base/FoamSolver.h
{
}

virtual ~mooseDeltaT() {};

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can remove this now

Comment thread src/base/FoamSolver.C
Comment on lines +180 to +183
// We need the adjustDeltaT function of Foam::Time to be called for adjustableRunTime
// writeControl to work properly. However, it is protected so we must do it through the public
// function setDeltaT. As a result, we save and then reset deltaT to its original value.
//

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain a bit more what side effect of adjustableRunTime is needed for writeControl?

Comment thread include/base/FoamSolver.h
void disable() { _enabled = false; }
Foam::scalar calculateDeltaTFactor(const Foam::scalar time) const
{
if (!_old_desired_dt)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mildly more explicit:

Suggested change
if (!_old_desired_dt)
if (!_old_desired_dt.has_value())

Comment thread src/base/FoamSolver.C
Comment on lines +77 to +78
Foam::functionObjects::mooseDeltaT *
findMooseDeltaT(Foam::Time & time)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this once again be my favourite type?

std::optional<std::reference_wrapper<Foam::functionObjects::mooseDeltaT>>

Comment on lines -94 to -98
// The key idea is that runTime.functionObjects().maxDeltaT() in adjustDeltaT
// loops over the function objects and chooses the minimum, so by having
// a function Object that returns what MOOSE wants, OpenFOAM will use the
// MOOSE time step if it is smaller than what OpenFOAM wants. As a result,
// if MOOSE wants to add a synchronisation step OpenFOAM will also use it too.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is still useful right? Maybe it could go in docstring for mooseDeltaT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

We get memory issues when using writeControl adjustableRunTime; in the controlDict

2 participants