60 const word& adjointSolverName,
61 const word& primalSolverName
64 objectiveIncompressible(
mesh,
dict, adjointSolverName, 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]
226 gradUbf[patchI] = tnf*
U.boundaryField()[patchI].snGrad();
233 for (
const label patchI : momentPatches_)
235 const fvPatch&
patch =
mesh_.boundary()[patchI];
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
252 for (label idir = 0; idir < pTraits<vector>::nComponents; ++idir)
256 for (
const label patchI : momentPatches_)
258 const fvPatch&
patch =
mesh_.boundary()[patchI];
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();
279 const vectorField dx(patch.Cf() - rotationCentre_);
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_;
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
void clear() noexcept
Clear the addressed list, i.e. set the size to zero.
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())
Internal & ref(const bool updateAccessTime=true)
Same as internalFieldRef().
GeometricBoundaryField< tensor, fvPatchField, volMesh > Boundary
const Boundary & boundaryField() const noexcept
Return const-reference to the boundary field.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
T & ref()
Return reference to the managed object without nullptr checking.
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface....
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T. FatalIOError if not found, or if the number of tokens is incorrect.
wordList sortedToc() const
Return the sorted table of contents.
Mesh data needed to do the Finite Volume discretisation.
const fvBoundaryMesh & boundary() const noexcept
Return reference to boundary mesh.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
const volVectorField & U() const
Return const reference to velocity.
const volScalarField & p() const
Return const reference to pressure.
const autoPtr< incompressible::turbulenceModel > & turbulence() const
Return const reference to the turbulence model.
const singlePhaseTransportModel & laminarTransport() const
Return const reference to transport model.
const volScalarField & pInst() const
Return const reference to pressure.
const autoPtr< incompressible::RASModelVariables > & RASModelVariables() const
Return const reference to the turbulence model variables.
Abstract base class for objective functions in incompressible flows.
autoPtr< boundaryScalarField > bdJdnutPtr_
Jacobian wrt to nut.
autoPtr< boundaryVectorField > bdJdpPtr_
Adjoint (intlet,wall) velocity.
const incompressibleVars & vars_
autoPtr< boundaryVectorField > bdSdbMultPtr_
Term multiplying delta(n dS)/delta b.
autoPtr< boundaryVectorField > bdxdbDirectMultPtr_
Term multiplying delta(x)/delta b at the boundary for objectives that directly depend on x,...
scalar J_
Objective function value and weight.
const dictionary & dict() const
Return objective dictionary.
autoPtr< boundaryVectorField > bdxdbMultPtr_
Term multiplying delta(x)/delta b at the boundary.
virtual void update_meanValues()
Update mean drag and lift values.
virtual void update_boundarydJdnut()
Update dJ/dnut multiplier.
virtual void update_dxdbDirectMultiplier()
Update delta(x)/delta b multiplier coming directly from the objective.
virtual scalar J()
Return the objective function value.
virtual void update_dxdbMultiplier()
Update delta(x)/delta b multiplier.
objectiveMoment(const fvMesh &mesh, const dictionary &dict, const word &adjointSolverName, const word &primalSolverName)
from components
virtual void update_boundarydJdp()
Update values to be added to the adjoint wall velocity.
virtual void update_dSdbMultiplier()
Update delta(n dS)/delta b multiplier.
A simple single-phase transport model based on viscosityModel.
virtual tmp< volScalarField > nu() const
Return the laminar viscosity.
A class for managing temporary objects.
const T & cref() const
Return const reference to the object or to the contents of a (non-null) managed pointer.
void clear() const noexcept
If object pointer points to valid object: delete object and set pointer to nullptr.
T & ref() const
Return non-const reference to the contents of a non-null managed pointer.
A List of wordRe with additional matching capabilities.
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
#define DebugInfo
Report an information message using Foam::Info.
Namespace for handling debugging switches.
const std::string patch
OpenFOAM patch number as a std::string.
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh > > grad(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Type gSum(const FieldField< Field, Type > &f)
GeometricField< vector, fvPatchField, volMesh > volVectorField
dimensionedSymmTensor sqr(const dimensionedVector &dv)
GeometricField< scalar, fvPatchField, volMesh > volScalarField
SymmTensor< Cmpt > devTwoSymm(const SymmTensor< Cmpt > &st)
Return the deviatoric part of twice the symmetric part of a SymmTensor.
dimensionedSymmTensor twoSymm(const dimensionedSymmTensor &dt)
const dimensionSet dimVelocity
messageStream Info
Information stream (stdout output on master, null elsewhere).
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Ostream & endl(Ostream &os)
Add newline and flush stream.
GeometricField< tensor, fvPatchField, volMesh > volTensorField
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
fvPatchField< symmTensor > fvPatchSymmTensorField
Field< vector > vectorField
Specialisation of Field<T> for vector.
GeometricField< symmTensor, fvPatchField, volMesh > volSymmTensorField
static constexpr const zero Zero
Global zero (0).
autoPtr< GeometricField< Type, fvPatchField, volMesh > > createZeroFieldPtr(const fvMesh &mesh, const word &name, const dimensionSet dims, bool printAllocation=false)
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).
autoPtr< typename GeometricField< Type, fvPatchField, volMesh >::Boundary > createZeroBoundaryPtr(const fvMesh &mesh, bool printAllocation=false)
#define forAll(list, i)
Loop across all elements in list.