subModelBase.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) 2011-2026 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 "subModelBase.H"
27 
28 // * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * //
29 
30 bool Foam::subModelBase::subModelBase::inLine() const
31 {
32  return (modelName_ != word::null);
33 }
34 
35 
36 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
37 
39 :
40  modelName_(word::null),
41  properties_(properties),
42  dict_(dictionary::null),
43  baseName_(word::null),
44  modelType_(word::null),
45  coeffDict_(dictionary::null)
46 {}
47 
48 
50 (
51  dictionary& properties,
52  const dictionary& dict,
53  const word& baseName,
54  const word& modelType
55 )
56 :
57  modelName_(word::null),
58  properties_(properties),
59  dict_(dict),
60  baseName_(baseName),
61  modelType_(modelType),
62  coeffDict_(dict.optionalTypeDict(modelType))
63 {}
64 
65 
67 (
68  const word& modelName,
69  dictionary& properties,
70  const dictionary& dict,
71  const word& baseName,
72  const word& modelType
73 )
74 :
75  modelName_(modelName),
76  properties_(properties),
77  dict_(dict),
78  baseName_(baseName),
79  modelType_(modelType),
80  coeffDict_(dict)
81 {}
82 
83 
85 :
86  modelName_(smb.modelName_),
87  properties_(smb.properties_),
88  dict_(smb.dict_),
89  baseName_(smb.baseName_),
90  modelType_(smb.modelType_),
91  coeffDict_(smb.coeffDict_)
92 {}
93 
94 
95 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
96 
98 {}
99 
100 
101 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
102 
104 {
105  return modelName_;
106 }
107 
108 
110 {
111  return dict_;
112 }
113 
114 
116 {
117  return baseName_;
118 }
119 
120 
122 {
123  return modelType_;
124 }
125 
126 
128 {
129  return coeffDict_;
130 }
131 
132 
134 {
135  return properties_;
136 }
137 
138 
139 bool Foam::subModelBase::defaultCoeffs(const bool printMsg) const
140 {
141  bool def = coeffDict_.lookupOrDefault<bool>("defaultCoeffs", false);
142  if (printMsg && def)
143  {
144  Info<< incrIndent;
145  Info<< indent << "Employing default coefficients" << endl;
146  Info<< decrIndent;
147  }
148 
149  return def;
150 }
151 
152 
154 {}
155 
156 
158 {
159  os << coeffDict_;
160 }
161 
162 
163 // ************************************************************************* //
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Base class for generic sub-models requiring to be read from dictionary. Provides a mechanism to read ...
Definition: subModelBase.H:52
virtual ~subModelBase()
Destructor.
Definition: subModelBase.C:97
const word & baseName() const
Return const access to the base name of the sub-model.
Definition: subModelBase.C:115
virtual void cacheFields(const bool store)
Cache dependent sub-model fields.
Definition: subModelBase.C:153
virtual void write(Ostream &os) const
Write.
Definition: subModelBase.C:157
const dictionary & typeDict() const
Return const access to the coefficients dictionary.
Definition: subModelBase.C:127
const dictionary & properties() const
Return const access to the properties dictionary.
Definition: subModelBase.C:133
const dictionary & dict() const
Return const access to the cloud dictionary.
Definition: subModelBase.C:109
const word & modelName() const
Return const access to the name of the sub-model.
Definition: subModelBase.C:103
const word & modelType() const
Return const access to the sub-model type.
Definition: subModelBase.C:121
virtual bool defaultCoeffs(const bool printMsg) const
Returns true if defaultCoeffs is true and outputs on printMsg.
Definition: subModelBase.C:139
subModelBase(dictionary &properties)
Construct null.
Definition: subModelBase.C:38
A class for handling words, derived from string.
Definition: word.H:63
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
Definition: Ostream.H:272
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:288
messageStream Info
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Definition: Ostream.H:265
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:243
dictionary dict