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 -------------------------------------------------------------------------------
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 
32 
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37 
38 namespace incompressible
39 {
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 defineTypeNameAndDebug(sensitivityMultiple, 0);
45 (
46  adjointSensitivity,
49 );
50 
51 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
52 
53 sensitivityMultiple::sensitivityMultiple
54 (
55  const fvMesh& mesh,
56  const dictionary& dict,
58 )
59 :
61  sensTypes_(dict.subDict("sensTypes").toc()),
62  sens_(sensTypes_.size())
63 {
64  forAll(sensTypes_, sI)
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 
83 {
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 
101 void sensitivityMultiple::accumulateIntegrand(const scalar dt)
102 {
104  {
105  sens_[sI].accumulateIntegrand(dt);
106  }
107 }
108 
109 
111 {
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 {
135  {
136  sens_[sI].clearSensitivities();
137  }
138 }
139 
140 
141 void 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 // ************************************************************************* //
dictionary dict
virtual bool readDict(const dictionary &dict)
Read dictionary if changed.
Definition: sensitivity.C:56
defineTypeNameAndDebug(adjointEikonalSolver, 0)
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:120
const scalarField & calculateSensitivities()
Calculates sensitivities at wall surface points.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:487
Base class for adjoint solvers.
Definition: adjointSolver.H:51
virtual void clearSensitivities()
Zero sensitivity fields and their constituents.
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
Definition: dictionary.C:453
addToRunTimeSelectionTable(adjointSensitivity, sensitivityBezier, dictionary)
Macros for easy insertion into run-time selection tables.
const incompressibleAdjointSolver & adjointSolver() const
Get adjoint solver.
Base class for incompressibleAdjoint solvers.
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:414
const dictionary & dict() const
Return the construction dictionary.
Definition: sensitivity.C:50
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: POSIX.C:799
dynamicFvMesh & mesh
A class for handling words, derived from Foam::string.
Definition: word.H:63
Abstract base class for adjoint-based sensitivities in incompressible flows.
static autoPtr< adjointSensitivity > New(const fvMesh &mesh, const dictionary &dict, incompressibleAdjointSolver &adjointSolver)
Return a reference to the selected turbulence model.
virtual void assembleSensitivities()
Assemble sensitivities.
virtual void accumulateIntegrand(const scalar dt)
Accumulate sensitivity integrands.
virtual void write(const word &baseName=word::null)
Write sensitivities to file.
Calculation of adjoint based sensitivities of multiple types.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:79
messageStream Info
Information stream (stdout output on master, null elsewhere)
virtual bool readDict(const dictionary &dict)
Read dict if changed.
List< label > toc(const UList< bool > &bools)
Return the (sorted) values corresponding to &#39;true&#39; entries.
Definition: BitOps.C:158
Namespace for OpenFOAM.