UniformDimensionedField.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
29 
30 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31 
32 template<class Type>
34 (
35  const IOobject& io,
36  const dimensioned<Type>& dt
37 )
38 :
39  regIOobject(io),
41 {
42  // Read value
43  readHeaderOk(IOstream::BINARY, typeName);
44 }
45 
46 
47 template<class Type>
49 (
51 )
52 :
53  regIOobject(rdt),
55 {}
56 
57 
58 template<class Type>
60 (
61  const IOobject& io
62 )
63 :
64  regIOobject(io),
66 {
67  // For if MUST_READ_IF_MODIFIED
68  addWatch();
69 
70  // Read unless NO_READ
71  readHeaderOk(IOstream::BINARY, typeName);
72 }
73 
74 
75 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
76 
77 template<class Type>
79 {}
80 
81 
82 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
83 
84 template<class Type>
86 {
87  dictionary dict(is);
88  scalar multiplier;
89  this->dimensions().read(dict.lookup("dimensions"), multiplier);
90 
91  dict.readEntry("value", this->value());
92  this->value() *= multiplier;
93 
94  return is.good();
95 }
96 
97 
98 template<class Type>
100 {
101  scalar multiplier;
102  os.writeKeyword("dimensions");
103  this->dimensions().write(os, multiplier) << token::END_STATEMENT << nl;
104  os.writeEntry("value", this->value()/multiplier) << nl;
105 
106  return os.good();
107 }
108 
109 
110 // * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
111 
112 template<class Type>
114 (
116 )
117 {
119 }
120 
121 
122 template<class Type>
124 (
125  const dimensioned<Type>& rhs
126 )
127 {
129 }
130 
131 
132 // ************************************************************************* //
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:104
Foam::dimless
const dimensionSet dimless(0, 0, 0, 0, 0, 0, 0)
Dimensionless.
Definition: dimensionSets.H:50
Foam::UniformDimensionedField::writeData
bool writeData(Ostream &) const
WriteData function required for regIOobject write operation.
Definition: UniformDimensionedField.C:99
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
Foam::UniformDimensionedField
Dimensioned<Type> registered with the database as a registered IOobject which has the functionality o...
Definition: UniformDimensionedField.H:56
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::name
word name(const complex &c)
Return string representation of complex.
Definition: complex.C:76
UniformDimensionedField.H
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::dimensioned
Generic dimensioned Type class.
Definition: dimensionedScalarFwd.H:43
Foam::Ostream::write
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
Foam::Ostream::writeKeyword
virtual Ostream & writeKeyword(const keyType &kw)
Write the keyword followed by an appropriate indentation.
Definition: Ostream.C:57
Foam::UniformDimensionedField::readData
virtual bool readData(Istream &)
ReadData function required for regIOobject read operation.
Definition: UniformDimensionedField.C:85
Foam::UniformDimensionedField::UniformDimensionedField
UniformDimensionedField(const IOobject &io, const dimensioned< Type > &dt)
Construct from components. Either reads or uses supplied value.
Definition: UniformDimensionedField.C:34
Foam::regIOobject
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:71
Foam::nl
constexpr char nl
Definition: Ostream.H:385
Foam::Ostream::writeEntry
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
Definition: Ostream.H:232
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::IOstream::good
bool good() const
Return true if next operation might succeed.
Definition: IOstream.H:224
Foam::UniformDimensionedField::~UniformDimensionedField
virtual ~UniformDimensionedField()
Destructor.
Definition: UniformDimensionedField.C:78