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

Added an option to use latest fields for unsteady solvers. #644

Merged
merged 1 commit into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dafoam/pyDAFoam.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ def __init__(self):
"PCMatUpdateInterval": 1,
"reduceIO": True,
"additionalOutput": ["None"],
"readZeroFields": True,
}

## At which iteration should we start the averaging of objective functions.
Expand Down
12 changes: 8 additions & 4 deletions src/adjoint/DASolver/DAPimpleFoam/DAPimpleFoam.C
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,15 @@ label DAPimpleFoam::solvePrimal(
// change the run status
daOptionPtr_->setOption<word>("runStatus", "solvePrimal");

// we need to read in the states from the 0 folder every time we start the primal
// here we read in all time levels
runTime.setTime(0.0, 0);
this->readStateVars(0.0, 0);
this->readStateVars(0.0, 1);
// if readZeroFields, we need to read in the states from the 0 folder every time
// we start the primal here we read in all time levels
label readZeroFields = daOptionPtr_->getAllOptions().subDict("unsteadyAdjoint").getLabel("readZeroFields");
if (readZeroFields)
{
this->readStateVars(0.0, 0);
this->readStateVars(0.0, 1);
}

// call correctNut, this is equivalent to turbulence->validate();
daTurbulenceModelPtr_->updateIntermediateVariables();
Expand Down
12 changes: 8 additions & 4 deletions src/adjoint/DASolver/DARhoPimpleFoam/DARhoPimpleFoam.C
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,15 @@ label DARhoPimpleFoam::solvePrimal(
// change the run status
daOptionPtr_->setOption<word>("runStatus", "solvePrimal");

// we need to read in the states from the 0 folder every time we start the primal
// here we read in all time levels
runTime.setTime(0.0, 0);
this->readStateVars(0.0, 0);
this->readStateVars(0.0, 1);
// if readZeroFields, we need to read in the states from the 0 folder every time
// we start the primal here we read in all time levels
label readZeroFields = daOptionPtr_->getAllOptions().subDict("unsteadyAdjoint").getLabel("readZeroFields");
if (readZeroFields)
{
this->readStateVars(0.0, 0);
this->readStateVars(0.0, 1);
}

// call correctNut, this is equivalent to turbulence->validate();
daTurbulenceModelPtr_->updateIntermediateVariables();
Expand Down
Loading