Go to the documentation of this file.
49 laminarTransportPtr_(nullptr),
50 turbulencePtr_(nullptr),
51 daTurbulenceModelPtr_(nullptr),
52 daFvSourcePtr_(nullptr),
53 fvSourcePtr_(nullptr),
71 Info <<
"Initializing fields for DAPimpleDyMFoam" << endl;
77 const word turbModelName(
80 "turbulenceProperties",
81 mesh.time().constant(),
94 if (
allOptions.subDict(
"fvSource").toc().size() != 0)
97 Info <<
"Computing fvSource" << endl;
98 word sourceName =
allOptions.subDict(
"fvSource").toc()[0];
99 word fvSourceType =
allOptions.subDict(
"fvSource").subDict(sourceName).getWord(
"type");
106 dictionary dvSubDict =
daOptionPtr_->getAllOptions().subDict(
"inputInfo");
107 forAll(dvSubDict.toc(), idxI)
109 word dvName = dvSubDict.toc()[idxI];
110 if (dvSubDict.subDict(dvName).getWord(
"type") ==
"volCoord")
136 Info <<
"\nStarting time loop\n"
139 label pimplePrintToScreen = 0;
142 label reduceIO =
daOptionPtr_->getAllOptions().subDict(
"unsteadyAdjoint").getLabel(
"reduceIO");
143 wordList additionalOutput;
146 daOptionPtr_->getAllOptions().subDict(
"unsteadyAdjoint").readEntry<wordList>(
"additionalOutput", additionalOutput);
149 scalar endTime =
runTime.endTime().value();
150 scalar deltaT =
runTime.deltaT().value();
151 label nInstances = round(endTime / deltaT);
154 label regModelFail = 0;
156 for (label iter = 1; iter <= nInstances; iter++)
167 Info <<
"Time = " <<
runTime.timeName() << nl << endl;
168 #include "CourantNo.H"
176 pimplePrintToScreen = 1;
180 pimplePrintToScreen = 0;
185 pointIOField readPoints(
195 mesh.movePoints(readPoints);
196 U.correctBoundaryConditions();
210 dimensionedScalar(
"rAUf", dimTime, 1),
239 regModelFail += fail;
254 if (reduceIO && iter < nInstances)
266 if (regModelFail != 0)
285 surfaceVectorField&
Uf,
286 const volVectorField&
U,
287 const surfaceScalarField&
phi)
289 const fvMesh&
mesh =
U.mesh();
293 Uf = fvc::interpolate(
U);
294 surfaceVectorField n(
mesh.Sf() /
mesh.magSf());
301 surfaceScalarField&
phi)
303 const fvMesh&
mesh =
U.mesh();
307 volVectorField::Boundary& Ubf =
U.boundaryFieldRef();
308 surfaceScalarField::Boundary& phibf =
309 phi.boundaryFieldRef();
313 if (Ubf[patchi].fixesValue())
315 Ubf[patchi].initEvaluate();
321 if (Ubf[patchi].fixesValue())
323 Ubf[patchi].evaluate();
325 phibf[patchi] = Ubf[patchi] &
mesh.Sf().boundaryField()[patchi];
333 surfaceScalarField&
phi,
334 const volScalarField&
p,
335 const dimensionedScalar& rAUf,
340 const fvMesh&
mesh =
U.mesh();
347 p.boundaryField().size(),
348 zeroGradientFvPatchScalarField::typeName);
351 forAll(
p.boundaryField(), patchi)
353 if (
p.boundaryField()[patchi].fixesValue())
355 pcorrTypes[patchi] = fixedValueFvPatchScalarField::typeName;
359 volScalarField pcorr(
365 dimensionedScalar(
p.dimensions(), Zero),
368 if (pcorr.needReference())
372 fvc::makeAbsolute(
phi,
U);
375 mesh.setFluxRequired(pcorr.name());
377 while (
pimple.correctNonOrthogonal())
381 fvScalarMatrix pcorrEqn(
382 fvm::laplacian(rAUf, pcorr) == fvc::div(
phi));
384 pcorrEqn.setReference(0, 0);
387 mesh.solver(pcorr.select(
pimple.finalNonOrthogonalIter())));
389 if (
pimple.finalNonOrthogonalIter())
391 phi -= pcorrEqn.flux();
label printToScreen_
whether to print primal information to the screen
void initDynamicMesh()
resetting internal info in fvMesh, which is needed for multiple primal runs
autoPtr< DARegression > daRegressionPtr_
DARegression pointer.
autoPtr< DAModel > daModelPtr_
DAModel pointer.
autoPtr< DAIndex > daIndexPtr_
DAIndex pointer.
label primalFinalTimeIndex_
the final time index from the primal solve. for steady state cases it can converge before endTime
void correctUphiBCsDF(volVectorField &U, surfaceScalarField &phi)
custom correctUphiBCs for DAFoam
addToRunTimeSelectionTable(DAFunction, DAFunctionForce, dictionary)
autoPtr< DAOption > daOptionPtr_
DAOption pointer.
volScalarField & fvSource
static autoPtr< DATurbulenceModel > New(const word modelType, const fvMesh &mesh, const DAOption &daOption)
label printIntervalUnsteady_
how frequent do you want to print the primal info default is every 100 steps
label isPrintTime(const Time &runTime, const label printInterval) const
bool moveMeshOuterCorrectors
void CorrectPhiDF(volVectorField &U, surfaceScalarField &phi, const volScalarField &p, const dimensionedScalar &rAUf, pimpleControlDF &pimple)
custom CorrectPhi for DAFoam
autoPtr< DAFvSource > daFvSourcePtr_
DASource pointer.
label validateStates()
check if the state variables have valid values
autoPtr< DATurbulenceModel > daTurbulenceModelPtr_
DATurbulenceModel pointer.
label hasFvSource_
whether to have fvSource term
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
virtual label solvePrimal()
solve the primal equations
defineTypeNameAndDebug(DAFunction, 0)
void correctUfPimpleDyM(surfaceVectorField &Uf, const volVectorField &U, const surfaceScalarField &phi)
custom CorrectUf function for DAFoam
MRF makeRelative(fvc::interpolate(rho), phiHbyA)
const dictionary & allOptions
DAPimpleDyMFoam(char *argsAll, PyObject *pyOptions)
singlePhaseTransportModel & laminarTransport
label hasTField_
whether to have the temperature field
label reduceIOWriteMesh_
whether to write mesh for the reduceIO
autoPtr< Time > runTimePtr_
runTime pointer
autoPtr< fvMesh > meshPtr_
fvMesh pointer
static label isFieldReadable(const fvMesh &mesh, const word fieldName, const word fieldType)
void updateInputFieldUnsteady()
assign the inputFieldUnsteady values to the OF field vars
void writeAdjStates(const label writeMesh, const wordList &additionalOutput)
write state variables that are NO_WRITE to disk
void printElapsedTime(const Time &runTime, const label printToScreen)
void calcAllFunctions(label print=0)
calculate the values of all objective functions and print them to screen