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(1);
89  this->dimensions().read
90  (
91  dict.lookup("dimensions", keyType::LITERAL),
92  multiplier
93  );
94 
95  dict.readEntry("value", this->value());
96  this->value() *= multiplier;
97 
98  return is.good();
99 }
100 
101 
102 template<class Type>
104 {
105  scalar multiplier(1);
106  os.writeKeyword("dimensions");
107  this->dimensions().write(os, multiplier) << token::END_STATEMENT << nl;
108  os.writeEntry("value", this->value()/multiplier) << nl;
109 
110  return os.good();
111 }
112 
113 
114 // * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
115 
116 template<class Type>
118 (
120 )
121 {
123 }
124 
125 
126 template<class Type>
128 (
129  const dimensioned<Type>& rhs
130 )
131 {
133 }
134 
135 
136 // ************************************************************************* //
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
Foam::UniformDimensionedField::writeData
bool writeData(Ostream &) const
WriteData function required for regIOobject write operation.
Definition: UniformDimensionedField.C:103
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
Foam::IOstream::good
bool good() const noexcept
True if next operation might succeed.
Definition: IOstream.H:233
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
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:123
os
OBJstream os(runTime.globalPath()/outputName)
Foam::dimensioned
Generic dimensioned Type class.
Definition: dimensionedScalarFwd.H:42
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:73
Foam::nl
constexpr char nl
Definition: Ostream.H:404
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::UniformDimensionedField::~UniformDimensionedField
virtual ~UniformDimensionedField()
Destructor.
Definition: UniformDimensionedField.C:78
Foam::dimless
const dimensionSet dimless
Dimensionless.
Definition: dimensionSets.C:189