OpenFOAM
v2406
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
Copyright (C) 2022 OpenCFD Ltd.
10
-------------------------------------------------------------------------------
11
License
12
This file is part of OpenFOAM.
13
14
OpenFOAM is free software: you can redistribute it and/or modify it
15
under the terms of the GNU General Public License as published by
16
the Free Software Foundation, either version 3 of the License, or
17
(at your option) any later version.
18
19
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22
for more details.
23
24
You should have received a copy of the GNU General Public License
25
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27
\*---------------------------------------------------------------------------*/
28
29
#include "
UniformDimensionedField.H
"
30
31
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32
33
template
<
class
Type>
34
Foam::UniformDimensionedField<Type>::UniformDimensionedField
35
(
36
const
IOobject
&
io
,
37
const
dimensioned<Type>
& dt
38
)
39
:
40
regIOobject
(
io
),
41
dimensioned
<Type>(dt)
42
{
43
if
(
dimensioned<Type>::name
().empty())
44
{
45
dimensioned<Type>::name
() =
regIOobject::name
();
46
}
47
48
// Read value
49
readHeaderOk(IOstreamOption::BINARY, typeName);
50
}
51
52
53
template
<
class
Type>
54
Foam::UniformDimensionedField<Type>::UniformDimensionedField
55
(
56
const
IOobject
&
io
,
57
const
dimensionSet
& dims,
58
const
Type& val
59
)
60
:
61
regIOobject
(
io
),
62
dimensioned
<Type>(
regIOobject
::
name
(), dims, val)
63
{
64
// Read value
65
readHeaderOk(IOstreamOption::BINARY, typeName);
66
}
67
68
69
template
<
class
Type>
70
Foam::UniformDimensionedField<Type>::UniformDimensionedField
71
(
72
const
IOobject
&
io
,
73
const
Type& val,
74
const
dimensionSet
& dims
75
)
76
:
77
regIOobject
(
io
),
78
dimensioned
<Type>(
regIOobject
::
name
(), dims, val)
79
{
80
// Read value
81
readHeaderOk(IOstreamOption::BINARY, typeName);
82
}
83
84
85
template
<
class
Type>
86
Foam::UniformDimensionedField<Type>::UniformDimensionedField
87
(
88
const
UniformDimensionedField<Type>
& rhs
89
)
90
:
91
regIOobject
(rhs),
92
dimensioned
<Type>(rhs)
93
{}
94
95
96
template
<
class
Type>
97
Foam::UniformDimensionedField<Type>::UniformDimensionedField
98
(
99
const
IOobject
&
io
100
)
101
:
102
regIOobject
(
io
),
103
dimensioned
<Type>(
regIOobject
::
name
(),
dimless
,
Zero
)
104
{
105
// For if MUST_READ_IF_MODIFIED
106
addWatch();
107
108
// Read unless NO_READ
109
readHeaderOk(IOstreamOption::BINARY, typeName);
110
}
111
112
113
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
114
115
template
<
class
Type>
116
bool
Foam::UniformDimensionedField<Type>::readData
(
Istream
& is)
117
{
118
dictionary
dict
(is);
119
120
// The dimensions
121
scalar multiplier(1);
122
this->dimensions().read
123
(
124
dict
.lookup(
"dimensions"
, keyType::LITERAL),
125
multiplier
126
);
127
128
// The value
129
dict
.readEntry(
"value"
, this->value(), keyType::LITERAL);
130
this->value() *= multiplier;
131
132
return
is.
good
();
133
}
134
135
136
template
<
class
Type>
137
bool
Foam::UniformDimensionedField<Type>::writeData
(
Ostream
&
os
)
const
138
{
139
// The dimensions
140
scalar multiplier(1);
141
os
.writeKeyword(
"dimensions"
);
142
this->dimensions().write(
os
, multiplier);
143
os
.endEntry();
144
145
// The value
146
os
.writeEntry(
"value"
, this->value()/multiplier) <<
nl
;
147
148
return
os
.good();
149
}
150
151
152
// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
153
154
template
<
class
Type>
155
void
Foam::UniformDimensionedField<Type>::operator
=
156
(
157
const
UniformDimensionedField<Type>
& rhs
158
)
159
{
160
dimensioned<Type>::operator=
(rhs);
161
}
162
163
164
template
<
class
Type>
165
void
Foam::UniformDimensionedField<Type>::operator
=
166
(
167
const
dimensioned<Type>
& rhs
168
)
169
{
170
dimensioned<Type>::operator=
(rhs);
171
}
172
173
174
// ************************************************************************* //
dict
dictionary dict
Definition:
searchingEngine.H:11
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition:
dictionary.H:129
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition:
Istream.H:57
Foam::nl
constexpr char nl
The newline '\n' character (0x0a)
Definition:
Ostream.H:50
Foam::dimensioned
Generic dimensioned Type class.
Definition:
dimensionedScalarFwd.H:33
Foam::dimless
const dimensionSet dimless
Dimensionless.
Definition:
dimensionSets.C:182
Foam::UniformDimensionedField::writeData
bool writeData(Ostream &) const
The writeData method required for regIOobject write operation.
Definition:
UniformDimensionedField.C:130
Foam::dimensionSet
Dimension set for the base types, which can be used to implement rigorous dimension checking for alge...
Definition:
dimensionSet.H:105
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition:
exprTraits.C:127
UniformDimensionedField.H
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition:
Ostream.H:56
os
OBJstream os(runTime.globalPath()/outputName)
Foam::UniformDimensionedField::readData
virtual bool readData(Istream &)
The readData method required for regIOobject read operation.
Definition:
UniformDimensionedField.C:109
Foam::UniformDimensionedField
Dimensioned<Type> registered with the database as a registered IOobject which has the functionality o...
Definition:
UniformDimensionedField.H:53
Foam::IOstream::good
bool good() const noexcept
True if next operation might succeed.
Definition:
IOstream.H:281
Foam::regIOobject
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition:
regIOobject.H:68
io
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition:
IOobject.H:180
Foam::UniformDimensionedField::UniformDimensionedField
UniformDimensionedField(const IOobject &io, const dimensioned< Type > &dt)
Construct from components. Either reads or uses supplied value.
Definition:
UniformDimensionedField.C:28
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition:
zero.H:127
src
OpenFOAM
fields
UniformDimensionedFields
UniformDimensionedField.C
Generated by
1.8.14