PatchFunction1.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-2020 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
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 
26 Class
27  Foam::PatchFunction1
28 
29 Description
30  Top level data entry class for use in dictionaries. Provides a mechanism
31  to specify a variable as a certain type, e.g. constant or time varying, and
32  provide functions to return the (interpolated) value, and integral between
33  limits.
34 
35  Extends the Function1 class by adding autoMap and rMap functions
36 
37 SourceFiles
38  PatchFunction1.C
39  PatchFunction1New.C
40 
41 SeeAlso
42  Foam::Function1
43 
44 \*---------------------------------------------------------------------------*/
45 
46 #ifndef PatchFunction1_H
47 #define PatchFunction1_H
48 
49 #include "patchFunction1Base.H"
50 #include "coordinateScaling.H"
51 #include "Field.H"
52 
53 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
54 
55 namespace Foam
56 {
57 
58 // Forward Declarations
59 class Time;
60 template<class Type> class PatchFunction1;
61 
62 template<class Type>
64 
65 /*---------------------------------------------------------------------------*\
66  Class PatchFunction1 Declaration
67 \*---------------------------------------------------------------------------*/
68 
69 template<class Type>
70 class PatchFunction1
71 :
72  public patchFunction1Base
73 {
74  // Private Member Functions
75 
76  //- Selector, with alternative entry etc
78  (
79  const polyPatch& pp,
80  const word& entryName,
81  const entry* eptr,
82  const dictionary& dict,
83  const bool faceValues,
84  const bool mandatory
85  );
86 
87 
88 protected:
89 
90  // Protected Data
91 
92  //- Optional local co-ordinate system and scaling
94 
95 
96  // Protected Member Functions
97 
98  //- No copy assignment
99  void operator=(const PatchFunction1<Type>&) = delete;
100 
101 
102 public:
103 
104  typedef Field<Type> returnType;
105 
106  //- Runtime type information
107  TypeName("PatchFunction1")
108 
109  //- Declare runtime constructor selection table
111  (
114  dictionary,
115  (
116  const polyPatch& pp,
117  const word& type,
118  const word& entryName,
119  const dictionary& dict,
120  const bool faceValues
121  ),
123  );
124 
125 
126  // Constructors
127 
128  //- Construct from polyPatch and entry name
130  (
131  const polyPatch& pp,
132  const word& entryName,
133  const bool faceValues = true
134  );
135 
136  //- Construct from polyPatch, dictionary and entry name
138  (
139  const polyPatch& pp,
140  const word& entryName,
141  const dictionary& dict,
142  const bool faceValues = true
143  );
144 
145  //- Copy construct
146  explicit PatchFunction1(const PatchFunction1<Type>& rhs);
147 
148  //- Copy construct setting patch
149  explicit PatchFunction1
150  (
151  const PatchFunction1<Type>& rhs,
152  const polyPatch& pp
153  );
154 
155  //- Return a clone
156  virtual tmp<PatchFunction1<Type>> clone() const = 0;
157 
158  //- Return a clone, setting patch
159  virtual tmp<PatchFunction1<Type>> clone(const polyPatch& pp) const = 0;
160 
161 
162  // Selectors
163 
164  //- Selector
165  static autoPtr<PatchFunction1<Type>> New
166  (
167  const polyPatch& pp,
168  const word& entryName,
169  const dictionary& dict,
170  const bool faceValues = true,
171  const bool mandatory = true
172  );
173 
174  //- Compatibility selector
175  static autoPtr<PatchFunction1<Type>> NewCompat
176  (
177  const polyPatch& pp,
178  const word& entryName,
179  std::initializer_list<std::pair<const char*,int>> compat,
180  const dictionary& dict,
181  const bool faceValues = true,
182  const bool mandatory = true
183  );
184 
185  //- An optional selector
186  static autoPtr<PatchFunction1<Type>> NewIfPresent
187  (
188  const polyPatch& pp,
189  const word& entryName,
190  const dictionary& dict,
191  const bool faceValues = true
192  );
193 
194 
195  //- Destructor
196  virtual ~PatchFunction1() = default;
197 
198 
199  // Member Functions
200 
201  // Evaluation
202 
203  //- Return value as a function of (scalar) independent variable
204  virtual tmp<Field<Type>> value(const scalar x) const;
205 
206  //- Is value constant (i.e. independent of x)
207  virtual bool constant() const = 0;
208 
209  //- Is value uniform (i.e. independent of coordinate)
210  virtual bool uniform() const = 0;
211 
212  //- Integrate between two (scalar) values
213  virtual tmp<Field<Type>> integrate
214  (
215  const scalar x1,
216  const scalar x2
217  ) const;
218 
219  //- Helper: optionally convert coordinates to local coordinates
220  virtual tmp<pointField> localPosition
221  (
222  const pointField& globalPos
223  ) const;
224 
225  //- Apply optional transformation
226  virtual tmp<Field<Type>> transform(const Field<Type>& fld) const;
227 
228  //- Apply optional transformation
229  virtual tmp<Field<Type>> transform
230  (
231  const tmp<Field<Type>>& tfld
232  ) const;
233 
234 
235  // Mapping
236 
237  //- Map (and resize as needed) from self given a mapping object
238  virtual void autoMap(const FieldMapper& mapper);
239 
240  //- Reverse map the given PatchFunction1 onto this PatchFunction1
241  virtual void rmap
242  (
243  const PatchFunction1<Type>& rhs,
244  const labelList& addr
245  );
246 
247 
248  // I/O
249 
250  //- Ostream Operator
251  friend Ostream& operator<< <Type>
252  (
253  Ostream& os,
254  const PatchFunction1<Type>& rhs
255  );
256 
257  //- Write in dictionary format
258  virtual void writeData(Ostream& os) const;
259 };
260 
261 
262 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
263 
264 } // End namespace Foam
265 
266 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
267 
268 // Define PatchFunction1 run-time selection
269 #define makePatchFunction1(Type) \
270  \
271  defineNamedTemplateTypeNameAndDebug(PatchFunction1<Type>, 0); \
272  \
273  defineTemplateRunTimeSelectionTable \
274  ( \
275  PatchFunction1<Type>, \
276  dictionary \
277  );
278 
279 
280 // Define (templated) PatchFunction1, add to (templated) run-time selection
281 #define makePatchFunction1Type(SS, Type) \
282  \
283  defineNamedTemplateTypeNameAndDebug(PatchFunction1Types::SS<Type>, 0); \
284  \
285  PatchFunction1<Type>::adddictionaryConstructorToTable \
286  <PatchFunction1Types::SS<Type>> \
287  add##SS##Type##ConstructorToTable_;
288 
289 
290 // Define (non-templated) PatchFunction1, add to (templated) run-time selection
291 #define makeConcretePatchFunction1Type(SS, Type) \
292  \
293  defineTypeNameAndDebug(SS, 0); \
294  \
295  PatchFunction1<Type>::adddictionaryConstructorToTable \
296  <PatchFunction1Types::SS> \
297  add##SS##Type##ConstructorToTable_;
298 
299 
300 // Define scalar PatchFunction1 and add to (templated) run-time selection
301 #define makeScalarPatchFunction1(SS) \
302  \
303  makeConcretePatchFunction1Type(SS, scalar);
304 
305 
306 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
307 
308 #ifdef NoRepository
309  #include "PatchFunction1.C"
310  #include "PatchFunction1New.C"
311 #endif
312 
313 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
314 
315 #endif
316 
317 // ************************************************************************* //
Foam::entry
A keyword and a list of tokens is an 'entry'.
Definition: entry.H:67
Foam::PatchFunction1::TypeName
TypeName("PatchFunction1") declareRunTimeSelectionTable(autoPtr
Runtime type information.
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::PatchFunction1::localPosition
virtual tmp< pointField > localPosition(const pointField &globalPos) const
Helper: optionally convert coordinates to local coordinates.
Definition: PatchFunction1.C:113
coordinateScaling.H
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::PatchFunction1::writeData
virtual void writeData(Ostream &os) const
Write in dictionary format.
Definition: PatchFunction1.C:184
Foam::PatchFunction1::operator=
void operator=(const PatchFunction1< Type > &)=delete
No copy assignment.
Foam::coordinateScaling
Helper class to wrap coordinate system and component-wise scaling.
Definition: coordinateScaling.H:55
Foam::FieldMapper
Abstract base class to hold the Field mapping addressing and weights.
Definition: FieldMapper.H:49
Foam::PatchFunction1::returnType
Field< Type > returnType
Definition: PatchFunction1.H:103
Foam::PatchFunction1::clone
virtual tmp< PatchFunction1< Type > > clone() const =0
Return a clone.
Foam::PatchFunction1::entryName
const polyPatch const word const word & entryName
Definition: PatchFunction1.H:117
Foam::PatchFunction1::operator
friend Ostream & operator(Ostream &os, const PatchFunction1< Type > &rhs)
Ostream Operator.
patchFunction1Base.H
Foam::PatchFunction1::type
const polyPatch const word & type
Definition: PatchFunction1.H:116
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Foam::uniform
Definition: uniform.H:50
Foam::Field
Generic templated field type.
Definition: Field.H:63
Foam::PatchFunction1::integrate
virtual tmp< Field< Type > > integrate(const scalar x1, const scalar x2) const
Integrate between two (scalar) values.
Definition: PatchFunction1.C:101
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:68
Field.H
PatchFunction1.C
fld
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Definition: gmvOutputLagrangian.H:23
Foam::PatchFunction1::transform
virtual tmp< Field< Type > > transform(const Field< Type > &fld) const
Apply optional transformation.
Definition: PatchFunction1.C:149
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::PatchFunction1
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition: PatchFunction1.H:59
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
PatchFunction1New.C
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::PatchFunction1::pp
const polyPatch & pp
Definition: PatchFunction1.H:115
Foam::PatchFunction1::dict
const polyPatch const word const word const dictionary & dict
Definition: PatchFunction1.H:118
Foam::List< label >
declareRunTimeSelectionTable
#define declareRunTimeSelectionTable(autoPtr, baseType, argNames, argList, parList)
Declare a run-time selection.
Definition: runTimeSelectionTables.H:49
Foam::PatchFunction1::rmap
virtual void rmap(const PatchFunction1< Type > &rhs, const labelList &addr)
Reverse map the given PatchFunction1 onto this PatchFunction1.
Definition: PatchFunction1.C:176
Foam::PatchFunction1::faceValues
const polyPatch const word const word const dictionary const bool faceValues
Definition: PatchFunction1.H:120
x
x
Definition: LISASMDCalcMethod2.H:52
Foam::PatchFunction1::value
virtual tmp< Field< Type > > value(const scalar x) const
Return value as a function of (scalar) independent variable.
Definition: PatchFunction1.C:84
Foam::PatchFunction1::NewCompat
static autoPtr< PatchFunction1< Type > > NewCompat(const polyPatch &pp, const word &entryName, std::initializer_list< std::pair< const char *, int >> compat, const dictionary &dict, const bool faceValues=true, const bool mandatory=true)
Compatibility selector.
Definition: PatchFunction1New.C:185
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::patchFunction1Base
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition: patchFunction1Base.H:59
constant
constant condensation/saturation model.
Foam::PatchFunction1::coordSys_
coordinateScaling< Type > coordSys_
Optional local co-ordinate system and scaling.
Definition: PatchFunction1.H:92
Foam::PatchFunction1::autoMap
virtual void autoMap(const FieldMapper &mapper)
Map (and resize as needed) from self given a mapping object.
Definition: PatchFunction1.C:170
Foam::PatchFunction1::NewIfPresent
static autoPtr< PatchFunction1< Type > > NewIfPresent(const polyPatch &pp, const word &entryName, const dictionary &dict, const bool faceValues=true)
An optional selector.
Definition: PatchFunction1New.C:209