UniformValueField.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) 2018-2021 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
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
26Class
27 Foam::PatchFunction1Types::UniformValueField
28
29Description
30 Templated function that returns a uniform field based on a run-time
31 selectable Function1 entry.
32
33 Usage - for entry <entryName> returning the value <value>:
34 \verbatim
35 <entryName> uniformValue
36 \endverbatim
37
38SourceFiles
39 UniformValueField.C
40
41\*---------------------------------------------------------------------------*/
42
43#ifndef PatchFunction1Types_UniformValueField_H
44#define PatchFunction1Types_UniformValueField_H
45
46#include "PatchFunction1.H"
47#include "Function1.H"
48
49// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50
51namespace Foam
52{
53namespace PatchFunction1Types
54{
55
56/*---------------------------------------------------------------------------*\
57 Class UniformValueField Declaration
58\*---------------------------------------------------------------------------*/
59
60template<class Type>
62:
63 public PatchFunction1<Type>
64{
65 // Private Data
66
67 //- Source of uniform values (in local coordinate system)
68 autoPtr<Foam::Function1<Type>> uniformValuePtr_;
69
70
71public:
72
73 // Runtime type information
74 TypeName("uniformValue");
75
76
77 // Generated Methods
78
79 //- No copy assignment
80 void operator=(const UniformValueField<Type>&) = delete;
81
82
83 // Constructors
84
85 //- Construct from entry name and dictionary
87 (
88 const polyPatch& pp,
89 const word& redirectType,
90 const word& entryName,
91 const dictionary& dict,
92 const bool faceValues = true
93 );
94
95 //- Copy construct
96 explicit UniformValueField(const UniformValueField<Type>& rhs);
97
98 //- Copy construct setting patch
99 explicit UniformValueField
100 (
101 const UniformValueField<Type>& rhs,
102 const polyPatch& pp
103 );
104
105 //- Construct and return a clone
106 virtual tmp<PatchFunction1<Type>> clone() const
107 {
109 (
110 new UniformValueField<Type>(*this)
111 );
112 }
113
114 //- Construct and return a clone setting patch
115 virtual tmp<PatchFunction1<Type>> clone(const polyPatch& pp) const
116 {
118 (
119 new UniformValueField<Type>(*this, pp)
120 );
121 }
122
123
124 //- Destructor
125 virtual ~UniformValueField() = default;
126
127
128 // Member Functions
129
130 //- Is value constant (i.e. independent of x)
131 virtual inline bool constant() const
132 {
133 return (uniformValuePtr_ && uniformValuePtr_->constant());
134 }
135
136 //- Can function be evaluated?
137 virtual inline bool good() const
138 {
139 return (uniformValuePtr_ && uniformValuePtr_->good());
140 }
141
142 //- Is value uniform (i.e. independent of coordinate)
143 virtual inline bool uniform() const
144 {
146 }
147
148
149 // Evaluation
150
151 //- Return UniformValueField value
152 virtual inline tmp<Field<Type>> value(const scalar x) const;
153
154 //- Integrate between two values
155 virtual inline tmp<Field<Type>> integrate
156 (
157 const scalar x1,
158 const scalar x2
159 ) const;
160
161
162 // Mapping
163
164 //- Map (and resize as needed) from self given a mapping object
165 virtual void autoMap(const FieldMapper& mapper);
166
167 //- Reverse map the given PatchFunction1 onto this PatchFunction1
168 virtual void rmap
169 (
170 const PatchFunction1<Type>& pf1,
171 const labelList& addr
172 );
173
174
175 // I-O
176
177 //- Write in dictionary format
178 virtual void writeData(Ostream& os) const;
179};
180
181
182// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
183
184} // End namespace PatchFunction1Types
185} // End namespace Foam
186
187// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
188
189// Macros
190
191#undef addUniformValueFieldFunction1s
192#define addUniformValueFieldFunction1s(F1Name, Type) \
193 PatchFunction1<Type>::adddictionaryConstructorToTable \
194 <PatchFunction1Types::UniformValueField<Type>> \
195 add##F1Name##UniformValueField##Type##ConstructorToTable_(#F1Name);
196
197
198// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
199
200#include "UniformValueFieldI.H"
201
202#ifdef NoRepository
203 #include "UniformValueField.C"
204#endif
205
206// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
207
208#endif
209
210// ************************************************************************* //
Abstract base class to hold the Field mapping addressing and weights.
Definition: FieldMapper.H:50
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
Templated function that returns a uniform field based on a run-time selectable Function1 entry.
virtual tmp< Field< Type > > integrate(const scalar x1, const scalar x2) const
Integrate between two values.
virtual bool uniform() const
Is value uniform (i.e. independent of coordinate)
virtual void rmap(const PatchFunction1< Type > &pf1, const labelList &addr)
Reverse map the given PatchFunction1 onto this PatchFunction1.
virtual void autoMap(const FieldMapper &mapper)
Map (and resize as needed) from self given a mapping object.
virtual void writeData(Ostream &os) const
Write in dictionary format.
virtual tmp< PatchFunction1< Type > > clone(const polyPatch &pp) const
Construct and return a clone setting patch.
virtual bool constant() const
Is value constant (i.e. independent of x)
virtual tmp< Field< Type > > value(const scalar x) const
Return UniformValueField value.
virtual tmp< PatchFunction1< Type > > clone() const
Construct and return a clone.
virtual bool good() const
Can function be evaluated?
void operator=(const UniformValueField< Type > &)=delete
No copy assignment.
virtual ~UniformValueField()=default
Destructor.
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
const polyPatch const word const word & entryName
virtual bool uniform() const =0
Is value uniform (i.e. independent of coordinate)
const polyPatch const word const word const dictionary & dict
const polyPatch & pp
const polyPatch const word const word const dictionary const bool faceValues
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
bool good() const noexcept
True if the managed pointer is non-null.
Definition: autoPtr.H:145
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:75
A class for managing temporary objects.
Definition: tmp.H:65
A class for handling words, derived from Foam::string.
Definition: word.H:68
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73