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-2025 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 (
118 )
119 {
121 }
122 
123 
124 template<class Type>
126 {
127  writeKeyword(os, "dimensions");
128  this->dimensions().write(os) << token::END_STATEMENT << nl;
129  writeEntry(os, "value", this->value());
130  os << nl;
131 
132  return (os.good());
133 }
134 
135 
136 // * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
137 
138 template<class Type>
140 (
142 )
143 {
145 }
146 
147 
148 template<class Type>
150 (
152 )
153 {
155 }
156 
157 
158 template<class Type>
160 (
161  const dimensioned<Type>& rhs
162 )
163 {
165 }
166 
167 
168 template<class Type>
170 {
171  return this->value();
172 }
173 
174 
175 // ************************************************************************* //
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:357
bool good() const
Return true if next operation might succeed.
Definition: IOstream.H:333
Class to add into field types to provide old-time storage and retrieval.
Definition: OldTimeField.H:113
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.
void reset(const UniformDimensionedField< Type > &)
Reset the field values to the given field.
Type & value()
Return a reference to the value.
virtual ~UniformDimensionedField()
Destructor.
const Type & operator[](const label) const
Access by index.
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
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:740
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
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
const HashTable< dimensionSet > & dimensions()
Get the table of dimension sets.
Definition: dimensionSets.C:96
const dimensionSet dimless
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
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:267
label timeIndex
Definition: getTimeIndex.H:4
dictionary dict