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-2018 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  const word& dictExt
56 )
57 :
59  properties_(properties),
60  dict_(dict),
61  baseName_(baseName),
62  modelType_(modelType),
63  coeffDict_(dict.subDict(modelType + dictExt))
64 {}
65 
66 
68 (
69  const word& modelName,
70  dictionary& properties,
71  const dictionary& dict,
72  const word& baseName,
73  const word& modelType
74 )
75 :
76  modelName_(modelName),
77  properties_(properties),
78  dict_(dict),
79  baseName_(baseName),
80  modelType_(modelType),
81  coeffDict_(dict)
82 {}
83 
84 
86 :
89  dict_(smb.dict_),
90  baseName_(smb.baseName_),
93 {}
94 
95 
96 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
97 
99 {}
100 
101 
102 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
103 
105 {
106  return modelName_;
107 }
108 
109 
111 {
112  return dict_;
113 }
114 
115 
117 {
118  return baseName_;
119 }
120 
121 
123 {
124  return modelType_;
125 }
126 
127 
129 {
130  return coeffDict_;
131 }
132 
133 
135 {
136  return properties_;
137 }
138 
139 
140 bool Foam::subModelBase::defaultCoeffs(const bool printMsg) const
141 {
142  bool def = coeffDict_.lookupOrDefault<bool>("defaultCoeffs", false);
143  if (printMsg && def)
144  {
145  Info<< incrIndent;
146  Info<< indent << "Employing default coefficients" << endl;
147  Info<< decrIndent;
148  }
149 
150  return def;
151 }
152 
153 
155 {
156  return true;
157 }
158 
159 
161 {}
162 
163 
165 {
166  return active();
167 }
168 
169 
171 {
172  os << coeffDict_;
173 }
174 
175 
176 // ************************************************************************* //
const dictionary & properties() const
Return const access to the properties dictionary.
Definition: subModelBase.C:134
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:226
subModelBase(dictionary &properties)
Construct null.
Definition: subModelBase.C:38
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
const word modelType_
Type of the sub-model.
Definition: subModelBase.H:76
dictionary & properties_
Reference to properties dictionary e.g. for restart.
Definition: subModelBase.H:67
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:256
const word baseName_
Name of the sub-model base class.
Definition: subModelBase.H:73
const word & modelName() const
Return const access to the name of the sub-model.
Definition: subModelBase.C:104
const dictionary coeffDict_
Coefficients dictionary.
Definition: subModelBase.H:79
const dictionary & dict() const
Return const access to the cloud dictionary.
Definition: subModelBase.C:110
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Definition: dictionary.C:692
virtual void write(Ostream &os) const
Write.
Definition: subModelBase.C:170
A class for handling words, derived from string.
Definition: word.H:59
static const word null
An empty word.
Definition: word.H:77
const dictionary & coeffDict() const
Return const access to the coefficients dictionary.
Definition: subModelBase.C:128
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
const word & modelType() const
Return const access to the sub-model type.
Definition: subModelBase.C:122
virtual void cacheFields(const bool store)
Cache dependent sub-model fields.
Definition: subModelBase.C:160
virtual bool defaultCoeffs(const bool printMsg) const
Returns true if defaultCoeffs is true and outputs on printMsg.
Definition: subModelBase.C:140
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
Definition: Ostream.H:240
virtual ~subModelBase()
Destructor.
Definition: subModelBase.C:98
Base class for generic sub-models requiring to be read from dictionary. Provides a mechanism to read ...
Definition: subModelBase.H:51
virtual bool writeTime() const
Flag to indicate when to write a property.
Definition: subModelBase.C:164
const word & baseName() const
Return const access to the base name of the sub-model.
Definition: subModelBase.C:116
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
const dictionary dict_
Copy of dictionary used during construction.
Definition: subModelBase.H:70
messageStream Info
const word modelName_
Name of the sub-model.
Definition: subModelBase.H:64
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Definition: Ostream.H:233
virtual bool active() const
Return the model &#39;active&#39; status - default active = true.
Definition: subModelBase.C:154