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-2019 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),
39 {
40  // Read value
41  if
42  (
43  (
44  io.readOpt() == IOobject::MUST_READ
45  || io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
46  )
47  || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
48  )
49  {
50  dictionary dict(readStream(typeName));
51  scalar multiplier;
52  this->dimensions().read(dict.lookup("dimensions"), multiplier);
53  dict.lookup("value") >> this->value();
54  this->value() *= multiplier;
55  }
56 }
57 
58 
59 template<class Type>
61 (
63 )
64 :
65  regIOobject(rdt),
67 {}
68 
69 
70 template<class Type>
72 (
73  const IOobject& io
74 )
75 :
76  regIOobject(io),
78 {
79  dictionary dict(readStream(typeName));
80  scalar multiplier;
81  this->dimensions().read(dict.lookup("dimensions"), multiplier);
82  dict.lookup("value") >> this->value();
83  this->value() *= multiplier;
84 }
85 
86 
87 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
88 
89 template<class Type>
91 {}
92 
93 
94 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
95 
96 template<class Type>
98 {
99  scalar multiplier;
100  writeKeyword(os, "dimensions");
101  this->dimensions().write(os, multiplier) << token::END_STATEMENT << nl;
102  writeEntry(os, "value", this->value()/multiplier);
103  os << nl;
104 
105  return (os.good());
106 }
107 
108 
109 // * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
110 
111 template<class Type>
112 void Foam::UniformDimensionedField<Type>::operator=
113 (
115 )
116 {
118 }
119 
120 
121 template<class Type>
122 void Foam::UniformDimensionedField<Type>::operator=
123 (
124  const dimensioned<Type>& rhs
125 )
126 {
128 }
129 
130 
131 // ************************************************************************* //
dictionary dict
Ostream & writeKeyword(Foam::Ostream &os, const keyType &kw)
Write the keyword to the Ostream with the current level of indentation.
Definition: keyType.C:155
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
const dimensionSet dimless
Generic dimensioned Type class.
bool writeData(Ostream &) const
WriteData function required for regIOobject write operation.
bool good() const
Return true if next operation might succeed.
Definition: IOstream.H:330
static const zero Zero
Definition: zero.H:97
UniformDimensionedField(const IOobject &, const dimensioned< Type > &)
Construct from components. Either reads or uses supplied value.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
static const char nl
Definition: Ostream.H:260
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
Dimensioned<Type> registered with the database as a registered IOobject which has the functionality o...
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:52
readOption readOpt() const
Definition: IOobject.H:353
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:92
virtual ~UniformDimensionedField()
Destructor.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:844