objectiveI.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-2023 PCOpt/NTUA
9  Copyright (C) 2013-2023 FOSS GP
10  Copyright (C) 2019-2020 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 
31 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
32 
33 inline const Foam::word& Foam::objective::objectiveName() const
34 {
35  return objectiveName_;
36 }
37 
38 
39 inline bool Foam::objective::shouldWrite() const
40 {
41  return shouldWrite_;
42 }
43 
44 
45 inline void Foam::objective::setWrite(const bool shouldWrite)
46 {
47  shouldWrite_ = shouldWrite;
48 }
49 
50 
51 inline const Foam::volScalarField& Foam::objective::dJdb() const
52 {
53  return *dJdbPtr_;
54 }
55 
56 
58 {
59  return *dJdbFieldPtr_;
60 }
61 
62 
63 inline const Foam::fvPatchVectorField&
64 Foam::objective::boundarydJdb(const label patchI) const
65 {
66  return bdJdbPtr_()[patchI];
67 }
68 
69 
70 inline const Foam::fvPatchVectorField&
71 Foam::objective::dSdbMultiplier(const label patchI) const
72 {
73  return bdSdbMultPtr_()[patchI];
74 }
75 
76 
77 inline const Foam::fvPatchVectorField&
78 Foam::objective::dndbMultiplier(const label patchI) const
79 {
80  return bdndbMultPtr_()[patchI];
81 }
82 
83 
84 inline const Foam::fvPatchVectorField&
85 Foam::objective::dxdbMultiplier(const label patchI) const
86 {
87  return bdxdbMultPtr_()[patchI];
88 }
89 
90 
91 inline const Foam::fvPatchVectorField&
92 Foam::objective::dxdbDirectMultiplier(const label patchI) const
93 {
94  return bdxdbDirectMultPtr_()[patchI];
95 }
96 
97 
99 (
100  const label patchI,
101  const label edgeI
102 ) const
103 {
104  if (!bdxdbDirectMultPtr_)
105  {
107  << "Unallocated boundaryEdgeMultiplier field"
108  << exit(FatalError);
109  }
110  return bEdgeContribution_()[patchI][edgeI];
111 }
112 
115 {
116  return *bdJdbPtr_;
117 }
118 
121 {
122  return *bdSdbMultPtr_;
123 }
124 
127 {
128  return *bdndbMultPtr_;
129 }
130 
131 
133 {
134  return *bdxdbMultPtr_;
135 }
136 
137 
140 {
141  return *bdxdbDirectMultPtr_;
142 }
143 
144 
146 {
147  if (!bdxdbDirectMultPtr_)
148  {
150  << "Unallocated boundaryEdgeMultiplier field"
151  << endl << endl
152  << exit(FatalError);
153  }
154  return *bEdgeContribution_;
155 }
156 
159 {
160  return *divDxDbMultPtr_;
161 }
162 
165 {
166  return *gradDxDbMultPtr_;
167 }
168 
170 inline bool Foam::objective::hasdJdb() const noexcept
171 {
172  return bool(dJdbPtr_);
173 }
174 
176 inline bool Foam::objective::hasdJdbField() const noexcept
177 {
178  return bool(dJdbFieldPtr_);
179 }
180 
182 inline bool Foam::objective::hasBoundarydJdb() const noexcept
183 {
184  return bool(bdJdbPtr_);
185 }
186 
188 inline bool Foam::objective::hasdSdbMult() const noexcept
189 {
190  return bool(bdSdbMultPtr_);
191 }
192 
194 inline bool Foam::objective::hasdndbMult() const noexcept
195 {
196  return bool(bdndbMultPtr_);
197 }
198 
200 inline bool Foam::objective::hasdxdbMult() const noexcept
201 {
202  return bool(bdxdbMultPtr_);
203 }
204 
207 {
208  return bool(bdxdbDirectMultPtr_);
209 }
210 
213 {
214  return bool(bEdgeContribution_);
215 }
216 
218 inline bool Foam::objective::hasDivDxDbMult() const noexcept
219 {
220  return bool(divDxDbMultPtr_);
221 }
222 
224 inline bool Foam::objective::hasGradDxDbMult() const noexcept
225 {
226  return bool(gradDxDbMultPtr_);
227 }
228 
231 {
232  return bool(integrationStartTimePtr_);
233 }
234 
237 {
238  return bool(integrationEndTimePtr_);
239 }
240 
241 
242 inline void Foam::objective::setComputed(const bool isComputed) noexcept
243 {
244  computed_ = isComputed;
245 }
246 
247 
248 // ************************************************************************* //
const scalarField & dJdbField() const
Contribution to sensitivities with a random number of designVars.
Definition: objectiveI.H:50
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:598
const vectorField3 & boundaryEdgeMultiplier() const
Multiplier located at patch boundary edges.
Definition: objectiveI.H:138
bool hasdxdbDirectMult() const noexcept
Definition: objectiveI.H:199
bool hasBoundarydJdb() const noexcept
Definition: objectiveI.H:175
bool hasdJdbField() const noexcept
Definition: objectiveI.H:169
void setWrite(const bool shouldWrite)
Should the objective be written to file upon calling write()?
Definition: objectiveI.H:38
bool hasdndbMult() const noexcept
Definition: objectiveI.H:187
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
const boundaryVectorField & dndbMultiplier() const
Multiplier of delta(n dS)/delta b for all patches.
Definition: objectiveI.H:119
bool hasBoundaryEdgeContribution() const noexcept
Definition: objectiveI.H:205
const word objectiveName_
Definition: objective.H:67
bool hasGradDxDbMult() const noexcept
Definition: objectiveI.H:217
bool hasdSdbMult() const noexcept
Definition: objectiveI.H:181
const boundaryVectorField & dxdbMultiplier() const
Multiplier of delta(x)/delta b for all patches.
Definition: objectiveI.H:125
const volScalarField & dJdb() const
Contribution to field sensitivities.
Definition: objectiveI.H:44
A class for handling words, derived from Foam::string.
Definition: word.H:63
bool hasdJdb() const noexcept
Definition: objectiveI.H:163
const boundaryVectorField & boundarydJdb() const
Contribution to surface sensitivities for all patches.
Definition: objectiveI.H:107
const volScalarField & divDxDbMultiplier() const
Multiplier of grad( delta(x)/delta b) for volume-based sensitivities.
Definition: objectiveI.H:151
const direction noexcept
Definition: Scalar.H:258
const boundaryVectorField & dSdbMultiplier() const
Multiplier of delta(n dS)/delta b for all patches.
Definition: objectiveI.H:113
const boundaryVectorField & dxdbDirectMultiplier() const
Multiplier of delta(x)/delta b for all patches.
Definition: objectiveI.H:132
bool hasIntegrationStartTime() const noexcept
Definition: objectiveI.H:223
bool shouldWrite() const
Should the objective be written to file upon calling write()?
Definition: objectiveI.H:32
bool hasDivDxDbMult() const noexcept
Definition: objectiveI.H:211
void setComputed(const bool isComputed) noexcept
Set the computed status of the objective.
Definition: objectiveI.H:235
const volTensorField & gradDxDbMultiplier() const
Multiplier of grad( delta(x)/delta b) for volume-based sensitivities.
Definition: objectiveI.H:157
bool hasdxdbMult() const noexcept
Definition: objectiveI.H:193
bool hasIntegrationEndTime() const noexcept
Definition: objectiveI.H:229
const word & objectiveName() const
Return the objective name.
Definition: objectiveI.H:26