Loading...
Searching...
No Matches
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 Copyright (C) 2022 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::UniformDimensionedField
29
30Description
31 Dimensioned<Type> registered with the database as a registered IOobject
32 which has the functionality of a uniform field and allows values from the
33 top-level code to be passed to boundary conditions etc.
34
35 Is a 'global' field, same on all processors
36
37SourceFiles
38 UniformDimensionedField.C
39
40\*---------------------------------------------------------------------------*/
41
42#ifndef Foam_UniformDimensionedField_H
43#define Foam_UniformDimensionedField_H
44
45#include "regIOobject.H"
46#include "dimensionedType.H"
47
48// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49
50namespace Foam
51{
52
53/*---------------------------------------------------------------------------*\
54 Class UniformDimensionedField Declaration
55\*---------------------------------------------------------------------------*/
56
57template<class Type>
59:
60 public regIOobject,
61 public dimensioned<Type>
62{
63public:
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 (if non-empty)
75 (
76 const IOobject& io,
77 const dimensioned<Type>& dt
78 );
79
80 //- Construct from components. Either reads or uses supplied value.
81 // The name of the IOobject defines the name of the field.
82 // Parameter ordering as per dimensioned<Type>
84 (
85 const IOobject& io,
86 const dimensionSet& dims,
87 const Type& val
88 );
89
90 //- Construct from components. Either reads or uses supplied value.
91 // The name of the IOobject defines the name of the field.
92 // Parameter ordering as per DimensionedField<Type>
94 (
95 const IOobject& io,
96 const Type& val,
97 const dimensionSet& dims
98 );
100 //- Construct as copy
102
103 //- Construct from IOobject. Either reads or sets dimensionless zero
104 explicit UniformDimensionedField(const IOobject& io);
105
106
107 //- Destructor
108 virtual ~UniformDimensionedField() = default;
110
111 // Member Functions
112
113 //- Use name from dimensioned<Type>, not from regIOobject
114 virtual const word& name() const
115 {
117 }
118
119 //- The readData method required for regIOobject read operation
120 virtual bool readData(Istream&);
121
122 //- The writeData method required for regIOobject write operation
123 bool writeData(Ostream&) const;
124
125 //- Is object global
126 virtual bool global() const
127 {
128 return true;
129 }
130
131 //- Return complete path + object name if the file exists
132 //- either in the case/processor or case otherwise null
133 virtual fileName filePath() const
134 {
135 return globalFilePath(type());
137
138
139 // Member Operators
140
141 //- Assign name, dimensions and value of the dimensioned<Type>
143
144 //- Assign name, dimensions and value to the dimensioned<Type>
145 void operator=(const dimensioned<Type>& rhs);
147 //- Return value
148 const Type& operator[](const label) const noexcept
149 {
151 }
152};
153
154
155// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
156
157//- Global file type for UniformDimensionedField
158template<class Type>
159struct is_globalIOobject<UniformDimensionedField<Type>> : std::true_type {};
160
161
162// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
163
164} // End namespace Foam
165
166// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
167
168#ifdef NoRepository
170#endif
172// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
173
174#endif
175
176// ************************************************************************* //
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition IOobject.H:191
fileName globalFilePath(const word &typeName, const bool search=true) const
Redirect to fileHandler filePath, searching up if in parallel.
Definition IOobject.C:604
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition Istream.H:60
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
Dimensioned<Type> registered with the database as a registered IOobject which has the functionality o...
virtual const word & name() const
Use name from dimensioned<Type>, not from regIOobject.
virtual ~UniformDimensionedField()=default
Destructor.
TypeName("UniformDimensionedField")
Runtime type information.
bool writeData(Ostream &) const
The writeData method required for regIOobject write operation.
virtual bool global() const
Is object global.
const Type & operator[](const label) const noexcept
Return value.
UniformDimensionedField(const IOobject &io, const Type &val, const dimensionSet &dims)
Construct from components. Either reads or uses supplied value.
UniformDimensionedField(const IOobject &io)
Construct from IOobject. Either reads or sets dimensionless zero.
UniformDimensionedField(const IOobject &io, const dimensionSet &dims, const Type &val)
Construct from components. Either reads or uses supplied value.
UniformDimensionedField(const IOobject &io, const dimensioned< Type > &dt)
Construct from components. Either reads or uses supplied value.
void operator=(const UniformDimensionedField< Type > &rhs)
Assign name, dimensions and value of the dimensioned<Type>.
UniformDimensionedField(const UniformDimensionedField< Type > &)
Construct as copy.
virtual fileName filePath() const
Return complete path + object name if the file exists either in the case/processor or case otherwise ...
virtual bool readData(Istream &)
The readData method required for regIOobject read operation.
void operator=(const dimensioned< Type > &rhs)
Assign name, dimensions and value to the dimensioned<Type>.
Dimension set for the base types, which can be used to implement rigorous dimension checking for alge...
dimensioned()
A dimensionless Zero, named "0".
const word & name() const noexcept
Return const reference to name.
const Type & value() const noexcept
Return const reference to value.
A class for handling file names.
Definition fileName.H:75
regIOobject(const IOobject &io, const bool isTimeObject=false)
Construct from IOobject. The optional flag adds special handling if the object is the top-level regIO...
Definition regIOobject.C:43
A class for handling words, derived from Foam::string.
Definition word.H:66
const auto & io
Namespace for OpenFOAM.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition POSIX.C:801
void rhs(fvMatrix< typename Expr::value_type > &m, const Expr &expression)
Trait for specifying global vs. local IOobject file types.
Definition IOobject.H:175
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68