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 | Copyright (C) 2011-2012 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
27 
28 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
29 
30 template<class Type>
32 (
33  const IOobject& io,
34  const dimensioned<Type>& dt
35 )
36 :
37  regIOobject(io),
39 {
40  // Read value
41  if
42  (
43  (
44  io.readOpt() == IOobject::MUST_READ
45  || io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
46  )
47  || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
48  )
49  {
50  dictionary dict(readStream(typeName));
51  scalar multiplier;
52  this->dimensions().read(dict.lookup("dimensions"), multiplier);
53  dict.lookup("value") >> this->value();
54  this->value() *= multiplier;
55  }
56 }
57 
58 
59 template<class Type>
61 (
63 )
64 :
65  regIOobject(rdt),
67 {}
68 
69 
70 template<class Type>
72 (
73  const IOobject& io
74 )
75 :
76  regIOobject(io),
78 {
79  dictionary dict(readStream(typeName));
80  scalar multiplier;
81  this->dimensions().read(dict.lookup("dimensions"), multiplier);
82  dict.lookup("value") >> this->value();
83  this->value() *= multiplier;
84 }
85 
86 
87 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
88 
89 template<class Type>
91 {}
92 
93 
94 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
95 
96 template<class Type>
98 {
99  scalar multiplier;
100  os.writeKeyword("dimensions");
101  this->dimensions().write(os, multiplier) << token::END_STATEMENT
102  << nl;
103  os.writeKeyword("value") << this->value()/multiplier << token::END_STATEMENT
104  << nl << nl;
105 
106  return (os.good());
107 }
108 
109 
110 // * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
111 
112 template<class Type>
113 void Foam::UniformDimensionedField<Type>::operator=
114 (
116 )
117 {
119 }
120 
121 
122 template<class Type>
123 void Foam::UniformDimensionedField<Type>::operator=
124 (
125  const dimensioned<Type>& rhs
126 )
127 {
129 }
130 
131 
132 // ************************************************************************* //
readOption readOpt() const
Definition: IOobject.H:304
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
virtual ~UniformDimensionedField()
Destructor.
UniformDimensionedField(const IOobject &, const dimensioned< Type > &)
Construct from components. Either reads or uses supplied value.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
dictionary dict
Generic dimensioned Type class.
static const char nl
Definition: Ostream.H:260
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
bool good() const
Return true if next operation might succeed.
Definition: IOstream.H:333
virtual Ostream & write(const token &)=0
Write next token to stream.
Ostream & writeKeyword(const keyType &)
Write the keyword followed by an appropriate indentation.
Definition: Ostream.C:59
Dimensioned<Type> registered with the database as a registered IOobject which has the functionality o...
Traits class for primitives.
Definition: pTraits.H:50
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:60
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:452
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
bool writeData(Ostream &) const
Pure virtual writaData function.
const dimensionSet dimless(0, 0, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:47