incompressibleAdjointSolver.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-2020 PCOpt/NTUA
9  Copyright (C) 2013-2020 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 
33 
34 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38  defineTypeNameAndDebug(incompressibleAdjointSolver, 0);
39  defineRunTimeSelectionTable(incompressibleAdjointSolver, dictionary);
41  (
42  adjointSolver,
43  incompressibleAdjointSolver,
44  adjointSolver
45  );
46 }
47 
48 
49 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
50 
51 Foam::incompressibleAdjointSolver::incompressibleAdjointSolver
52 (
53  fvMesh& mesh,
54  const word& managerType,
55  const dictionary& dict,
56  const word& primalSolverName
57 )
58 :
59  adjointSolver(mesh, managerType, dict, primalSolverName),
60  primalVars_
61  (
62  mesh.lookupObjectRef<incompressiblePrimalSolver>(primalSolverName).
63  getIncoVars()
64  ),
65  ATCModel_(nullptr)
66 {}
67 
68 
69 // * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
70 
73 (
74  fvMesh& mesh,
75  const word& managerType,
76  const dictionary& dict,
77  const word& primalSolverName
78 )
79 {
80  const word solverType(dict.get<word>("solver"));
81  auto* ctorPtr = dictionaryConstructorTable(solverType);
82 
83  if (!ctorPtr)
84  {
86  (
87  dict,
88  "incompressibleAdjointSolver",
89  solverType,
90  *dictionaryConstructorTablePtr_
91  ) << exit(FatalIOError);
92  }
93 
94  return
95  autoPtr<incompressibleAdjointSolver>
96  (
97  ctorPtr(mesh, managerType, dict, primalSolverName)
98  );
99 }
100 
101 
102 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
103 
105 {
107  {
108  return true;
109  }
110 
111  return false;
112 }
113 
115 {
116  return getAdjointVars().useSolverNameForFields();
117 }
118 
119 
122 {
123  return primalVars_;
124 }
125 
126 
127 
130 {
131  const incompressibleAdjointVars& adjointVars =
132  refCast<incompressibleAdjointVars>(const_cast<variablesSet&>(vars_()));
133  return adjointVars;
134 }
135 
136 
139 {
140  incompressibleAdjointVars& adjointVars =
141  refCast<incompressibleAdjointVars>(const_cast<variablesSet&>(vars_()));
142  return adjointVars;
143 }
144 
145 
146 
149 {
150  return ATCModel_;
151 }
152 
153 
155 {
156  return ATCModel_;
157 }
158 
159 
161 {
162  if (vars_)
163  {
164  getAdjointVars().adjointTurbulence()->setChangedPrimalSolution();
165  }
166 }
167 
168 
169 // ************************************************************************* //
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
Foam::adjointSolver
Base class for adjoint solvers.
Definition: adjointSolver.H:51
incompressiblePrimalSolver.H
Foam::incompressibleAdjointSolver::New
static autoPtr< incompressibleAdjointSolver > New(fvMesh &mesh, const word &managerType, const dictionary &dict, const word &primalSolverName)
Definition: incompressibleAdjointSolver.C:66
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:63
Foam::incompressibleAdjointSolver::getATCModel
const autoPtr< ATCModel > & getATCModel() const
Definition: incompressibleAdjointSolver.C:141
Foam::adjointSolver::primalSolverName
const word & primalSolverName() const
Definition: adjointSolver.H:146
Foam::incompressibleAdjointSolver::useSolverNameForFields
virtual bool useSolverNameForFields() const
Definition: incompressibleAdjointSolver.C:107
Foam::defineRunTimeSelectionTable
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
Foam::FatalIOError
IOerror FatalIOError
Foam::adjointSolver::readDict
virtual bool readDict(const dictionary &dict)
Definition: adjointSolver.C:119
Foam::dictionary::get
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:100
Foam::incompressibleAdjointVars
Class including all adjoint fields for incompressible flows.
Definition: incompressibleAdjointVars.H:46
incompressibleAdjointSolver.H
Foam::variablesSet
Base class for creating a set of variables.
Definition: variablesSet.H:43
FatalIOErrorInLookup
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Definition: error.H:502
Foam::incompressiblePrimalSolver
Base class for primal incompressible solvers.
Definition: incompressiblePrimalSolver.H:47
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::incompressibleAdjointSolver::updatePrimalBasedQuantities
virtual void updatePrimalBasedQuantities()
Definition: incompressibleAdjointSolver.C:153
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:119
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:81
Foam
Definition: atmBoundaryLayer.C:26
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:49
Foam::solver::mesh
const fvMesh & mesh() const
Definition: solver.C:89
Foam::incompressibleAdjointSolver::getAdjointVars
virtual const incompressibleAdjointVars & getAdjointVars() const
Definition: incompressibleAdjointSolver.C:122
Foam::incompressibleAdjointSolver::readDict
virtual bool readDict(const dictionary &dict)
Definition: incompressibleAdjointSolver.C:97
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::incompressibleAdjointSolver::getPrimalVars
const incompressibleVars & getPrimalVars() const
Definition: incompressibleAdjointSolver.C:114
Foam::solver::dict
virtual const dictionary & dict() const
Definition: solver.C:106
Foam::incompressibleVars
Base class for solution control classes.
Definition: incompressibleVars.H:48