44 incompressibleAdjointSolver,
75 mag(
contErr)().weightedAverage(mesh_.V()).value();
83 <<
", cumulative = " << cumulativeContErr_
90 adjointSensitivity_->accumulateIntegrand(scalar(1));
96 Foam::adjointSimple::adjointSimple
99 const word& managerType,
101 const word& primalSolverName,
102 const word& solverName
114 adjointVars_(allocateVars()),
115 cumulativeContErr_(
Zero)
143 solverControl_().incrementIter();
144 if (solverControl_().performIter())
155 Info<<
"Time = " << mesh_.time().timeName() <<
"\n" <<
endl;
169 adjointVars_.adjointTurbulence();
170 const label& paRefCell = solverControl_().pRefCell();
171 const scalar& paRefValue = solverControl_().pRefValue();
191 objectiveManager_.addSource(UaEqn);
194 ATCModel_->addATC(UaEqn);
197 addMomentumSource(UaEqn);
220 tmp<volScalarField> rAtUa(rAUa);
222 if (solverControl_().consistent())
224 rAtUa = 1.0/(1.0/rAUa - UaEqn.H1());
236 while (solverControl_().correctNonOrthogonal())
245 addPressureSource(
paEqn);
252 if (solverControl_().finalNonOrthogonalIter())
272 if (solverControl_().printMaxMags())
276 Info<<
"Max mag (" << Ua.
name() <<
") = " << maxUa.value() <<
endl;
284 solverControl_().write();
287 adjointVars_.computeMeanFields();
290 mesh_.time().printExecutionTime(
Info);
300 while (solverControl_().loop())
311 return solverControl_().loop();
318 adjointVars_.restoreInitValues();
319 adjointVars_.resetMeanFields();
340 objectiveManager_.updateAndWrite();
348 adjointVars_.adjointTurbulence();
350 adjointTurbulence().getAdjointTMVariablesBaseNames();
351 label nTurbVars(turbVarNames.
size());
352 if (adjointTurbulence().includeDistance())
360 names[varID++] = adjointVars_.UaInst().name();
361 for (
const word& turbName : turbVarNames)
363 names[varID++] = turbName;
365 if (adjointTurbulence().includeDistance())
368 word(useSolverNameForFields() ?
"da" + solverName_ :
"da");
372 const word
dictName(
"topOSource" + solverName_);
374 optionDict.add<word>(
"type",
"topOSource");
376 optionDict.add<word>(
"function",
"linear");
377 optionDict.add<word>(
"interpolationField",
"beta");
387 os.
writeEntry(
"averageIter", solverControl_().averageIter());
const bool momentumPredictor
virtual void mainIter()
The main SIMPLE iter.
void correct(GeometricField< Type, PatchField, GeoMesh > &field)
Apply correction to field.
virtual void addTopOFvOptions() const
Add fvOptions for TopO.
const Type & value() const noexcept
Return const reference to value.
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh >> grad(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
void size(const label n)
Older name for setAddressableSize.
fvMatrix< scalar > fvScalarMatrix
const volScalarField & paInst() const
Return const reference to pressure.
List< word > names(const UPtrList< T > &list, const UnaryMatchPredicate &matcher)
List of names generated by calling name() for each list item and filtered for matches.
virtual void updatePrimalBasedQuantities()
Update primal based quantities related to the objective functions.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
A list of keyword definitions, which are a keyword followed by a number of values (eg...
virtual const incompressibleAdjointVars & getAdjointVars() const
Access to the incompressible adjoint variables set.
virtual tmp< fvVectorMatrix > divDevReff(volVectorField &U) const =0
Return the diffusion term for the momentum equation.
const word & name() const noexcept
Return the object name.
tmp< surfaceScalarField > flux(const volVectorField &vvf)
Return the face-flux field obtained from the given volVectorField.
virtual void preLoop()
Functions to be called before loop.
tmp< GeometricField< Type, fvPatchField, volMesh > > div(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
const fvMesh & mesh() const
Return the solver mesh.
void allocateSensitivities()
Allocate the sensitivity derivatives.
void setReference(const label celli, const Type &value, const bool forceReference=false)
Set reference level for solution.
autoPtr< ATCModel > ATCModel_
Adjoint Transpose Convection options.
const word dictName("faMeshDefinition")
autoPtr< SIMPLEControl > solverControl_
Solver control.
Ostream & endl(Ostream &os)
Add newline and flush stream.
virtual void updatePrimalBasedQuantities()
Update primal based quantities, e.g. the primal fields in adjoint turbulence models.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
#define addProfiling(Name,...)
Define profiling trigger with specified name and description string. The description is generated by ...
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
autoPtr< variablesSet > vars_
Base variableSet pointer.
GeometricField< vector, fvPatchField, volMesh > volVectorField
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
bool adjustPhi(surfaceScalarField &phi, const volVectorField &U, volScalarField &p)
Adjust the balance of fluxes to obey continuity.
Find the reference cell nearest (in index) to the given cell but which is not on a cyclic...
Macros for easy insertion into run-time selection tables.
incompressibleAdjointVars & allocateVars()
Allocate incompressibleAdjointVars and return reference to be used for convenience in the rest of the...
Class including all adjoint fields for incompressible flows.
Base class for incompressibleAdjoint solvers.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
volScalarField::Internal contErr((fvc::ddt(rho)+fvc::div(rhoPhi) -(fvOptions(alpha1, mixture.thermo1().rho())&rho1) -(fvOptions(alpha2, mixture.thermo2().rho())&rho2))())
virtual bool loop()
Looper (advances iters, time step)
static autoPtr< option > New(const word &name, const dictionary &dict, const fvMesh &mesh)
Return a reference to the selected fvOption model.
virtual bool writeData(Ostream &os) const
Write the sensitivity derivatives.
virtual void correct()
Solve the adjoint turbulence equations.
incompressibleVars & primalVars_
Primal variable set.
incompressibleAdjointVars & adjointVars_
Reference to incompressibleAdjointVars.
virtual void preIter()
Steps to be executed before each main SIMPLE iteration.
A class for handling words, derived from Foam::string.
A special matrix type and solver, designed for finite volume solutions of scalar equations. Face addressing is used to make all matrix assembly and solution loops vectorise.
tmp< volVectorField > constrainHbyA(const tmp< volVectorField > &tHbyA, const volVectorField &U, const volScalarField &p)
const dictionary & dict() const
Return the solver dictionary.
void continuityErrors()
Compute continuity errors.
SolverPerformance< Type > solve(faMatrix< Type > &, const dictionary &solverControls)
Solve returning the solution statistics given convergence tolerance.
virtual void postIter()
Steps to be executed before each main SIMPLE iteration.
void constrain(fvMatrix< Type > &eqn)
Apply constraints to equation.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
SolverPerformance< Type > solve(const dictionary &)
Solve returning the solution statistics.
static autoPtr< ATCModel > New(const fvMesh &mesh, const incompressibleVars &primalVars, const incompressibleAdjointVars &adjointVars, const dictionary &dict)
Return a reference to the selected turbulence model.
tmp< fvMatrix< Type > > div(const surfaceScalarField &flux, const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
Type gMax(const FieldField< Field, Type > &f)
OBJstream os(runTime.globalPath()/outputName)
virtual void solve()
Main control loop.
defineTypeNameAndDebug(combustionModel, 0)
static tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > interpolate(const GeometricField< Type, fvPatchField, volMesh > &tvf, const surfaceScalarField &faceFlux, Istream &schemeData)
Interpolate field onto faces using scheme given by Istream.
virtual void addPressureSource(fvScalarMatrix &matrix)
Source terms for the continuity equation.
List< word > wordList
List of word.
void relax(const scalar alpha)
Relax field (for steady-state solution).
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
tmp< fvMatrix< Type > > laplacian(const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
Mesh data needed to do the Finite Volume discretisation.
Solution of the adjoint PDEs for incompressible, steady-state flows.
void push_back(T *ptr)
Append an element to the end of the list.
Boundary & boundaryFieldRef(const bool updateAccessTime=true)
Return a reference to the boundary field.
virtual bool writeData(Ostream &os) const
Write average iteration.
void correctBoundaryConditions()
Correct boundary field.
SIMPLE control class to supply convergence information/checks for the SIMPLE loop.
For cases which do no have a pressure boundary adjust the balance of fluxes to obey continuity...
messageStream Info
Information stream (stdout output on master, null elsewhere)
virtual void preCalculateSensitivities()
Accumulate the sensitivities integrand before calculating them.
fvScalarMatrix paEqn(fvm::d2dt2(pa) - sqr(c0) *fvc::laplacian(pa))
fvMesh & mesh_
Reference to the mesh database.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > flux() const
Return the face-flux field from the matrix.
void boundaryManipulate(typename GeometricField< Type, fvPatchField, volMesh >::Boundary &values)
Manipulate based on a boundary field.
dimensioned< Type > weightedAverage(const DimensionedField< scalar, GeoMesh > &weightField) const
Calculate and return weighted average.
List of finite volume options.
virtual void solveIter()
Execute one iteration of the solution algorithm.
A class for managing temporary objects.
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
static options & New(const fvMesh &mesh)
Construct fvOptions and register to database if not present.
virtual tmp< volVectorField > adjointMeanFlowSource()=0
Source terms to the adjoint momentum equation due to the differentiation of the turbulence model...
objectiveManager objectiveManager_
Object to manage objective functions.
bool setRefCell(const volScalarField &field, const volScalarField &fieldRef, const dictionary &dict, label &refCelli, scalar &refValue, const bool forceReference=false)
If the field fieldRef needs referencing find the reference cell nearest.
virtual void addMomentumSource(fvVectorMatrix &matrix)
Source terms for the momentum equations.
tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > snGrad(const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
addToRunTimeSelectionTable(functionObject, pointHistory, dictionary)
static constexpr const zero Zero
Global zero (0)