UniformDimensionedField.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2024 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 Class
25  Foam::UniformDimensionedField
26 
27 Description
28  Dimensioned<Type> registered with the database as a registered IOobject
29  which has the functionality of a uniform field and allows values from the
30  top-level code to be passed to boundary conditions etc.
31 
32 SourceFiles
33  UniformDimensionedField.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef UniformDimensionedField_H
38 #define UniformDimensionedField_H
39 
40 #include "regIOobject.H"
41 #include "dimensionedType.H"
42 #include "UniformField.H"
43 #include "OldTimeField.H"
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 template<class Type> class UniformDimensionedField;
51 
52 /*---------------------------------------------------------------------------*\
53  Class UniformDimensionedField Declaration
54 \*---------------------------------------------------------------------------*/
55 
56 template<class Type>
58 :
59  public regIOobject,
60  public dimensioned<Type>,
61  public OldTimeField<UniformDimensionedField<Type>>
62 {
63 
64 public:
65 
66  // Public Typedefs
67 
68  //- Type of the non-dimensioned field
70 
71  //- Component type of the elements of the field
72  typedef typename UniformField<Type>::cmptType cmptType;
73 
74 
75  //- Runtime type information
76  TypeName("UniformDimensionedField");
77 
78 
79  // Constructors
80 
81  //- Construct from components. Either reads or uses supplied value.
83 
84  //- Copy constructor
86 
87  //- Construct from Istream
89 
90 
91  //- Destructor
92  virtual ~UniformDimensionedField();
93 
94 
95  // Member Functions
96 
97  //- Name function provided to resolve the ambiguity between the
98  // name functions in regIOobject and dimensioned<Type>
99  virtual const word& name() const
100  {
101  return dimensioned<Type>::name();
102  }
103 
104  //- Is object global
105  virtual bool global() const
106  {
107  return true;
108  }
109 
110  //- Dummy reference count uniqueness test
111  bool unique() const
112  {
113  return true;
114  }
115 
116  //- Return a reference to the value
117  Type& value();
118 
119  //- Return a const-reference to the value
120  const Type& value() const;
121 
122  //- Return the non-dimensioned field
123  FieldType field() const
124  {
125  return FieldType(this->value());
126  }
127 
128  //- WriteData function required for regIOobject write operation
129  bool writeData(Ostream&) const;
130 
131 
132  // Member Operators
133 
136  void operator=(const dimensioned<Type>&);
137 
138  Type operator[](const label) const
139  {
140  return this->value();
141  }
142 
143  //- Dummy reference count decrement
144  void operator--()
145  {}
146 };
147 
148 
149 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
150 
151 } // End namespace Foam
152 
153 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
154 
155 #ifdef NoRepository
156  #include "UniformDimensionedField.C"
157 #endif
158 
159 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
160 
161 #endif
162 
163 // ************************************************************************* //
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
Class to add into field types to provide old-time storage and retrieval.
Definition: OldTimeField.H:93
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
Dimensioned<Type> registered with the database as a registered IOobject which has the functionality o...
UniformField< Type > FieldType
Type of the non-dimensioned field.
UniformDimensionedField(const IOobject &, const dimensioned< Type > &)
Construct from components. Either reads or uses supplied value.
TypeName("UniformDimensionedField")
Runtime type information.
bool writeData(Ostream &) const
WriteData function required for regIOobject write operation.
bool unique() const
Dummy reference count uniqueness test.
FieldType field() const
Return the non-dimensioned field.
virtual bool global() const
Is object global.
void operator--()
Dummy reference count decrement.
Type & value()
Return a reference to the value.
virtual const word & name() const
Name function provided to resolve the ambiguity between the.
virtual ~UniformDimensionedField()
Destructor.
UniformField< Type >::cmptType cmptType
Component type of the elements of the field.
void operator==(const UniformDimensionedField< Type > &)
void operator=(const UniformDimensionedField< Type > &)
A class representing the concept of a uniform field which stores only the single value and providing ...
Definition: UniformField.H:48
pTraits< Type >::cmptType cmptType
Component type.
Definition: UniformField.H:59
Generic dimensioned Type class.
const word & name() const
Return const reference to name.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:55
A class for handling words, derived from string.
Definition: word.H:62
Namespace for OpenFOAM.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59