Loading...
Searching...
No Matches
subModelBase.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) 2011-2016 OpenFOAM Foundation
9 Copyright (C) 2019 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::subModelBase
29
30Description
31 Base class for generic sub-models requiring to be read from dictionary.
32 Provides a mechanism to read and write properties from a dictionary to
33 enable clean re-starts. Used by, e.g. clou dsub-models.
34
35SourceFiles
36 subModelBase.C
37
38\*---------------------------------------------------------------------------*/
39
40#ifndef subModelBase_H
41#define subModelBase_H
42
43#include "dictionary.H"
44
45// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46
47namespace Foam
48{
49
51/*---------------------------------------------------------------------------*\
52 Class subModelBase Declaration
53\*---------------------------------------------------------------------------*/
54
55class subModelBase
56{
57 // Private Member Functions
58
59 //- No copy assignment
60 void operator=(const subModelBase&) = delete;
61
62
63protected:
64
65 // Protected Data
66
67 //- Name of the sub-model
68 const word modelName_;
69
70 //- Reference to properties dictionary e.g. for restart
73 //- Copy of dictionary used during construction
74 const dictionary dict_;
75
76 //- Name of the sub-model base class
78
79 //- Type of the sub-model
80 const word modelType_;
81
82 //- Coefficients dictionary
84
85
86 // Protected Member Functions
88 //- Flag to indicate whether data is/was read in-line
89 bool inLine() const;
90
91
92public:
93
94 // Public Data
95
96 //- Flag to write log into Info
97 bool log;
98
99
100 // Constructors
101
102 //- Construct null
104
105 //- Construct from components without name
107 (
109 const dictionary& dict,
111 const word& modelType,
112 const word& dictExt = "Coeffs"
113 );
114
115 //- Construct from components with name
117 (
118 const word& modelName,
120 const dictionary& dict,
121 const word& baseName,
122 const word& modelType
123 );
124
125 //- Construct as copy
126 subModelBase(const subModelBase& smb);
127
128
129 //- Destructor
130 virtual ~subModelBase() = default;
131
132
133 // Member Functions
134
135 // Access
136
137 //- Return const access to the name of the sub-model
138 const word& modelName() const;
139
140 //- Return const access to the cloud dictionary
141 const dictionary& dict() const;
142
143 //- Return const access to the base name of the sub-model
144 const word& baseName() const;
145
146 //- Return const access to the sub-model type
147 const word& modelType() const;
148
149 //- Return const access to the coefficients dictionary
150 const dictionary& coeffDict() const;
151
152 //- Return const access to the properties dictionary
153 const dictionary& properties() const;
154
155 //- Returns true if defaultCoeffs is true and outputs on printMsg
156 virtual bool defaultCoeffs(const bool printMsg) const;
157
158 //- Return the model 'active' status - default active = true
159 virtual bool active() const;
160
161 //- Cache dependent sub-model fields
162 virtual void cacheFields(const bool store);
163
164 //- Flag to indicate when to write a property
165 virtual bool writeTime() const;
166
167 //- Output directory
168 virtual fileName localPath() const;
169
170
171 // Edit
172
173 // Base properties
174
175 //- Retrieve generic property from the base model
176 template<class Type>
177 Type getBaseProperty
178 (
179 const word& entryName,
180 const Type& defaultValue = Type(Zero)
181 ) const;
182
183 //- Retrieve generic property from the base model
184 template<class Type>
185 void getBaseProperty(const word& entryName, Type& value) const;
186
187 //- Add generic property to the base model
188 template<class Type>
189 void setBaseProperty(const word& entryName, const Type& value);
190
191
192 // Model properties
193
194 //- Retrieve dictionary, return true if set
195 bool getModelDict
196 (
197 const word& entryName,
199 ) const;
200
201 //- Retrieve generic property from the sub-model
202 // Return true if found
203 template<class Type>
204 bool getModelProperty(const word& entryName, Type& value) const;
205
206 //- Retrieve generic property from the sub-model
207 template<class Type>
209 (
210 const word& entryName,
211 const Type& defaultValue = Type(Zero)
212 ) const;
213
214 //- Add generic property to the sub-model
215 template<class Type>
216 void setModelProperty(const word& entryName, const Type& value);
217
218
219 // I-O
220
221 //- Write
222 virtual void write(Ostream& os) const;
223};
224
225
226// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
227
228} // End namespace Foam
229
230// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
231
232#ifdef NoRepository
233 #include "subModelBaseTemplates.C"
234#endif
235
236// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
237
238#endif
239
240// ************************************************************************* //
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
A class for handling file names.
Definition fileName.H:75
bool getModelProperty(const word &entryName, Type &value) const
Retrieve generic property from the sub-model.
const word modelType_
Type of the sub-model.
const word modelName_
Name of the sub-model.
const word & baseName() const
Return const access to the base name of the sub-model.
virtual void cacheFields(const bool store)
Cache dependent sub-model fields.
bool inLine() const
Flag to indicate whether data is/was read in-line.
virtual fileName localPath() const
Output directory.
const dictionary & coeffDict() const
Return const access to the coefficients dictionary.
Type getBaseProperty(const word &entryName, const Type &defaultValue=Type(Zero)) const
Retrieve generic property from the base model.
const dictionary & properties() const
Return const access to the properties dictionary.
virtual ~subModelBase()=default
Destructor.
bool getModelDict(const word &entryName, dictionary &dict) const
Retrieve dictionary, return true if set.
const dictionary coeffDict_
Coefficients dictionary.
const word baseName_
Name of the sub-model base class.
const dictionary dict_
Copy of dictionary used during construction.
const dictionary & dict() const
Return const access to the cloud dictionary.
const word & modelName() const
Return const access to the name of the sub-model.
const word & modelType() const
Return const access to the sub-model type.
virtual bool active() const
Return the model 'active' status - default active = true.
virtual bool defaultCoeffs(const bool printMsg) const
Returns true if defaultCoeffs is true and outputs on printMsg.
bool log
Flag to write log into Info.
subModelBase(dictionary &properties)
Construct null.
void setBaseProperty(const word &entryName, const Type &value)
Add generic property to the base model.
dictionary & properties_
Reference to properties dictionary e.g. for restart.
virtual bool writeTime() const
Flag to indicate when to write a property.
void setModelProperty(const word &entryName, const Type &value)
Add generic property to the sub-model.
A class for handling words, derived from Foam::string.
Definition word.H:66
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
static constexpr const zero Zero
Global zero (0).
Definition zero.H:127
runTime write()