Loading...
Searching...
No Matches
adjointTurbulenceModel.C
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2007-2019 PCOpt/NTUA
9 Copyright (C) 2013-2019 FOSS GP
10 Copyright (C) 2019-2021 OpenCFD Ltd.
11-------------------------------------------------------------------------------
12License
13 This file is part of OpenFOAM.
14
15 OpenFOAM is free software: you can redistribute it and/or modify it
16 under the terms of the GNU General Public License as published by
17 the Free Software Foundation, either version 3 of the License, or
18 (at your option) any later version.
19
20 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
21 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
22 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23 for more details.
24
25 You should have received a copy of the GNU General Public License
26 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
27
28\*---------------------------------------------------------------------------*/
29
31#include "volFields.H"
32#include "surfaceFields.H"
33
34// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35
36namespace Foam
39{
40
41// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42
43defineTypeNameAndDebug(adjointTurbulenceModel, 0);
44defineRunTimeSelectionTable(adjointTurbulenceModel, adjointTurbulenceModel);
45
46// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
47
48adjointTurbulenceModel::adjointTurbulenceModel
49(
50 incompressibleVars& primalVars,
52 objectiveManager& objManager,
53 const word& adjointTurbulenceModelName
54)
55:
57 (
58 IOobject
59 (
60 adjointTurbulenceModelName,
61 primalVars.U().time().constant(),
62 primalVars.U().db(),
63 IOobject::NO_READ,
64 IOobject::NO_WRITE
65 )
66 ),
67 primalVars_(primalVars),
68 adjointVars_(adjointVars),
69 runTime_(primalVars.U().time()),
70 mesh_(primalVars.U().mesh())
71{}
72
73
74// * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
75
77(
78 incompressibleVars& primalVars,
80 objectiveManager& objManager,
81 const word& adjointTurbulenceModelName
82)
83{
84 const word modelType
85 (
87 (
89 (
90 "turbulenceProperties",
91 primalVars.U().time().constant(),
92 primalVars.U().db(),
96 )
97 ).get<word>("simulationType")
98 );
99
100 Info<< "Selecting turbulence model type " << modelType << endl;
101
102 auto* ctorPtr = adjointTurbulenceModelConstructorTable(modelType);
103
104 if (!ctorPtr)
105 {
107 (
108 "adjointTurbulenceModel",
109 modelType,
110 *adjointTurbulenceModelConstructorTablePtr_
111 ) << exit(FatalError);
112 }
113
115 (
116 ctorPtr
117 (
118 primalVars,
119 adjointVars,
120 objManager,
121 adjointTurbulenceModelName
123 );
124}
125
126
127// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
128
130{
132}
133
134
135// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
136
137} // End namespace incompressibleAdjoint
138} // End namespace Foam
139
140// ************************************************************************* //
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
@ NO_REGISTER
Do not request registration (bool: false).
@ NO_READ
Nothing to be read.
@ MUST_READ
Reading required.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition IOobject.H:191
const Time & time() const noexcept
Return Time associated with the objectRegistry.
Definition IOobject.C:456
const objectRegistry & db() const noexcept
Return the local objectRegistry.
Definition IOobject.C:450
const word & constant() const noexcept
Return constant name.
Definition TimePathsI.H:131
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
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.
Manages the adjoint mean flow fields and their mean values.
Abstract base class for incompressible adjoint turbulence models (RAS, LES and laminar).
static autoPtr< adjointTurbulenceModel > New(incompressibleVars &primalVars, incompressibleAdjointMeanFlowVars &adjointVars, objectiveManager &objManager, const word &adjointTurbulenceModelName=typeName)
Return a reference to the selected turbulence model.
virtual void correct()=0
Solve the adjoint turbulence equations.
Base class for solution control classes.
const volVectorField & U() const
Return const reference to velocity.
const singlePhaseTransportModel & laminarTransport() const
Return const reference to transport model.
Class for managing objective functions.
regIOobject(const IOobject &io, const bool isTimeObject=false)
Construct from IOobject. The optional flag adds special handling if the object is the top-level regIO...
Definition regIOobject.C:43
virtual void correct()
Correct the laminar viscosity.
A class for handling words, derived from Foam::string.
Definition word.H:66
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
U
Definition pEqn.H:72
dynamicFvMesh & mesh
#define FatalErrorInLookup(lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalError.
Definition error.H:607
Different types of constants.
Namespace for incompressible adjoint turbulence models.
Namespace for OpenFOAM.
messageStream Info
Information stream (stdout output on master, null elsewhere).
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition errorManip.H:125
#define defineRunTimeSelectionTable(baseType, argNames)
Define run-time selection table.
Foam::surfaceFields.