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 
43 defineTypeNameAndDebug(adjointTurbulenceModel, 0);
44 defineRunTimeSelectionTable(adjointTurbulenceModel, adjointTurbulenceModel);
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(),
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(),
95  false // Do not register
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::IOobject::NO_WRITE
Definition: IOobject.H:195
volFields.H
Foam::IOdictionary
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:54
Foam::incompressibleAdjointMeanFlowVars
Manages the adjoint mean flow fields and their mean values.
Definition: incompressibleAdjointMeanFlowVars.H:51
Foam::objectiveManager
class for managing incompressible objective functions.
Definition: objectiveManager.H:54
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
adjointTurbulenceModel.H
Foam::incompressibleAdjoint::adjointTurbulenceModel::New
static autoPtr< adjointTurbulenceModel > New(incompressibleVars &primalVars, incompressibleAdjointMeanFlowVars &adjointVars, objectiveManager &objManager, const word &adjointTurbulenceModelName=typeName)
Return a reference to the selected turbulence model.
Definition: adjointTurbulenceModel.C:77
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
surfaceFields.H
Foam::surfaceFields.
Foam::dictionary::get
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:107
Foam::incompressibleAdjoint::defineTypeNameAndDebug
defineTypeNameAndDebug(adjointRASModel, 0)
Foam::Info
messageStream Info
Information stream (stdout output on master, null elsewhere)
Foam::incompressibleVars::laminarTransport
const singlePhaseTransportModel & laminarTransport() const
Return const reference to transport model.
Definition: incompressibleVars.C:418
Foam::incompressibleVars::U
const volVectorField & U() const
Return const reference to velocity.
Definition: incompressibleVars.C:331
Foam::FatalError
error FatalError
FatalErrorInLookup
#define FatalErrorInLookup(lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalError.
Definition: error.H:457
Foam::incompressibleAdjoint::adjointTurbulenceModel::correct
virtual void correct()=0
Solve the adjoint turbulence equations.
Definition: adjointTurbulenceModel.C:129
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::incompressibleAdjoint::defineRunTimeSelectionTable
defineRunTimeSelectionTable(adjointRASModel, dictionary)
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::regIOobject
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:73
Foam::IOobject::MUST_READ_IF_MODIFIED
Definition: IOobject.H:186
Foam::incompressibleAdjoint::adjointTurbulenceModel::primalVars_
incompressibleVars & primalVars_
Definition: adjointTurbulenceModel.H:90
Foam::singlePhaseTransportModel::correct
virtual void correct()
Correct the laminar viscosity.
Definition: singlePhaseTransportModel.C:85
Foam::IOobject::NO_READ
Definition: IOobject.H:188
Foam::incompressibleVars
Base class for solution control classes.
Definition: incompressibleVars.H:54