Loading...
Searching...
No Matches
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-------------------------------------------------------------------------------
12License
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\*---------------------------------------------------------------------------*/
30#include "solver.H"
31
32// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33
34namespace 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 (
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
92{
93 // Does nothing in the base class
94}
95
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// ************************************************************************* //
@ READ_IF_PRESENT
Reading is optional [identical to LAZY_READ].
@ AUTO_WRITE
Automatically write from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition IOobject.H:191
const Time & time() const noexcept
Return Time associated with the objectRegistry.
Definition IOobject.C:456
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T, or return the given default value. FatalIOError if it is found and the number of...
static const dictionary null
An empty dictionary, which is also the parent for all dictionaries.
Definition dictionary.H:487
A class for handling file names.
Definition fileName.H:75
Mesh data needed to do the Finite Volume discretisation.
Definition fvMesh.H:85
localIOdictionary is derived from IOdictionary but excludes parallel master reading.
localIOdictionary(const IOobject &io, const dictionary *fallback=nullptr)
Construct given an IOobject and optional fallback dictionary content.
Base solver class.
Definition solver.H:48
autoPtr< variablesSet > vars_
Base variableSet pointer.
Definition solver.H:95
const word & managerType() const
Return the manager type.
Definition solverI.H:72
bool active_
Solve equations?
Definition solver.H:76
bool useSolverNameForFields_
Append the variables related to the solver with it name.
Definition solver.H:88
bool isMaster_
Is the solver the master one.
Definition solver.H:83
const word managerType_
The optimisation type.
Definition solver.H:61
virtual void restoreInitValues()
Restore initial field values if necessary.
Definition solver.C:84
dictionary dict_
Dictionary holding the solver info.
Definition solver.H:66
virtual bool readDict(const dictionary &dict)
Definition solver.C:70
virtual void addTopOFvOptions() const
Add topO fvOptions.
Definition solver.C:102
const dictionary & dict() const
Return the solver dictionary.
Definition solverI.H:54
virtual void preLoop()
Functions to be called before loop.
Definition solver.C:90
const word solverName_
Solver name.
Definition solver.H:71
const fvMesh & mesh() const
Return the solver mesh.
Definition solverI.H:24
const word & solverName() const
Return the solver name.
Definition solverI.H:30
fvMesh & mesh_
Reference to the mesh database.
Definition solver.H:56
virtual void postLoop()
Functions to be called after loop.
Definition solver.C:96
solver(const solver &)=delete
No copy construct.
A class for handling words, derived from Foam::string.
Definition word.H:66
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
dynamicFvMesh & mesh
word timeName
Definition getTimeIndex.H:3
Namespace for OpenFOAM.
dictionary dict