Skip to content

Commit

Permalink
Added an option to use latest fields for unsteady solvers. (#644)
Browse files Browse the repository at this point in the history
  • Loading branch information
friedenhe authored May 29, 2024
1 parent e40e2f8 commit eb6d1b3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
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

0 comments on commit eb6d1b3

Please sign in to comment.