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 // ************************************************************************* //
incompressiblePrimalSolver.H
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::simple::solverControl_
autoPtr< SIMPLEControl > solverControl_
Solver control.
Definition: simple.H:72
Foam::simple::mainIter
virtual void mainIter()
The main SIMPLE iter.
Definition: simple.C:142
Foam::simple::postIter
virtual void postIter()
Steps to be executed before each main SIMPLE iteration.
Definition: simple.C:238
Foam::simple::addExtraSchemes
void addExtraSchemes()
Definition: simple.C:56
Foam::simple::continuityErrors
void continuityErrors()
Compute continuity errors.
Definition: simple.C:70
Foam::simple::cumulativeContErr_
scalar cumulativeContErr_
Cumulative continuity error.
Definition: simple.H:83
Foam::simple
Base class for solution control classes.
Definition: simple.H:52
Foam::simple::objectives_
List< objective * > objectives_
List of objectives related to this primal solver.
Definition: simple.H:86
Foam::simple::solveIter
virtual void solveIter()
Execute one iteration of the solution algorithm.
Definition: simple.C:128
Foam::simple::writeData
virtual bool writeData(Ostream &os) const
Write average iteration.
Definition: simple.C:315
SIMPLEControl.H
Foam::simple::preLoop
virtual void preLoop()
Functions to be called before loop.
Definition: simple.C:286
Foam::simple::restoreInitValues
virtual void restoreInitValues()
Restore initial field values if necessary.
Definition: simple.C:280
Foam::incompressiblePrimalSolver
Base class for primal incompressible solvers.
Definition: incompressiblePrimalSolver.H:53
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
os
OBJstream os(runTime.globalPath()/outputName)
Foam::simple::incoVars_
incompressibleVars & incoVars_
Reference to incompressibleVars.
Definition: simple.H:77
Foam::simple::loop
virtual bool loop()
Looper (advances iters, time step)
Definition: simple.C:274
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::simple::preIter
virtual void preIter()
Steps to be executed before each main SIMPLE iteration.
Definition: simple.C:136
IOMRFZoneList.H
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::solver::mesh
const fvMesh & mesh() const
Return the solver mesh.
Definition: solver.C:96
Foam::simple::MRF_
IOMRFZoneList MRF_
MRF zones.
Definition: simple.H:80
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:63
Foam::IOMRFZoneList
List of MRF zones with IO functionality. MRF zones are specified by a list of dictionary entries,...
Definition: IOMRFZoneList.H:71
Foam::simple::allocateVars
incompressibleVars & allocateVars()
Protected Member Functions.
Definition: simple.C:49
Foam::simple::~simple
virtual ~simple()=default
Destructor.
Foam::simple::TypeName
TypeName("simple")
Run-time type information.
Foam::simple::readDict
virtual bool readDict(const dictionary &dict)
Read dict if updated.
Definition: simple.C:118
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
objective.H
Foam::solver::dict
virtual const dictionary & dict() const
Return the solver dictionary.
Definition: solver.C:113
Foam::incompressibleVars
Base class for solution control classes.
Definition: incompressibleVars.H:54
Foam::simple::solve
virtual void solve()
Main control loop.
Definition: simple.C:259
Foam::simple::postLoop
virtual void postLoop()
Functions to be called after loop.
Definition: simple.C:303