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-------------------------------------------------------------------------------
10License
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
32template<class Type>
34(
35 const IOobject& io,
36 const dimensioned<Type>& dt
37)
38:
40 dimensioned<Type>(dt)
41{
42 // Read value
44}
45
46
47template<class Type>
49(
51)
52:
53 regIOobject(rdt),
54 dimensioned<Type>(rdt)
55{}
56
57
58template<class Type>
60(
61 const IOobject& io
62)
63:
66{
67 // For if MUST_READ_IF_MODIFIED
68 addWatch();
69
70 // Read unless NO_READ
72}
74
75// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
76
77template<class Type>
79{}
81
82// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
84template<class Type>
86{
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}
101
102template<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
116template<class Type>
118(
120)
121{
123}
124
126template<class Type>
128(
129 const dimensioned<Type>& rhs
130)
131{
133}
134
135
136// ************************************************************************* //
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
bool good() const noexcept
True if next operation might succeed.
Definition: IOstream.H:233
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
Definition: Ostream.H:239
virtual Ostream & writeKeyword(const keyType &kw)
Write the keyword followed by an appropriate indentation.
Definition: Ostream.C:57
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
Dimensioned<Type> registered with the database as a registered IOobject which has the functionality o...
virtual ~UniformDimensionedField()
Destructor.
virtual bool readData(Istream &)
ReadData function required for regIOobject read operation.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
ITstream & lookup(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionary.C:386
bool readEntry(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX, bool mandatory=true) const
Generic dimensioned Type class.
void operator=(const ObukhovLength &)=delete
No copy assignment.
@ LITERAL
String literal.
Definition: keyType.H:81
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:76
virtual void addWatch()
Add file watch on object (if registered and READ_IF_MODIFIED)
Definition: regIOobject.C:267
bool readHeaderOk(const IOstreamOption::streamFormat fmt, const word &typeName)
Helper: check readOpt flags and read if necessary.
@ END_STATEMENT
End entry [isseparator].
Definition: token.H:154
OBJstream os(runTime.globalPath()/outputName)
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
const dimensionSet dimless
Dimensionless.
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
dictionary dict