simple.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-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 Class
29  Foam::simple
30 
31 Description
32  Base class for solution control classes
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef simple_H
37 #define simple_H
38 
40 #include "SIMPLEControl.H"
41 #include "IOMRFZoneList.H"
42 #include "objective.H"
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 /*---------------------------------------------------------------------------*\
50  Class simple Declaration
51 \*---------------------------------------------------------------------------*/
52 
53 class simple
54 :
56 {
57 private:
58 
59  // Private Member Functions
60 
61  //- No copy construct
62  simple(const simple&) = delete;
63 
64  //- No copy assignment
65  void operator=(const simple&) = delete;
66 
67 
68 protected:
69 
70  // Protected data
71 
72  //- Solver control
74 
75  //- Reference to incompressibleVars
76  // Used for convenience and to avoid repetitive dynamic_casts
77  // Same as getIncoVars()
79 
80  //- MRF zones
82 
83  //- Cumulative continuity error
84  scalar cumulativeContErr_;
85 
86  //- List of objectives related to this primal solver
88 
89 
90  //- Protected Member Functions
91 
92  //- Allocate incompressibleVars and return reference to be used for
93  //- convenience in the rest of the class.
95 
96  //- In case variable names are different than the base ones,
97  //- add extra schemes and relaxation factors to the appropriate dicts
98  // Note: Not supported for now
99  void addExtraSchemes();
100 
101  //- Compute continuity errors
102  void continuityErrors();
103 
104 
105 public:
106 
107  // Static Data Members
108 
109  //- Run-time type information
110  TypeName("simple");
111 
112 
113  // Constructors
114 
115  //- Construct from mesh and dictionary
116  simple
117  (
118  fvMesh& mesh,
119  const word& managerType,
120  const dictionary& dict
121  );
122 
123 
124  //- Destructor
125  virtual ~simple() = default;
126 
127 
128  // Member Functions
129 
130  virtual bool readDict(const dictionary& dict);
131 
132  // Evolution
133 
134  //- Execute one iteration of the solution algorithm
135  virtual void solveIter();
136 
137  //- Steps to be executed before each main SIMPLE iteration
138  virtual void preIter();
139 
140  //- The main SIMPLE iter
141  virtual void mainIter();
142 
143  //- Steps to be executed before each main SIMPLE iteration
144  virtual void postIter();
145 
146  //- Main control loop
147  virtual void solve();
148 
149  //- Looper (advances iters, time step)
150  virtual bool loop();
151 
152  //- Restore initial field values if necessary
153  virtual void restoreInitValues();
154 
155  //- Functions to be called before loop
156  virtual void preLoop();
157 
158  //- Functions to be called after loop
159  virtual void postLoop();
160 
161  //- Write average iteration
162  virtual bool writeData(Ostream& os) const;
163 };
164 
165 
166 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
167 
168 } // End namespace Foam
169 
170 
171 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
172 
173 #endif
174 
175 // ************************************************************************* //
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:120
autoPtr< SIMPLEControl > solverControl_
Solver control.
Definition: simple.H:72
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:56
virtual void solveIter()
Execute one iteration of the solution algorithm.
Definition: simple.C:121
const fvMesh & mesh() const
Return the solver mesh.
Definition: solver.C:89
void continuityErrors()
Compute continuity errors.
Definition: simple.C:63
virtual void solve()
Main control loop.
Definition: simple.C:252
virtual bool readDict(const dictionary &dict)
Read dict if updated.
Definition: simple.C:111
virtual bool writeData(Ostream &os) const
Write average iteration.
Definition: simple.C:308
Base class for solution control classes.
incompressibleVars & allocateVars()
Protected Member Functions.
Definition: simple.C:42
virtual void mainIter()
The main SIMPLE iter.
Definition: simple.C:135
List< objective * > objectives_
List of objectives related to this primal solver.
Definition: simple.H:95
A class for handling words, derived from Foam::string.
Definition: word.H:63
virtual void postLoop()
Functions to be called after loop.
Definition: simple.C:296
virtual void restoreInitValues()
Restore initial field values if necessary.
Definition: simple.C:273
scalar cumulativeContErr_
Cumulative continuity error.
Definition: simple.H:90
virtual void postIter()
Steps to be executed before each main SIMPLE iteration.
Definition: simple.C:231
virtual bool loop()
Looper (advances iters, time step)
Definition: simple.C:267
virtual const dictionary & dict() const
Return the solver dictionary.
Definition: solver.C:106
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:55
void addExtraSchemes()
In case variable names are different than the base ones, add extra schemes and relaxation factors to ...
Definition: simple.C:49
OBJstream os(runTime.globalPath()/outputName)
IOMRFZoneList MRF_
MRF zones.
Definition: simple.H:85
virtual ~simple()=default
Destructor.
virtual void preIter()
Steps to be executed before each main SIMPLE iteration.
Definition: simple.C:129
Base class for solution control classes.
Definition: simple.H:46
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:79
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
Base class for primal incompressible solvers.
TypeName("simple")
Run-time type information.
List of MRF zones with IO functionality. MRF zones are specified by a list of dictionary entries...
Definition: IOMRFZoneList.H:67
incompressibleVars & incoVars_
Reference to incompressibleVars.
Definition: simple.H:80
Namespace for OpenFOAM.
virtual void preLoop()
Functions to be called before loop.
Definition: simple.C:279