Loading...
Searching...
No Matches
solverControl.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 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
29Class
30 Foam::solverControl
31
32Description
33 Base class for solver control classes
34
35\*---------------------------------------------------------------------------*/
36
37#ifndef solverControl_H
38#define solverControl_H
39
40#include "fvMesh.H"
41#include "solver.H"
42
43// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44
45namespace Foam
46{
47
48/*---------------------------------------------------------------------------*\
49 Class solverControl Declaration
50\*---------------------------------------------------------------------------*/
51
52class solverControl
53{
54protected:
55
56 // Protected data
57
58 //- Reference to the underlaying solver
59 const solver& solver_;
60
61 // Solution controls
62
63 //- Whether to print the max magnitude during each solver iteration
64 // Useful for adjoint solvers
65 bool printMaxMags_;
66
67
68 // Evolution
69
70 //- Current iteration index
71 label iter_;
72
73 //- Current averaging iteration index
74 label averageIter_;
75
76 //- Averaging start index
78
79 // Non run-time modifiable entries
80
81 //- Whether to re-initialize the solution based on the initial
82 //- time step. Makes sense only for optimisation or FD runs
84
85 //- Do averaging
86 bool average_;
87
88
89 // Protected Member Functions
90
91 //- Read controls from optimisationDict
92 virtual bool read();
93
95private:
96
97 //- No copy construct
98 solverControl(const solverControl&) = delete;
99
100 //- No copy assignment
101 void operator=(const solverControl&) = delete;
102
103
104public:
105
106
107 // Static Data Members
108
109 //- Run-time type information
110 TypeName("solverControl");
111
112
113 // Constructors
114
115 //- Construct from solver
116 solverControl(const solver& solver);
117
118
119 //- Destructor
120 virtual ~solverControl() = default;
121
122
123 // Member Functions
124
125 //- Read controls from optimisationDict
127 //- Return the solver dictionary
128 inline virtual const dictionary solverDict() const;
129
130 //- Return the solutionControls dictionary
131 inline virtual const dictionary solutionDict() const;
132
133 //- Print max mags of solver fields
134 inline bool printMaxMags() const;
135
136
137 // Solution control
138
139 //- Re-initialize
140 inline bool storeInitValues() const;
141
142 //- Return iteration index
143 inline label iter() const;
144
145 //- Return average iteration index reference
146 inline label& averageIter();
147
148 //- Return const average iteration index reference
149 inline label averageIter() const;
150
151 //- Return iteration index
152 inline label averageStartIter() const;
153
154 //- Whether or not to add fields of the current iteration to the
155 //- average fields
156 inline bool doAverageIter() const;
157
158 //- Use averaged fields?
159 //- For solving the adjoint equations or computing sensitivities
160 //- based on averaged fields
161 inline bool useAveragedFields() const;
162
163 //- Whether averaging is enabled or not
164 inline bool average() const;
165
166 //- Return reference to the underlaying solver
167 inline const solver& getSolver() const;
168};
169
170
171// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
172
173} // End namespace Foam
174
175#include "solverControlI.H"
176
177// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
178
179#endif
180
181// ************************************************************************* //
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
bool doAverageIter() const
Whether or not to add fields of the current iteration to the average fields.
const solver & solver_
Reference to the underlaying solver.
bool storeInitValues() const
Re-initialize.
virtual ~solverControl()=default
Destructor.
bool storeInitValues_
Whether to re-initialize the solution based on the initial time step. Makes sense only for optimisati...
label averageStartIter() const
Return iteration index.
label & averageIter()
Return average iteration index reference.
bool average_
Do averaging.
label averageStartIter_
Averaging start index.
virtual const dictionary solutionDict() const
Return the solutionControls dictionary.
bool printMaxMags() const
Print max mags of solver fields.
bool useAveragedFields() const
Use averaged fields? For solving the adjoint equations or computing sensitivities based on averaged f...
label averageIter_
Current averaging iteration index.
label iter_
Current iteration index.
virtual const dictionary solverDict() const
Read controls from optimisationDict.
TypeName("solverControl")
Run-time type information.
bool average() const
Whether averaging is enabled or not.
label iter() const
Return iteration index.
virtual bool read()
Read controls from optimisationDict.
bool printMaxMags_
Whether to print the max magnitude during each solver iteration.
const solver & getSolver() const
Return reference to the underlaying solver.
Base solver class.
Definition solver.H:48
Namespace for OpenFOAM.
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68