solver.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-2023 PCOpt/NTUA
9  Copyright (C) 2013-2023 FOSS GP
10  Copyright (C) 2019-2020 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 "solver.H"
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
37 }
38 
39 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
40 
42 (
43  fvMesh& mesh,
44  const word& managerType,
45  const dictionary& dict,
46  const word& solverName
47 )
48 :
50  (
51  IOobject
52  (
53  solverName,
54  mesh.time().timeName(),
55  fileName("uniform")/fileName("solvers"),
56  mesh,
57  IOobject::READ_IF_PRESENT,
58  IOobject::AUTO_WRITE
59  ),
60  word::null // avoid type checking since dictionary is read using the
61  // derived type name and type() will result in "solver" here
62  ),
63  mesh_(mesh),
64  managerType_(managerType),
65  dict_(dict),
66  solverName_(solverName),
67  active_(dict.getOrDefault<bool>("active", true)),
68  isMaster_(dict.getOrDefault<bool>("isMaster", true)),
69  useSolverNameForFields_
70  (dict_.getOrDefault<bool>("useSolverNameForFields", false)),
71  vars_(nullptr)
72 {}
73 
74 
75 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
76 
78 {
79  dict_ = dict;
80 
81  // Note: Slightly dangerous to change active_ while the solver is
82  // running. At the very least, this should trigger writing before stopping.
83  // Additional problems if we have an adjointSolver corresponding to a
84  // constraint. To be revisited
85  //active_ = dict.getOrDefault<bool>("active", true);
86 
87  return true;
88 }
89 
90 
92 {
93  // Does nothing in the base class
94 }
95 
96 
98 {
99  restoreInitValues();
100 }
101 
104 {
105  // Does nothing in the base class
106 }
107 
108 
110 {
111  // Does nothing in the base class
112 }
113 
114 
115 // ************************************************************************* //
virtual void restoreInitValues()
Restore initial field values if necessary.
Definition: solver.C:84
dictionary dict
A class for handling file names.
Definition: fileName.H:72
Base solver class.
Definition: solver.H:45
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
dictionary dict_
Dictionary holding the solver info.
Definition: solver.H:66
localIOdictionary is derived from IOdictionary but excludes parallel master reading.
word timeName
Definition: getTimeIndex.H:3
virtual void addTopOFvOptions() const
Add topO fvOptions.
Definition: solver.C:102
dynamicFvMesh & mesh
A class for handling words, derived from Foam::string.
Definition: word.H:63
solver(const solver &)=delete
No copy construct.
const dictionary & dict() const
Return the solver dictionary.
Definition: solverI.H:54
virtual bool readDict(const dictionary &dict)
Definition: solver.C:70
defineTypeNameAndDebug(combustionModel, 0)
virtual void preLoop()
Functions to be called before loop.
Definition: solver.C:90
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:172
virtual void postLoop()
Functions to be called after loop.
Definition: solver.C:96
Namespace for OpenFOAM.