UniformDimensionedField.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-2024 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 
27 
28 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
29 
30 template<class Type>
32 (
33  const IOobject& io,
34  const dimensioned<Type>& dt
35 )
36 :
37  regIOobject(io),
38  dimensioned<Type>(dt),
40 {
41  // Read value
42  if
43  (
44  (
47  )
49  )
50  {
51  dictionary dict(readStream(typeName));
52 
53  this->dimensions().read(dict.lookup("dimensions"));
54 
55  this->value() = dict.lookup<Type>("value", this->dimensions());
56  }
57 }
58 
59 
60 template<class Type>
62 (
64 )
65 :
66  regIOobject(udt),
67  dimensioned<Type>(udt),
69 {}
70 
71 
72 template<class Type>
74 (
75  const IOobject& io
76 )
77 :
78  regIOobject(io),
81 {
82  dictionary dict(readStream(typeName));
83 
84  this->dimensions().read(dict.lookup("dimensions"));
85 
86  this->value() = dict.lookup<Type>("value", this->dimensions());
87 }
88 
89 
90 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
91 
92 template<class Type>
94 {}
95 
96 
97 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
98 
99 template<class Type>
101 {
102  this->storeOldTimes();
103  return dimensioned<Type>::value();
104 }
105 
106 
107 template<class Type>
109 {
110  return dimensioned<Type>::value();
111 }
112 
113 
114 template<class Type>
116 {
117  writeKeyword(os, "dimensions");
118  this->dimensions().write(os) << token::END_STATEMENT << nl;
119  writeEntry(os, "value", this->value());
120  os << nl;
121 
122  return (os.good());
123 }
124 
125 
126 // * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
127 
128 template<class Type>
130 (
132 )
133 {
135 }
136 
137 
138 template<class Type>
140 (
142 )
143 {
145 }
146 
147 
148 template<class Type>
150 (
151  const dimensioned<Type>& rhs
152 )
153 {
155 }
156 
157 
158 // ************************************************************************* //
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
@ MUST_READ_IF_MODIFIED
Definition: IOobject.H:119
readOption readOpt() const
Definition: IOobject.H:360
bool good() const
Return true if next operation might succeed.
Definition: IOstream.H:330
Class to add into field types to provide old-time storage and retrieval.
Definition: OldTimeField.H:93
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
Dimensioned<Type> registered with the database as a registered IOobject which has the functionality o...
UniformDimensionedField(const IOobject &, const dimensioned< Type > &)
Construct from components. Either reads or uses supplied value.
bool writeData(Ostream &) const
WriteData function required for regIOobject write operation.
Type & value()
Return a reference to the value.
const Type & value() const
Return a const-reference to the value.
virtual ~UniformDimensionedField()
Destructor.
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:710
Istream & read(Istream &is)
Read.
Generic dimensioned Type class.
const dimensionSet & dimensions() const
Return const reference to dimensions.
const Type & value() const
Return const reference to value.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:55
bool headerOk()
Read and check header info.
Definition: regIOobject.C:453
Istream & readStream(const word &, const bool read=true)
Return Istream and check object type against that given.
@ END_STATEMENT
Definition: token.H:108
static const zero Zero
Definition: zero.H:97
const HashTable< dimensionSet > & dimensions()
Get the table of dimension sets.
Definition: dimensionSets.C:96
word name(const bool)
Return a word representation of a bool.
Definition: boolIO.C:39
const dimensionSet dimless
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
Ostream & writeKeyword(Foam::Ostream &os, const keyType &kw)
Write the keyword to the Ostream with the current level of indentation.
Definition: keyType.C:155
static const char nl
Definition: Ostream.H:266
label timeIndex
Definition: getTimeIndex.H:4
dictionary dict