Loading...
Searching...
No Matches
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-2024 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 Foam_PatchFunction1Types_UniformValueField_H
44#define Foam_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 setting patch
96 explicit UniformValueField
97 (
99 const polyPatch& pp
100 );
101
102 //- Copy construct
104
105 //- Return a clone
106 virtual tmp<PatchFunction1<Type>> clone() const
107 {
108 return PatchFunction1<Type>::Clone(*this);
109 }
110
111 //- Return a clone, setting the patch
112 virtual tmp<PatchFunction1<Type>> clone(const polyPatch& pp) const
114 return PatchFunction1<Type>::Clone(*this, pp);
115 }
116
117
118 //- Destructor
119 virtual ~UniformValueField() = default;
120
122 // Member Functions
123
124 //- Is value constant (i.e. independent of x)
125 virtual inline bool constant() const
126 {
127 return (uniformValuePtr_ && uniformValuePtr_->constant());
128 }
129
130 //- Can function be evaluated?
131 virtual inline bool good() const
132 {
133 return (uniformValuePtr_ && uniformValuePtr_->good());
134 }
135
136 //- Is value uniform (i.e. independent of coordinate)
137 virtual inline bool uniform() const
140 }
141
142
143 // Evaluation
144
145 //- Return UniformValueField value
146 virtual inline tmp<Field<Type>> value(const scalar x) const;
147
148 //- Integrate between two values
149 virtual inline tmp<Field<Type>> integrate
150 (
151 const scalar x1,
152 const scalar x2
153 ) const;
155
156 // Mapping
157
158 //- Map (and resize as needed) from self given a mapping object
159 virtual void autoMap(const FieldMapper& mapper);
160
161 //- Reverse map the given PatchFunction1 onto this PatchFunction1
162 virtual void rmap
163 (
164 const PatchFunction1<Type>& pf1,
165 const labelList& addr
166 );
167
168
169 // I-O
170
171 //- Write in dictionary format
172 virtual void writeData(Ostream& os) const;
173};
174
175
176// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
177
178} // End namespace PatchFunction1Types
179} // End namespace Foam
180
181// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
182
183// Macros
184
185#undef addUniformValueFieldFunction1s
186#define addUniformValueFieldFunction1s(F1Name, Type) \
187 PatchFunction1<Type>::adddictionaryConstructorToTable \
188 <PatchFunction1Types::UniformValueField<Type>> \
189 add##F1Name##UniformValueField##Type##ConstructorToTable_(#F1Name);
190
191
192// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
193
194#include "UniformValueFieldI.H"
195
196#ifdef NoRepository
197 #include "UniformValueField.C"
198#endif
199
200// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
201
202#endif
203
204// ************************************************************************* //
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
Abstract base class to hold the Field mapping addressing and weights.
Definition FieldMapper.H:44
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
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
Return a clone, setting the 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
Return a clone.
virtual bool good() const
Can function be evaluated?
UniformValueField(const polyPatch &pp, const word &redirectType, const word &entryName, const dictionary &dict, const bool faceValues=true)
Construct from entry name and dictionary.
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
static tmp< PatchFunction1< Type > > Clone(const Derived &fun)
Clone a PatchFunction1.
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:65
A patch is a list of labels that address the faces in the global face list.
Definition polyPatch.H:73
A class for managing temporary objects.
Definition tmp.H:75
A class for handling words, derived from Foam::string.
Definition word.H:66
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
List< label > labelList
A List of labels.
Definition List.H:62
void rhs(fvMatrix< typename Expr::value_type > &m, const Expr &expression)
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68