48 objectiveIncompressible,
60 const word& adjointSolverName,
61 const word& primalSolverName
74 Aref_(
dict.
get<scalar>(
"Aref")),
75 lRef_(
dict.
get<scalar>(
"lRef")),
76 rhoInf_(
dict.
get<scalar>(
"rhoInf")),
77 UInf_(
dict.
get<scalar>(
"UInf")),
78 invDenom_(2./(rhoInf_*UInf_*UInf_*Aref_*lRef_)),
82 if (momentPatches_.
empty())
85 <<
"No valid patch name on which to minimize " <<
type() <<
endl 90 Info<<
"Minimizing " <<
type() <<
" in patches:" <<
endl;
91 for (
const label patchI : momentPatches_)
119 for (
const label patchI : momentPatches_)
124 pressureMoment +=
gSum 126 rhoInf_*(dx ^ Sf)*
p.boundaryField()[patchI]
130 viscousMoment +=
gSum 136 cumulativeMoment = pressureMoment + viscousMoment;
138 scalar moment = cumulativeMoment & momentDirection_;
139 scalar Cm = moment*invDenom_;
141 "Moment|Coeff " << moment <<
"|" << Cm <<
endl;
156 devReff_ = turbVars->devReff(lamTransp,
U)();
163 for (
const label patchI : momentPatches_)
167 bdJdpPtr_()[patchI] = (momentDirection_ ^ tdx)*invDenom_*rhoInf_;
176 for (
const label patchI : momentPatches_)
185 (momentDirection_ ^ tdx()) &
191 + rhoInf_*(momentDirection_ ^ tdx())*
p.boundaryField()[patchI]
223 if (isA<wallFvPatch>(
patch))
226 gradUbf[patchI] = tnf*
U.boundaryField()[patchI].snGrad();
233 for (
const label patchI : momentPatches_)
236 tmp<vectorField> tnf =
patch.nf();
237 tmp<vectorField> tdx =
patch.Cf() - rotationCentre_;
239 (momentDirection_ & (tdx ^ tnf))*gradp.boundaryField()[patchI]
245 tmp<volScalarField> tnuEff = lamTransp.
nu() + turbVars->nut();
246 tmp<volSymmTensorField> tstress = tnuEff*
twoSymm(tgradU);
248 autoPtr<volVectorField> ptemp
256 for (
const label patchI : momentPatches_)
259 tmp<vectorField> tnf =
patch.nf();
260 tmp<vectorField> tdx =
patch.Cf() - rotationCentre_;
261 tmp<scalarField> taux = (momentDirection_ ^ tdx)().component(idir);
263 taux*(gradStressDir.boundaryField()[patchI] & tnf)
274 for (
const label patchI : momentPatches_)
277 tmp<vectorField> tnf =
patch.nf();
284 ((
p.boundaryField()[patchI]*nf)
289 (force^momentDirection_)*invDenom_*rhoInf_;
299 for (
const label patchI : momentPatches_)
305 devGradU.boundaryField()[patchI];
307 - rhoInf_*((tdx ^ (bdevGradU & tnf)) & momentDirection_)*invDenom_;
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
GeometricField< symmTensor, fvPatchField, volMesh > volSymmTensorField
const volScalarField & pInst() const
Return const reference to pressure.
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh >> grad(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
autoPtr< boundaryVectorField > bdxdbMultPtr_
Term multiplying delta(x)/delta b at the boundary.
virtual void update_dxdbMultiplier()
Update delta(x)/delta b multiplier.
errorManipArg< error, int > exit(error &err, const int errNo=1)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
T & ref() const
Return non-const reference to the contents of a non-null managed pointer.
GeometricField< tensor, fvPatchField, volMesh > volTensorField
dimensionedSymmTensor sqr(const dimensionedVector &dv)
virtual void update_dSdbMultiplier()
Update delta(n dS)/delta b multiplier.
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface...
Ostream & endl(Ostream &os)
Add newline and flush stream.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
void unzipRow(const FieldField< Field, SymmTensor< Cmpt >> &input, const direction idx, FieldField< Field, Vector< Cmpt >> &result)
Extract a symmTensor field field row (x,y,z) == (0,1,2)
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
::Foam::direction nComponents(const expressions::valueTypeCode) noexcept
The number of components associated with given valueTypeCode.
GeometricField< vector, fvPatchField, volMesh > volVectorField
Macros for easy insertion into run-time selection tables.
dimensionedSymmTensor twoSymm(const dimensionedSymmTensor &dt)
#define forAll(list, i)
Loop across all elements in list.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
autoPtr< boundaryScalarField > bdJdnutPtr_
Jacobian wrt to nut.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
objectiveMoment(const fvMesh &mesh, const dictionary &dict, const word &adjointSolverName, const word &primalSolverName)
from components
Type gSum(const FieldField< Field, Type > &f)
const singlePhaseTransportModel & laminarTransport() const
Return const reference to transport model.
A class for handling words, derived from Foam::string.
defineTypeNameAndDebug(objectivePartialVolume, 1)
virtual void update_boundarydJdp()
Update values to be added to the adjoint wall velocity.
const volScalarField & p() const
Return const reference to pressure.
A List of wordRe with additional matching capabilities.
scalar J_
Objective function value and weight.
#define DebugInfo
Report an information message using Foam::Info.
const volVectorField & U() const
Return const reference to velocity.
static tmp< GeometricField< tensor, fvPatchField, volMesh > > New(const word &name, IOobjectOption::registerOption regOpt, const Mesh &mesh, const dimensionSet &dims, const word &patchFieldType=fvPatchField< tensor >::calculatedType())
Return tmp field (NO_READ, NO_WRITE) from name, mesh, dimensions and patch type. [Takes current timeN...
bool empty() const noexcept
True if the hash table is empty.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
int debug
Static debugging option.
autoPtr< boundaryVectorField > bdJdpPtr_
Adjoint (intlet,wall) velocity.
Info<< "Reading field U\"<< endl;volVectorField U(IOobject("U", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE), mesh);volScalarField rho(IOobject("rho", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE), thermo.rho());volVectorField rhoU(IOobject("rhoU", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE), rho *U);volScalarField rhoE(IOobject("rhoE", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE), rho *(e+0.5 *magSqr(U)));surfaceScalarField pos(IOobject("pos", runTime.timeName(), mesh), mesh, dimensionedScalar("pos", dimless, 1.0));surfaceScalarField neg(IOobject("neg", runTime.timeName(), mesh), mesh, dimensionedScalar("neg", dimless, -1.0));surfaceScalarField phi("phi", fvc::flux(rhoU));Info<< "Creating turbulence model\"<< endl;autoPtr< compressible::turbulenceModel > turbulence(compressible::turbulenceModel::New(rho, U, phi, thermo))
addToRunTimeSelectionTable(objectiveGeometric, objectivePartialVolume, dictionary)
const autoPtr< incompressible::RASModelVariables > & RASModelVariables() const
Return const reference to the turbulence model variables.
const incompressibleVars & vars_
virtual void update_boundarydJdnut()
Update dJ/dnut multiplier.
Mesh data needed to do the Finite Volume discretisation.
const std::string patch
OpenFOAM patch number as a std::string.
List< label > sortedToc(const UList< bool > &bools)
Return the (sorted) values corresponding to 'true' entries.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Internal & ref(const bool updateAccessTime=true)
Same as internalFieldRef()
const fvBoundaryMesh & boundary() const noexcept
Return reference to boundary mesh.
const autoPtr< incompressible::turbulenceModel > & turbulence() const
Return const reference to the turbulence model.
Field< vector > vectorField
Specialisation of Field<T> for vector.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
virtual void update_dxdbDirectMultiplier()
Update delta(x)/delta b multiplier coming directly from the objective.
autoPtr< boundaryVectorField > bdxdbDirectMultPtr_
Term multiplying delta(x)/delta b at the boundary for objectives that directly depend on x...
A class for managing temporary objects.
autoPtr< boundaryVectorField > bdSdbMultPtr_
Term multiplying delta(n dS)/delta b.
virtual void update_meanValues()
Update mean drag and lift values.
A simple single-phase transport model based on viscosityModel.
Abstract base class for objective functions in incompressible flows.
virtual scalar J()
Return the objective function value.
const Boundary & boundaryField() const noexcept
Return const-reference to the boundary field.
virtual tmp< volScalarField > nu() const
Return the laminar viscosity.
SymmTensor< Cmpt > devTwoSymm(const SymmTensor< Cmpt > &st)
Return the deviatoric part of twice the symmetric part of a SymmTensor.
static constexpr const zero Zero
Global zero (0)
const dimensionSet dimVelocity