SIMPLEControl.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-2019 PCOpt/NTUA
9  Copyright (C) 2013-2019 FOSS GP
10  Copyright (C) 2019-2021 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 \*---------------------------------------------------------------------------*/
29 
30 #include "SIMPLEControl.H"
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36  defineTypeNameAndDebug(SIMPLEControl, 0);
37  defineRunTimeSelectionTable(SIMPLEControl, dictionary);
38 }
39 
40 
41 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
42 
43 Foam::SIMPLEControl::SIMPLEControl
44 (
45  fvMesh& mesh,
46  const word& managerType,
47  const solver& solver
48 )
49 :
51  simpleControl(mesh, "SIMPLE", false),
52  managerType_(managerType),
53  nIters_(Zero),
54  pRefCell_(Zero),
55  pRefValue_(Zero)
56 {
57  read();
58 }
59 
60 
61 // * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
62 
64 (
65  fvMesh& mesh,
66  const word& managerType,
67  const solver& solver
68 )
69 {
70  auto* ctorPtr = dictionaryConstructorTable(managerType);
71 
72  if (!ctorPtr)
73  {
75  (
76  "control",
77  managerType,
78  *dictionaryConstructorTablePtr_
79  ) << exit(FatalError);
80  }
81 
82  return autoPtr<SIMPLEControl>(ctorPtr(mesh, managerType, solver));
83 }
84 
85 
87 {
90  readIters();
91 
93  {
95  << "Average start iteration is larger than nIter in solver "
96  << solver_.solverName() << nl
97  << tab << "Disabling averaging ..." << nl
98  << endl;
99  average_ = false;
100  }
101 
102  return true;
103 }
104 
105 
107 {
108  nIters_ = dict().get<label>("nIters");
109 }
110 
111 
113 {
114  if (average_ && iter_ < averageStartIter_)
115  {
117  << "Solver " << solver_.solverName()
118  << " converged before averaging started" << nl << tab
119  << "Using instantaneous fields ..." << nl
120  << endl;
121  }
122 }
123 
124 
125 // ************************************************************************* //
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::solverControl::averageStartIter_
label averageStartIter_
Averaging start index.
Definition: solverControl.H:76
Foam::solverControl::read
virtual bool read()
Read controls from optimisationDict.
Definition: solverControl.C:41
Foam::simpleControl
SIMPLE control class to supply convergence information/checks for the SIMPLE loop.
Definition: simpleControl.H:52
Foam::solver::solverName
const word & solverName() const
Return the solver name.
Definition: solver.C:101
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
Foam::defineRunTimeSelectionTable
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
Foam::solverControl::average_
bool average_
Do averaging.
Definition: solverControl.H:85
Foam::solverControl
Base class for solver control classes.
Definition: solverControl.H:51
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::dictionary::get
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:107
Foam::blockMeshTools::read
void read(Istream &, label &val, const dictionary &)
In-place read with dictionary lookup.
Definition: blockMeshTools.C:57
Foam::solver
Base class for solution control classes.
Definition: solver.H:51
SIMPLEControl.H
Foam::SIMPLEControl::read
virtual bool read()
Read controls from fvSolution dictionary.
Definition: SIMPLEControl.C:86
Foam::SIMPLEControl::checkMeanSolution
void checkMeanSolution() const
Definition: SIMPLEControl.C:112
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::solverControl::solver_
const solver & solver_
Reference to the underlaying solver.
Definition: solverControl.H:58
Foam::FatalError
error FatalError
FatalErrorInLookup
#define FatalErrorInLookup(lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalError.
Definition: error.H:457
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::SIMPLEControl::New
static autoPtr< SIMPLEControl > New(fvMesh &mesh, const word &managerType, const solver &solver)
Return a reference to the selected turbulence model.
Definition: SIMPLEControl.C:64
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::autoPtr< Foam::SIMPLEControl >
Foam::tab
constexpr char tab
Definition: Ostream.H:403
Foam::nl
constexpr char nl
Definition: Ostream.H:404
Foam::simpleControl::read
bool read()
Read controls from fvSolution dictionary.
Definition: simpleControl.C:42
Foam::SIMPLEControl::nIters_
label nIters_
Number of SIMPLE iterations.
Definition: SIMPLEControl.H:66
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
WarningInFunction
#define WarningInFunction
Report a warning using Foam::Warning.
Definition: messageStream.H:328
Foam::SIMPLEControl::readIters
virtual void readIters()
Definition: SIMPLEControl.C:106