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-2026 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>
51 class UniformDimensionedField;
52 
53 template<class Type>
55 {
57 };
58 
59 template<class Type>
61 {
62  template<template<class> class OtherPrimitiveField>
64 };
65 
66 /*---------------------------------------------------------------------------*\
67  Class UniformDimensionedField Declaration
68 \*---------------------------------------------------------------------------*/
69 
70 template<class Type>
72 :
73  public regIOobject,
74  public dimensioned<Type>,
75  public tmp<UniformDimensionedField<Type>>::refCount,
76  public OldTimeField<UniformDimensionedField<Type>>
77 {
78 protected:
79 
80  // Protected Member Functions
81 
82  //- Construct from IOobject and dimensions without reading
84  (
85  const IOobject&,
86  const dimensionSet& dims,
87  const bool
88  );
89 
90  //- Construct from IOobject and default value without reading
92  (
93  const IOobject&,
94  const dimensioned<Type>&,
95  const bool
96  );
97 
98  //- Read the field and check the dimensions
99  void read
100  (
101  const IOobject::readOption& ro,
102  const dimensionSet& dims
103  );
104 
105 
106 public:
107 
108  // Public Typedefs
109 
110  //- Type of the non-dimensioned field
112 
113  //- Component type of the elements of the field
114  typedef typename UniformField<Type>::cmptType cmptType;
115 
116 
117  //- Runtime type information
118  TypeName("UniformDimensionedField");
119 
120 
121  // Constructors
122 
123  //- Construct from IOobject
125 
126  //- Construct from IOobject and dimensions
127  UniformDimensionedField(const IOobject&, const dimensionSet& dims);
128 
129  //- Construct from IOobject and default value
130  // reading from the IOobject file according to read option
132 
133  //- Copy constructor
135 
136 
137  //- Destructor
138  virtual ~UniformDimensionedField();
139 
140 
141  // Member Functions
142 
143  //- Name function provided to resolve the ambiguity between the
144  // name functions in regIOobject and dimensioned<Type>
145  virtual const word& name() const
146  {
147  return dimensioned<Type>::name();
148  }
149 
150  //- Is object global
151  virtual bool global() const
152  {
153  return true;
154  }
155 
156  //- Return a reference to the value
157  Type& value();
158 
159  //- Return a const-reference to the value
160  const Type& value() const;
161 
162  //- Reset the field values to the given field
163  // Equivalent to operator=
165 
166  //- Prevent warning due to read method
167  using regIOobject::read;
168 
169  //- WriteData function required for regIOobject write operation
170  bool writeData(Ostream&) const;
171 
172 
173  // Member Operators
174 
175  //- Assign to another field
177 
178  //- Assign to another field
180 
181  //- Assign to a dimensioned type
182  void operator=(const dimensioned<Type>&);
183 
184  //- Access by index
185  const Type& operator[](const label) const;
186 };
187 
188 
189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
190 
191 } // End namespace Foam
192 
193 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
194 
195 #ifdef NoRepository
196  #include "UniformDimensionedField.C"
197 #endif
198 
199 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
200 
201 #endif
202 
203 // ************************************************************************* //
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
readOption
Enumeration defining the read options.
Definition: IOobject.H:117
Class to add into field types to provide old-time storage and retrieval.
Definition: OldTimeField.H:115
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...
UniformDimensionedField(const IOobject &, const dimensionSet &dims, const bool)
Construct from IOobject and dimensions without reading.
UniformField< Type > FieldType
Type of the non-dimensioned field.
TypeName("UniformDimensionedField")
Runtime type information.
bool writeData(Ostream &) const
WriteData function required for regIOobject write operation.
virtual bool global() const
Is object global.
void reset(const UniformDimensionedField< Type > &)
Reset the field values to the given field.
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.
const Type & operator[](const label) const
Access by index.
UniformField< Type >::cmptType cmptType
Component type of the elements of the field.
void operator==(const UniformDimensionedField< Type > &)
Assign to another field.
void operator=(const UniformDimensionedField< Type > &)
Assign to another field.
virtual bool read()
Prevent warning due to read method.
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
Dimension set for the base types.
Definition: dimensionSet.H:125
Generic dimensioned Type class.
const word & name() const
Return const reference to name.
Reference counter for various OpenFOAM components.
Definition: refCount.H:50
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:55
virtual bool read()
Read object.
A class for managing temporary objects.
Definition: tmp.H:55
A class for handling words, derived from string.
Definition: word.H:63
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
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488