Loading...
Searching...
No Matches
steadyOptimisation.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-2023 PCOpt/NTUA
9 Copyright (C) 2013-2023 FOSS GP
10 Copyright (C) 2019-2020 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// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34
35namespace Foam
36{
39 (
43 );
44}
45
46
47// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
48
49Foam::steadyOptimisation::steadyOptimisation(fvMesh& mesh)
50:
52{
53 initialize();
54 // Force the construction of the design variables, if they are not
55 // already present
56 if (!designVars_)
57 {
58 designVars_.reset
59 (
61 (
62 mesh_,
63 subDict("optimisation").subDict("designVariables")
64 ).ptr()
65 );
66 }
67 designVars_().setInitialValues();
68 dvUpdate_.reset
69 (
70 new designVariablesUpdate
71 (
72 mesh,
73 subDict("optimisation"),
76 )
77 );
78}
79
80
81// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
82
84{
85 time_++;
86 if (!end())
87 {
88 Info<< "\n* * * * * * * * * * * * * * * * *" << endl;
89 Info<< "Optimisation cycle " << time_.value() << endl;
90 Info<< "* * * * * * * * * * * * * * * * *\n" << endl;
91 }
92 return *this;
93}
94
103{
104 if (update())
106 dvUpdate_->update();
107 }
108 return end();
109}
110
113{
114 return time_.end();
115}
116
117
119{
120 return (time_.timeIndex() != 1 && !end());
121}
122
123
124// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
A class encapsulating functionality neccessary to perform an optimisation loop, such as updating the ...
static autoPtr< designVariables > New(fvMesh &mesh, const dictionary &dict)
Return a reference to the selected design variables.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
Definition dictionary.C:441
Mesh data needed to do the Finite Volume discretisation.
Definition fvMesh.H:85
Abstract base class for optimisation methods.
virtual void initialize()
Initialization. Construct primal and adjoint solvers.
autoPtr< designVariablesUpdate > dvUpdate_
Helper class managing parts of the optimisation.
autoPtr< designVariables > designVars_
Design variables of the optimisation problem.
Time & time_
Reference to the time.
PtrList< adjointSolverManager > adjointSolverManagers_
List of adjoint solver managers to be included in the optimisation.
fvMesh & mesh_
Reference to the mesh.
Iterate the optimisation cycles. For steady state opt, this coinsides with evolving Time.
virtual optimisationManager & operator++()
Prefix increment.
virtual bool update()
Whether to update the design variables.
virtual bool checkEndOfLoopAndUpdate()
Return true if end of optimisation run.
virtual bool end()
Return true if end of optimisation run.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
mesh update()
dynamicFvMesh & mesh
Namespace for OpenFOAM.
messageStream Info
Information stream (stdout output on master, null elsewhere).
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519