adjointBoundaryCondition.H
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-2021 PCOpt/NTUA
9  Copyright (C) 2013-2021 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 Class
30  Foam::adjointBoundaryCondition
31 
32 Description
33  Base class for solution control classes
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef adjointBoundaryCondition_H
38 #define adjointBoundaryCondition_H
39 
41 #include "ATCModel.H"
42 #include "Switch.H"
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 /*---------------------------------------------------------------------------*\
50  Class adjointBoundaryCondition Declaration
51 \*---------------------------------------------------------------------------*/
52 
53 template<class Type>
55 {
56 protected:
57 
58  // Protected data
59 
60  //- Reference to patch
61  const fvPatch& patch_;
62 
63  //- objectiveManager name corresponding to field
65 
66  //- adjointSolver name corresponding to field
68 
69  //- simulationType corresponding to field.
70  // A placeholder for now
72 
73  //- Engine to manage contributions of the objective functions
74  //- to the adjoint boundary conditions
76 
77  //- Whether to add the extra term from the UaGradU formulation.
78  // As a Switch with delayed evaluation since ATCModel
79  // has not been allocated at the time of construction
81 
82 
83  // Protected Member Functions
84 
85  //- Get gradient of field on a specific boundary
86  template<class Type2>
88  <
91 
92  //- Whether to add the extra term from the UaGradU formulation
93  bool addATCUaGradUTerm();
94 
95 
96 public:
97 
98  // Static Data Members
99 
100  //- Run-time type information
101  TypeName("adjointBoundaryCondition");
102 
103 
104  // Constructors
105 
106  //- Construct from field and base name
108  (
109  const fvPatch& p,
111  const word& solverName
112  );
113 
114  //- Construct as copy
116 
117 
118  //- Destructor
119  virtual ~adjointBoundaryCondition() = default;
120 
121 
122  // Member Functions
123 
124  // Access
125 
126  //- Return objectiveManager name
127  const word& objectiveManagerName() const;
128 
129  //- Return adjointSolverName
130  const word& adjointSolverName() const;
131 
132  //- Return the simulationType
133  const word& simulationType() const;
134 
135  //- Set the ptr to the correct boundaryAdjointContribution
137 
138  //- Get boundaryContribution
140 
141  //- ATC type might be useful for a number of BCs. Return here
142  const ATCModel& getATC() const;
143 
144 
145  // Contribution to sensitivity derivatives
146 
147  //- Return contribution to sensitivity derivatives
148  // For adjoint boundary conditions corresponding to primal
149  // boundary conditions that include geometric components
150  // (e.g. rotatingWallVelocity)
151  virtual tmp
152  <
154  > dxdbMult() const;
155 
156  //- Update the primal based quantities related to the adjoint boundary
157  //- conditions
158  virtual void updatePrimalBasedQuantities();
159 };
160 
161 
162 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
163 
164 } // End namespace Foam
165 
166 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
167 
168 #ifdef NoRepository
169  #include "adjointBoundaryCondition.C"
170 #endif
171 
172 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
173 
174 #endif
175 
176 #define makeAdjointBoundaryCondition(adjointTypeBoundaryCondition) \
177 defineNamedTemplateTypeNameAndDebug(adjointTypeBoundaryCondition, 0);
178 
179 // ************************************************************************* //
word simulationType_
simulationType corresponding to field.
tmp< Field< typename Foam::outerProduct< Foam::vector, Type2 >::type > > computePatchGrad(word name)
Get gradient of field on a specific boundary.
adjointBoundaryCondition(const fvPatch &p, const DimensionedField< Type, volMesh > &iF, const word &solverName)
Construct from field and base name.
word managerName_
objectiveManager name corresponding to field
virtual void updatePrimalBasedQuantities()
Update the primal based quantities related to the adjoint boundary conditions.
const word & simulationType() const
Return the simulationType.
const word & adjointSolverName() const
Return adjointSolverName.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:70
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, any/none. Also accepts 0/1 as a string and shortcuts t/f, y/n.
Definition: Switch.H:77
void setBoundaryContributionPtr()
Set the ptr to the correct boundaryAdjointContribution.
bool addATCUaGradUTerm()
Whether to add the extra term from the UaGradU formulation.
virtual tmp< Field< typename Foam::outerProduct< Foam::vector, Type >::type > > dxdbMult() const
Return contribution to sensitivity derivatives.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition: exprTraits.C:127
autoPtr< boundaryAdjointContribution > boundaryContrPtr_
Engine to manage contributions of the objective functions to the adjoint boundary conditions...
Generic templated field type.
Definition: Field.H:62
const ATCModel & getATC() const
ATC type might be useful for a number of BCs. Return here.
A class for handling words, derived from Foam::string.
Definition: word.H:63
Base class for selecting the adjoint transpose convection model. Inherits from regIOobject to add loo...
Definition: ATCModel.H:56
Abstract base class for computing contributions of the objective functions to the adjoint boundary co...
boundaryAdjointContribution & getBoundaryAdjContribution()
Get boundaryContribution.
virtual ~adjointBoundaryCondition()=default
Destructor.
const fvPatch & patch_
Reference to patch.
Base class for solution control classes.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
Switch addATCUaGradUTerm_
Whether to add the extra term from the UaGradU formulation.
volScalarField & p
A class for managing temporary objects.
Definition: HashPtrTable.H:50
TypeName("adjointBoundaryCondition")
Run-time type information.
const word & objectiveManagerName() const
Return objectiveManager name.
word adjointSolverName_
adjointSolver name corresponding to field
Namespace for OpenFOAM.