OpenFOAM: API Guide
v2112
The open source CFD toolbox
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
28
#include "
UniformDimensionedField.H
"
29
30
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31
32
template
<
class
Type>
33
Foam::UniformDimensionedField<Type>::UniformDimensionedField
34
(
35
const
IOobject
&
io
,
36
const
dimensioned<Type>
& dt
37
)
38
:
39
regIOobject
(
io
),
40
dimensioned
<Type>(dt)
41
{
42
// Read value
43
readHeaderOk
(
IOstream::BINARY
, typeName);
44
}
45
46
47
template
<
class
Type>
48
Foam::UniformDimensionedField<Type>::UniformDimensionedField
49
(
50
const
UniformDimensionedField<Type>
& rdt
51
)
52
:
53
regIOobject
(rdt),
54
dimensioned
<Type>(rdt)
55
{}
56
57
58
template
<
class
Type>
59
Foam::UniformDimensionedField<Type>::UniformDimensionedField
60
(
61
const
IOobject
&
io
62
)
63
:
64
regIOobject
(
io
),
65
dimensioned
<Type>(
regIOobject
::
name
(),
dimless
,
Zero
)
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>
78
Foam::UniformDimensionedField<Type>::~UniformDimensionedField
()
79
{}
80
81
82
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
83
84
template
<
class
Type>
85
bool
Foam::UniformDimensionedField<Type>::readData
(
Istream
& is)
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>
103
bool
Foam::UniformDimensionedField<Type>::writeData
(
Ostream
&
os
)
const
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>
117
void
Foam::UniformDimensionedField<Type>::operator
=
118
(
119
const
UniformDimensionedField<Type>
& rhs
120
)
121
{
122
dimensioned<Type>::operator=
(rhs);
123
}
124
125
126
template
<
class
Type>
127
void
Foam::UniformDimensionedField<Type>::operator
=
128
(
129
const
dimensioned<Type>
& rhs
130
)
131
{
132
dimensioned<Type>::operator=
(rhs);
133
}
134
135
136
// ************************************************************************* //
UniformDimensionedField.H
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition:
IOobject.H:170
Foam::IOstream::good
bool good() const noexcept
True if next operation might succeed.
Definition:
IOstream.H:233
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition:
Istream.H:64
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition:
Ostream.H:62
Foam::Ostream::writeEntry
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
Definition:
Ostream.H:239
Foam::Ostream::writeKeyword
virtual Ostream & writeKeyword(const keyType &kw)
Write the keyword followed by an appropriate indentation.
Definition:
Ostream.C:57
Foam::Ostream::write
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
Foam::UniformDimensionedField
Dimensioned<Type> registered with the database as a registered IOobject which has the functionality o...
Definition:
UniformDimensionedField.H:60
Foam::UniformDimensionedField::~UniformDimensionedField
virtual ~UniformDimensionedField()
Destructor.
Definition:
UniformDimensionedField.C:78
Foam::UniformDimensionedField::readData
virtual bool readData(Istream &)
ReadData function required for regIOobject read operation.
Definition:
UniformDimensionedField.C:85
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition:
dictionary.H:126
Foam::dictionary::lookup
ITstream & lookup(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Definition:
dictionary.C:386
Foam::dictionary::readEntry
bool readEntry(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX, bool mandatory=true) const
Definition:
dictionaryTemplates.C:302
Foam::dimensioned
Generic dimensioned Type class.
Definition:
dimensionedType.H:67
Foam::fileFormats::STLCore::BINARY
@ BINARY
BINARY.
Definition:
STLCore.H:64
Foam::functionObjects::ObukhovLength::operator=
void operator=(const ObukhovLength &)=delete
No copy assignment.
Foam::keyType::LITERAL
@ LITERAL
String literal.
Definition:
keyType.H:81
Foam::regIOobject
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition:
regIOobject.H:76
Foam::regIOobject::addWatch
virtual void addWatch()
Add file watch on object (if registered and READ_IF_MODIFIED)
Definition:
regIOobject.C:267
Foam::regIOobject::readHeaderOk
bool readHeaderOk(const IOstreamOption::streamFormat fmt, const word &typeName)
Helper: check readOpt flags and read if necessary.
Definition:
regIOobjectRead.C:39
Foam::token::END_STATEMENT
@ END_STATEMENT
End entry [isseparator].
Definition:
token.H:154
os
OBJstream os(runTime.globalPath()/outputName)
io
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
Foam::dimless
const dimensionSet dimless
Dimensionless.
Definition:
dimensionSets.C:189
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition:
zero.H:131
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition:
exprTraits.C:59
Foam::nl
constexpr char nl
The newline '\n' character (0x0a)
Definition:
Ostream.H:53
dict
dictionary dict
Definition:
searchingEngine.H:14
src
OpenFOAM
fields
UniformDimensionedFields
UniformDimensionedField.C
Generated by
1.9.5
OPENFOAM® is a registered
trademark
of OpenCFD Ltd.