Go to the documentation of this file.
49 laminarTransportPtr_(nullptr),
50 turbulencePtr_(nullptr),
51 daTurbulenceModelPtr_(nullptr),
52 daFvSourcePtr_(nullptr),
65 Info <<
"Initializing fields for DAPimpleFoam" << endl;
80 if (
mode_ ==
"hybridAdjoint")
84 daOptionPtr_->getSubDictOption<label>(
"unsteadyAdjoint",
"nTimeInstances");
87 daOptionPtr_->getSubDictOption<scalar>(
"unsteadyAdjoint",
"periodicity");
91 FatalErrorIn(
"") <<
"periodicity <= 0!" << abort(FatalError);
94 else if (
mode_ ==
"timeAccurateAdjoint")
98 daOptionPtr_->getSubDictOption<label>(
"unsteadyAdjoint",
"nTimeInstances");
102 label maxNTimeInstances = round(endTime / deltaT) + 1;
105 FatalErrorIn(
"") <<
"nTimeInstances in timeAccurateAdjoint is not equal to "
106 <<
"the maximal possible value!" << abort(FatalError);
110 if (
mode_ ==
"hybridAdjoint" ||
mode_ ==
"timeAccurateAdjoint")
115 FatalErrorIn(
"") <<
"nTimeInstances <= 0!" << abort(FatalError);
135 if (
allOptions.subDict(
"fvSource").toc().size() != 0)
138 Info <<
"Computing fvSource" << endl;
139 word sourceName =
allOptions.subDict(
"fvSource").toc()[0];
140 word fvSourceType =
allOptions.subDict(
"fvSource").subDict(sourceName).getWord(
"type");
165 daOptionPtr_->setOption<word>(
"runStatus",
"solvePrimal");
170 Info <<
"\nStarting time loop\n"
192 label printInterval =
daOptionPtr_->getOption<label>(
"printIntervalUnsteady");
193 label printToScreen = 0;
194 label timeInstanceI = 0;
196 if (
mode_ ==
"timeAccurateAdjoint")
207 Info <<
"Time = " <<
runTime.timeName() << nl << endl;
228 #include "CourantNo.H"
239 Info <<
"ExecutionTime = " <<
runTime.elapsedCpuTime() <<
" s"
240 <<
" ClockTime = " <<
runTime.elapsedClockTime() <<
" s"
246 if (
mode_ ==
"hybridAdjoint")
251 if (
mode_ ==
"timeAccurateAdjoint")
void writeFailedMesh()
write the failed mesh to disk
const dictionary & allOptions
label loop(Time &runTime)
return whether to loop the primal solution, similar to runTime::loop() except we don't do file IO
autoPtr< DACheckMesh > daCheckMeshPtr_
DACheckMesh object pointer.
forAll(pseudoP.boundaryField(), patchI)
autoPtr< DAModel > daModelPtr_
DAModel pointer.
autoPtr< DAIndex > daIndexPtr_
DAIndex pointer.
List< label > runTimeIndexAllInstances_
the runtime index for all instances (unsteady)
singlePhaseTransportModel & laminarTransport
autoPtr< DAOption > daOptionPtr_
DAOption pointer.
void saveTimeInstanceFieldHybrid(label &timeInstanceI)
save primal variable to time instance list for hybrid adjoint (unsteady)
label hasFvSource_
whether to have fvSource term
volScalarField & fvSource
void calcPrimalResidualStatistics(const word mode, const label writeRes=0)
calculate the norms of all residuals and print to screen
DAPimpleFoam(char *argsAll, PyObject *pyOptions)
label isPrintTime(const Time &runTime, const label printInterval) const
word mode_
whether the hybrid adjoint or time accurate adjoint is active
autoPtr< DALinearEqn > daLinearEqnPtr_
DALinearEqn pointer.
void saveTimeInstanceFieldTimeAccurate(label &timeInstanceI)
save primal variable to time instance list for time accurate adjoint (unsteady)
virtual label solvePrimal(const Vec xvVec, Vec wVec)
solve the primal equations
static autoPtr< DAFvSource > New(const word modelType, const fvMesh &mesh, const DAOption &daOption, const DAModel &daModel, const DAIndex &daIndex)
virtual void initSolver()
initialize fields and variables
List< scalar > runTimeAllInstances_
the runtime value for all instances (unsteady)
void setDAObjFuncList()
initialize DASolver::daObjFuncPtrList_ one needs to call this before calling printAllObjFuncs
void printAllObjFuncs()
calculate the values of all objective functions and print them to screen
List< dictionary > objFuncsAllInstances_
objective function for all instances (unsteady)
scalar primalMinRes_
the maximal residual for primal solution
autoPtr< DATurbulenceModel > daTurbulenceModelPtr_
DATurbulenceModel pointer.
autoPtr< Time > runTimePtr_
runTime pointer
autoPtr< fvMesh > meshPtr_
fvMesh pointer
defineTypeNameAndDebug(DAFvSource, 0)
addToRunTimeSelectionTable(DAFvSource, DAFvSourceActuatorDisk, dictionary)
void ofField2StateVec(Vec stateVec) const
set the state vector based on the latest fields in OpenFOAM
label checkMesh() const
check the mesh quality and return meshOK
autoPtr< DAFvSource > daFvSourcePtr_
DASource pointer.
label nTimeInstances_
number of time instances for hybird adjoint (unsteady)
List< List< scalar > > stateAllInstances_
state variable list for all instances (unsteady)
scalar periodicity_
periodicity of oscillating flow variables (unsteady)
void pointVec2OFMesh(const Vec xvVec) const
assign the points in fvMesh of OpenFOAM based on the point vector
List< List< scalar > > stateBoundaryAllInstances_
state boundary variable list for all instances (unsteady)