All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
pisoControl.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2018-2023 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "pisoControl.H"
27 
28 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
29 
30 namespace Foam
31 {
33 }
34 
35 
36 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
37 
39 {
41  {
42  return false;
43  }
44 
45  const dictionary& solutionDict = dict();
46 
47  nCorrPiso_ = solutionDict.lookupOrDefault<label>("nCorrectors", 1);
48 
49  return true;
50 }
51 
52 
53 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
54 
55 Foam::pisoControl::pisoControl(fvMesh& mesh, const word& algorithmName)
56 :
57  fluidSolutionControl(mesh, algorithmName),
58  nCorrPiso_(-1),
59  corrPiso_(0)
60 {
61  read();
62 }
63 
64 
65 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
66 
68 {}
69 
70 
71 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
72 
73 bool Foam::pisoControl::isFinal(const bool finalIter) const
74 {
75  return (finalIter && !anyPisoIter()) || finalPisoIter();
76 }
77 
78 
79 bool Foam::pisoControl::correct(const bool finalIter)
80 {
81  if (finalPisoIter())
82  {
83  corrPiso_ = 0;
84 
85  updateFinal(isFinal(finalIter));
86 
87  return false;
88  }
89 
90  corrPiso_++;
91 
92  updateFinal(isFinal(finalIter));
93 
94  return true;
95 }
96 
97 
98 bool Foam::pisoControl::correctNonOrthogonal(const bool finalIter)
99 {
101  (
102  isFinal(finalIter)
103  );
104 }
105 
106 
108 {
109  return time.run();
110 }
111 
112 
114 {
115  return time.loop();
116 }
117 
118 
119 // ************************************************************************* //
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:76
virtual bool run() const
Return true if run should continue,.
Definition: Time.C:901
virtual bool loop()
Return true if run should continue and if so increment time.
Definition: Time.C:948
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T, if not found return the given default.
Fluid solution control class. Holds flags specific to the solution of fluids.
virtual bool read()
Read controls.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:99
bool correctNonOrthogonal(const bool finalIter=false)
Non-orthogonal corrector loop.
Piso control class. Provides time-loop and piso-loop control methods. No convergence checking is done...
Definition: pisoControl.H:55
virtual ~pisoControl()
Destructor.
Definition: pisoControl.C:67
pisoControl(fvMesh &mesh, const word &algorithmName="PISO")
Construct from a mesh and the name of the algorithm.
Definition: pisoControl.C:55
label nCorrPiso_
Maximum number of piso correctors.
Definition: pisoControl.H:61
bool isFinal(const bool finalIter) const
Flag to indicate whether in final state.
Definition: pisoControl.C:73
bool run(Time &time)
Time run loop.
Definition: pisoControl.C:107
bool correct(const bool finalIter=false)
Piso loop within outer loop.
Definition: pisoControl.C:79
bool correctNonOrthogonal(const bool finalIter=true)
Non-orthogonal corrector loop.
Definition: pisoControl.C:98
bool loop(Time &time)
Time loop loop.
Definition: pisoControl.C:113
virtual bool read()
Read controls.
Definition: pisoControl.C:38
virtual const dictionary & dict() const
Return the solution dictionary.
A class for handling words, derived from string.
Definition: word.H:62
Namespace for OpenFOAM.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
defineTypeNameAndDebug(combustionModel, 0)