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  //- Read the field
83  void read(const IOobject::readOption& ro);
84 
85 
86 public:
87 
88  // Public Typedefs
89 
90  //- Type of the non-dimensioned field
92 
93  //- Component type of the elements of the field
94  typedef typename UniformField<Type>::cmptType cmptType;
95 
96 
97  //- Runtime type information
98  TypeName("UniformDimensionedField");
99 
100 
101  // Constructors
102 
103  //- Construct from IO object
104  UniformDimensionedField(const IOobject&, const bool read = true);
105 
106  //- Construct from IO object. Either reads or uses supplied value.
108  (
109  const IOobject&,
110  const dimensioned<Type>&,
111  const bool read = true
112  );
113 
114  //- Copy constructor
116 
117 
118  //- Destructor
119  virtual ~UniformDimensionedField();
120 
121 
122  // Member Functions
123 
124  //- Name function provided to resolve the ambiguity between the
125  // name functions in regIOobject and dimensioned<Type>
126  virtual const word& name() const
127  {
128  return dimensioned<Type>::name();
129  }
130 
131  //- Is object global
132  virtual bool global() const
133  {
134  return true;
135  }
136 
137  //- Return a reference to the value
138  Type& value();
139 
140  //- Return a const-reference to the value
141  const Type& value() const;
142 
143  //- Reset the field values to the given field
144  // Equivalent to operator=
146 
147  //- Prevent warning due to read method
148  using regIOobject::read;
149 
150  //- WriteData function required for regIOobject write operation
151  bool writeData(Ostream&) const;
152 
153 
154  // Member Operators
155 
156  //- Assign to another field
158 
159  //- Assign to another field
161 
162  //- Assign to a dimensioned type
163  void operator=(const dimensioned<Type>&);
164 
165  //- Access by index
166  const Type& operator[](const label) const;
167 };
168 
169 
170 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
171 
172 } // End namespace Foam
173 
174 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
175 
176 #ifdef NoRepository
177  #include "UniformDimensionedField.C"
178 #endif
179 
180 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
181 
182 #endif
183 
184 // ************************************************************************* //
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...
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.
UniformDimensionedField(const IOobject &, const bool read=true)
Construct from IO object.
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
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