sensitivityMultipleIncompressible.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 OpenCFD Ltd.
11-------------------------------------------------------------------------------
12License
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
32
33// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34
35namespace Foam
36{
37
38namespace incompressible
39{
40
41// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42
45(
49);
50
51// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
52
54(
55 const fvMesh& mesh,
56 const dictionary& dict,
58)
59:
61 sensTypes_(dict.subDict("sensTypes").toc()),
62 sens_(sensTypes_.size())
63{
65 {
66 sens_.set
67 (
68 sI,
70 (
71 mesh,
72 dict.subDict("sensTypes").subDict(sensTypes_[sI]),
74 )
75 );
76 }
77}
78
79
80// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
81
82bool sensitivityMultiple::readDict(const dictionary& dict)
83{
84 if (sensitivity::readDict(dict))
85 {
86 forAll(sens_, sI)
87 {
88 sens_[sI].readDict
89 (
90 dict.subDict("sensTypes").subDict(sensTypes_[sI])
91 );
92 }
93
94 return true;
95 }
96
97 return false;
98}
99
100
102{
103 forAll(sens_, sI)
104 {
105 sens_[sI].accumulateIntegrand(dt);
106 }
107}
108
109
111{
112 forAll(sens_, sI)
113 {
114 sens_[sI].assembleSensitivities();
115 }
116}
117
118
120{
121 forAll(sens_, sI)
122 {
123 Info<< "Computing sensitivities " << sensTypes_[sI] << endl;
124 derivatives_ = sens_[sI].calculateSensitivities();
125 }
126 write(type());
127
128 return derivatives_;
129}
130
131
133{
134 forAll(sens_, sI)
135 {
136 sens_[sI].clearSensitivities();
137 }
138}
139
140
141void sensitivityMultiple::write(const word& baseName)
142{
143 forAll(sens_, sI)
144 {
145 sens_[sI].write(sensTypes_[sI]);
146 }
147}
148
149
150// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
151
152} // End namespace incompressible
153} // End namespace Foam
154
155// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
Definition: Time.C:717
Base class for adjoint solvers.
Definition: adjointSolver.H:60
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
Definition: dictionary.C:460
virtual bool write()
Write the output fields.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
Base class for incompressibleAdjoint solvers.
Abstract base class for adjoint-based sensitivities in incompressible flows.
Calculation of adjoint based sensitivities of multiple types.
virtual void clearSensitivities()
Zero sensitivity fields and their constituents.
virtual void assembleSensitivities()
Assemble sensitivities.
const scalarField & calculateSensitivities()
Calculates sensitivities at wall surface points.
virtual void accumulateIntegrand(const scalar dt)
Accumulate sensitivity integrands.
const dictionary & dict() const
Return the construction dictionary.
Definition: sensitivity.C:57
A class for handling words, derived from Foam::string.
Definition: word.H:68
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition: className.H:121
dynamicFvMesh & mesh
Namespace for OpenFOAM.
messageStream Info
Information stream (stdout output on master, null elsewhere)
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:598
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
runTime write()
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333