adjointBoundaryCondition.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 
31 #include "ATCUaGradU.H"
32 
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37 
38 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
39 
40 defineTypeNameAndDebug(adjointBoundaryCondition, 0);
41 
42 
43 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
44 
46 {
48  {
49  addATCUaGradUTerm_.reset(new bool(isA<ATCUaGradU>(getATC())));
50  }
51  return addATCUaGradUTerm_();
52 }
53 
54 
55 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
56 
58 (
59  const adjointBoundaryCondition& adjointBC
60 )
61 :
62  patch_(adjointBC.patch_),
63  managerName_(adjointBC.managerName_),
64  adjointSolverName_(adjointBC.adjointSolverName_),
65  simulationType_(adjointBC.simulationType_),
66  boundaryContrPtr_
67  (
69  (
70  adjointBC.managerName_,
71  adjointBC.adjointSolverName_,
72  adjointBC.simulationType_,
73  adjointBC.patch_
74  )
75  ),
76  addATCUaGradUTerm_(adjointBC.addATCUaGradUTerm_)
77 {}
78 
79 
80 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
81 
83 {
84  return managerName_;
85 }
86 
87 
89 {
90  return adjointSolverName_;
91 }
92 
93 
95 {
96  return simulationType_;
97 }
98 
99 
101 {
102  // Note:
103  // Check whether there is an objectiveFunctionManager object in the registry
104  // Necessary for decomposePar if the libadjoint is loaded
105  // through controlDict. A nicer way should be found
106  const fvMesh& meshRef = patch_.boundaryMesh().mesh();
107  if (meshRef.foundObject<regIOobject>(managerName_))
108  {
109  boundaryContrPtr_.reset
110  (
112  (
113  managerName_,
116  patch_
117  ).ptr()
118  );
119  }
120  else
121  {
123  << "No objectiveManager " << managerName_ << " available." << nl
124  << "Setting boundaryAdjointContributionPtr to nullptr. " << nl
125  << "OK for decomposePar."
126  << endl;
127  }
128 }
129 
130 
133 {
134  return boundaryContrPtr_();
135 }
136 
137 
139 {
140  return
142  (
143  "ATCModel" + adjointSolverName_
144  );
145 }
146 
147 
148 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
149 
150 } // End namespace Foam
151 
152 // ************************************************************************* //
Foam::autoPtr::reset
void reset(T *p=nullptr) noexcept
Delete managed object and set to new given pointer.
Definition: autoPtrI.H:158
Foam::adjointBoundaryCondition::adjointBoundaryCondition
adjointBoundaryCondition(const fvPatch &p, const DimensionedField< Type, volMesh > &iF, const word &solverName)
Construct from field and base name.
Definition: adjointBoundaryConditionTemplates.C:145
Foam::adjointBoundaryCondition::getBoundaryAdjContribution
boundaryAdjointContribution & getBoundaryAdjContribution()
Get boundaryContribution.
Definition: adjointBoundaryCondition.C:132
adjointBoundaryCondition.H
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::adjointBoundaryCondition::patch_
const fvPatch & patch_
Reference to patch.
Definition: adjointBoundaryCondition.H:58
Foam::adjointBoundaryCondition::simulationType
const word & simulationType() const
Return the simulationType.
Definition: adjointBoundaryCondition.C:94
Foam::adjointBoundaryCondition
Base class for solution control classes.
Definition: adjointBoundaryCondition.H:51
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:337
Foam::adjointBoundaryCondition::boundaryContrPtr_
autoPtr< boundaryAdjointContribution > boundaryContrPtr_
Definition: adjointBoundaryCondition.H:72
Foam::fvBoundaryMesh::mesh
const fvMesh & mesh() const
Return the mesh reference.
Definition: fvBoundaryMesh.H:103
Foam::ATCModel
Base class for selecting the adjoint transpose convection model. Inherits from regIOobject to add loo...
Definition: ATCModel.H:60
Foam::autoPtr::empty
bool empty() const noexcept
True if the managed pointer is null.
Definition: autoPtrI.H:100
Foam::objectRegistry::foundObject
bool foundObject(const word &name, const bool recursive=false) const
Is the named Type found?
Definition: objectRegistryTemplates.C:379
Foam::adjointBoundaryCondition::getATC
const ATCModel & getATC() const
ATC type might be useful for a number of BCs. Return here.
Definition: adjointBoundaryCondition.C:138
Foam::adjointBoundaryCondition::setBoundaryContributionPtr
void setBoundaryContributionPtr()
Set the ptr to the correct boundaryAdjointContribution.
Definition: adjointBoundaryCondition.C:100
Foam::fvPatch::boundaryMesh
const fvBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
Definition: fvPatch.H:187
ATCUaGradU.H
Foam::adjointBoundaryCondition::adjointSolverName_
word adjointSolverName_
adjointSolver name corresponding to field
Definition: adjointBoundaryCondition.H:64
Foam::objectRegistry::lookupObject
const Type & lookupObject(const word &name, const bool recursive=false) const
Definition: objectRegistryTemplates.C:434
Foam::adjointBoundaryCondition::simulationType_
word simulationType_
simulationType corresponding to field.
Definition: adjointBoundaryCondition.H:68
Foam::adjointBoundaryCondition::addATCUaGradUTerm
bool addATCUaGradUTerm()
Whether to add the extra term from the UaGradU formulation.
Definition: adjointBoundaryCondition.C:45
Foam::adjointBoundaryCondition::managerName_
word managerName_
objectiveManager name corresponding to field
Definition: adjointBoundaryCondition.H:61
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:84
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::regIOobject
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:67
Foam::boundaryAdjointContribution
Abstract base class for computing contributions of the objective functions to the adjoint boundary co...
Definition: boundaryAdjointContribution.H:58
Foam::nl
constexpr char nl
Definition: Ostream.H:372
Foam::adjointBoundaryCondition::objectiveManagerName
const word & objectiveManagerName() const
Return objectiveManager name.
Definition: adjointBoundaryCondition.C:82
Foam::adjointBoundaryCondition::adjointSolverName
const word & adjointSolverName() const
Return adjointSolverName.
Definition: adjointBoundaryCondition.C:88
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
WarningInFunction
#define WarningInFunction
Report a warning using Foam::Warning.
Definition: messageStream.H:294
Foam::boundaryAdjointContribution::New
static autoPtr< boundaryAdjointContribution > New(const word &managerName, const word &adjointSolverName, const word &simulationType, const fvPatch &patch)
Return a reference to the selected turbulence model.
Definition: boundaryAdjointContribution.C:59
Foam::adjointBoundaryCondition::addATCUaGradUTerm_
autoPtr< bool > addATCUaGradUTerm_
Whether to add the extra term from the UaGradU formulation.
Definition: adjointBoundaryCondition.H:78