UniformDimensionedField.H
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-2017 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 Class
27  Foam::UniformDimensionedField
28 
29 Description
30  Dimensioned<Type> registered with the database as a registered IOobject
31  which has the functionality of a uniform field and allows values from the
32  top-level code to be passed to boundary conditions etc.
33 
34  Is a 'global' field, same on all processors
35 
36 SourceFiles
37  UniformDimensionedField.C
38 
39 \*---------------------------------------------------------------------------*/
40 
41 #ifndef UniformDimensionedField_H
42 #define UniformDimensionedField_H
43 
44 #include "regIOobject.H"
45 #include "dimensionedType.H"
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
49 namespace Foam
50 {
51 
52 /*---------------------------------------------------------------------------*\
53  Class UniformDimensionedField Declaration
54 \*---------------------------------------------------------------------------*/
55 
56 template<class Type>
58 :
59  public regIOobject,
60  public dimensioned<Type>
61 {
62 
63 public:
64 
65  //- Runtime type information
66  TypeName("UniformDimensionedField");
67 
68 
69  // Constructors
70 
71  //- Construct from components. Either reads or uses supplied value.
72  // The name of the dimensioned<Type> defines the name of the
73  // field.
75  (
76  const IOobject& io,
77  const dimensioned<Type>& dt
78  );
79 
80  //- Construct as copy
82 
83  //- Construct from Istream
85 
86 
87  //- Destructor
88  virtual ~UniformDimensionedField();
89 
90 
91  // Member Functions
92 
93  //- Name function provided to resolve the ambiguity between the
94  // name functions in regIOobject and dimensioned<Type>
95  virtual const word& name() const
96  {
97  return dimensioned<Type>::name();
98  }
99 
100  //- ReadData function required for regIOobject read operation
101  virtual bool readData(Istream&);
102 
103  //- WriteData function required for regIOobject write operation
104  bool writeData(Ostream&) const;
105 
106  //- Is object global
107  virtual bool global() const
108  {
109  return true;
110  }
111 
112  //- Return complete path + object name if the file exists
113  // either in the case/processor or case otherwise null
114  virtual fileName filePath() const
115  {
116  return globalFilePath(type());
117  }
118 
119 
120  // Member Operators
121 
122  //- Assign name, dimensions and value.
123  void operator=(const UniformDimensionedField<Type>& rhs);
124 
125  //- Assign name, dimensions and value.
126  void operator=(const dimensioned<Type>& rhs);
127 
128  Type operator[](const label) const
129  {
130  return this->value();
131  }
132 };
133 
134 
135 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
136 
137 } // End namespace Foam
138 
139 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
140 
141 #ifdef NoRepository
142  #include "UniformDimensionedField.C"
143 #endif
144 
145 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
146 
147 #endif
148 
149 // ************************************************************************* //
regIOobject.H
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::fileName
A class for handling file names.
Definition: fileName.H:73
Foam::UniformDimensionedField::writeData
bool writeData(Ostream &) const
WriteData function required for regIOobject write operation.
Definition: UniformDimensionedField.C:103
Foam::dimensioned::name
const word & name() const
Return const reference to name.
Definition: dimensionedType.C:406
Foam::UniformDimensionedField::global
virtual bool global() const
Is object global.
Definition: UniformDimensionedField.H:106
Foam::dimensioned::value
const Type & value() const
Return const reference to value.
Definition: dimensionedType.C:434
Foam::UniformDimensionedField::name
virtual const word & name() const
Name function provided to resolve the ambiguity between the.
Definition: UniformDimensionedField.H:94
UniformDimensionedField.C
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
Foam::IOobject::globalFilePath
fileName globalFilePath(const word &typeName, const bool search=true) const
Helper for filePath that searches up if in parallel.
Definition: IOobject.C:580
Foam::dimensioned
Generic dimensioned Type class.
Definition: dimensionedScalarFwd.H:42
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::UniformDimensionedField::readData
virtual bool readData(Istream &)
ReadData function required for regIOobject read operation.
Definition: UniformDimensionedField.C:85
Foam::UniformDimensionedField::operator[]
Type operator[](const label) const
Definition: UniformDimensionedField.H:127
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::type
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:590
Foam::UniformDimensionedField::filePath
virtual fileName filePath() const
Return complete path + object name if the file exists.
Definition: UniformDimensionedField.H:113
Foam::UniformDimensionedField::TypeName
TypeName("UniformDimensionedField")
Runtime type information.
Foam::UniformDimensionedField::operator=
void operator=(const UniformDimensionedField< Type > &rhs)
Assign name, dimensions and value.
Definition: UniformDimensionedField.C:118
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
dimensionedType.H