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 -------------------------------------------------------------------------------
12 License
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 
30 #include "adjointTurbulenceModel.H"
31 #include "volFields.H"
32 #include "surfaceFields.H"
33 
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38 namespace incompressibleAdjoint
39 {
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
45 
46 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
47 
48 adjointTurbulenceModel::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  (
88  IOobject
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
122  )
123  );
124 }
125 
126 
127 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
128 
130 {
132 }
133 
134 
135 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
136 
137 } // End namespace incompressibleAdjoint
138 } // End namespace Foam
139 
140 // ************************************************************************* //
Foam::surfaceFields.
defineTypeNameAndDebug(adjointRASModel, 0)
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
defineRunTimeSelectionTable(adjointRASModel, dictionary)
Class for managing objective functions.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
virtual void correct()=0
Solve the adjoint turbulence equations.
Ignore writing from objectRegistry::writeObject()
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.
#define FatalErrorInLookup(lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalError.
Definition: error.H:605
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:50
Base class for solution control classes.
dynamicFvMesh & mesh
const singlePhaseTransportModel & laminarTransport() const
Return const reference to transport model.
A class for handling words, derived from Foam::string.
Definition: word.H:63
const objectRegistry & db() const noexcept
Return the local objectRegistry.
Definition: IOobject.C:450
const Time & time() const noexcept
Return Time associated with the objectRegistry.
Definition: IOobject.C:456
const volVectorField & U() const
Return const reference to velocity.
virtual void correct()
Correct the laminar viscosity.
const word & constant() const noexcept
Return constant name.
Definition: TimePathsI.H:112
static autoPtr< adjointTurbulenceModel > New(incompressibleVars &primalVars, incompressibleAdjointMeanFlowVars &adjointVars, objectiveManager &objManager, const word &adjointTurbulenceModelName=typeName)
Return a reference to the selected turbulence model.
Abstract base class for incompressible adjoint turbulence models (RAS, LES and laminar).
Manages the adjoint mean flow fields and their mean values.
U
Definition: pEqn.H:72
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:66
messageStream Info
Information stream (stdout output on master, null elsewhere)
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:172
Do not request registration (bool: false)
Namespace for OpenFOAM.