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 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 cstrIter =
103  adjointTurbulenceModelConstructorTablePtr_->cfind(modelType);
104 
105  if (!cstrIter.found())
106  {
108  (
109  "adjointTurbulenceModel",
110  modelType,
111  *adjointTurbulenceModelConstructorTablePtr_
112  ) << exit(FatalError);
113  }
114 
116  (
117  cstrIter()
118  (
119  primalVars,
120  adjointVars,
121  objManager,
122  adjointTurbulenceModelName
123  )
124  );
125 }
126 
127 
128 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
129 
131 {
133 }
134 
135 
136 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
137 
138 } // End namespace incompressibleAdjoint
139 } // End namespace Foam
140 
141 // ************************************************************************* //
Foam::IOobject::NO_WRITE
Definition: IOobject.H:130
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:104
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
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:350
surfaceFields.H
Foam::surfaceFields.
Foam::dictionary::get
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:81
Foam::incompressibleAdjoint::defineTypeNameAndDebug
defineTypeNameAndDebug(adjointRASModel, 0)
Foam::Info
messageStream Info
Information stream (uses stdout - output is on the master only)
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:385
Foam::incompressibleAdjoint::adjointTurbulenceModel::correct
virtual void correct()=0
Solve the adjoint turbulence equations.
Definition: adjointTurbulenceModel.C:130
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:71
Foam::IOobject::MUST_READ_IF_MODIFIED
Definition: IOobject.H:121
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:123
Foam::incompressibleVars
Base class for solution control classes.
Definition: incompressibleVars.H:54