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 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 "dictionary.H"
50 #include "Field.H"
51 #include "polyPatch.H"
52 #include "coordinateScaling.H"
53 
54 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55 
56 namespace Foam
57 {
58 
59 // Forward declarations
60 class Time;
61 
62 // Forward declaration of friend functions and operators
63 template<class Type>
64 class PatchFunction1;
65 
66 template<class Type>
67 Ostream& operator<<
68 (
69  Ostream&,
71 );
72 
73 /*---------------------------------------------------------------------------*\
74  Class PatchFunction1 Declaration
75 \*---------------------------------------------------------------------------*/
76 
77 template<class Type>
78 class PatchFunction1
79 :
80  public refCount
81 {
82  // Private Member Functions
83 
84  //- No copy assignment
85  void operator=(const PatchFunction1<Type>&) = delete;
86 
87 
88 protected:
89 
90  // Protected data
91 
92  //- Name of entry
93  const word name_;
94 
95  //- Reference to the patch
96  const polyPatch& patch_;
97 
98  //- Whether to generate face or point values on patch
99  const bool faceValues_;
100 
101  //- Optional local co-ordinate system and scaling
103 
104 
105 public:
106 
107  typedef Field<Type> returnType;
108 
109  //- Runtime type information
110  TypeName("PatchFunction1")
111 
112  //- Declare runtime constructor selection table
114  (
117  dictionary,
118  (
119  const polyPatch& pp,
120  const word& type,
121  const word& entryName,
122  const dictionary& dict,
123  const bool faceValues
124  ),
126  );
127 
128 
129  // Constructors
130 
131  //- Construct from polyPatch and entry name
133  (
134  const polyPatch& pp,
135  const word& entryName,
136  const bool faceValues = true
137  );
138 
139  //- Construct from polyPatch, dictionary and entry name
141  (
142  const polyPatch& pp,
143  const word& entryName,
144  const dictionary& dict,
145  const bool faceValues = true
146  );
147 
148  //- Copy constructor
149  explicit PatchFunction1(const PatchFunction1<Type>& pf1);
150 
151  //- Copy constructor setting patch
152  explicit PatchFunction1
153  (
154  const PatchFunction1<Type>& pf1,
155  const polyPatch& pp
156  );
157 
158  //- Construct and return a clone
159  virtual tmp<PatchFunction1<Type>> clone() const = 0;
160 
161  //- Construct and return a clone setting patch
162  virtual tmp<PatchFunction1<Type>> clone(const polyPatch& pp) const = 0;
163 
164 
165  //- Selector
166  static autoPtr<PatchFunction1<Type>> New
167  (
168  const polyPatch& pp,
169  const word& entryName,
170  const dictionary& dict,
171  const bool faceValues = true
172  );
173 
174 
175  //- Destructor
176  virtual ~PatchFunction1() = default;
177 
178 
179  // Member Functions
180 
181  // Access
182 
183  //- Return the name of the entry
184  const word& name() const;
185 
186  //- Reference to the patch
187  const polyPatch& patch() const;
188 
189  //- Whether to generate face or point values on patch
190  bool faceValues() const;
191 
192 
193  // Manipulation
194 
195  //- Convert time
196  virtual void convertTimeBase(const Time& t);
197 
198 
199  // Evaluation
200 
201  //- Return value as a function of (scalar) independent variable
202  virtual tmp<Field<Type>> value(const scalar x) const;
203 
204  //- Is value constant (i.e. independent of x)
205  virtual bool constant() const = 0;
206 
207  //- Is value uniform (i.e. independent of coordinate)
208  virtual bool uniform() const = 0;
209 
210  //- Integrate between two (scalar) values
211  virtual tmp<Field<Type>> integrate
212  (
213  const scalar x1,
214  const scalar x2
215  ) const;
216 
217  //- Helper: optionally convert coordinates to local coordinates
218  virtual tmp<pointField> localPosition
219  (
220  const pointField& globalPos
221  ) const;
222 
223  //- Apply optional transformation
224  virtual tmp<Field<Type>> transform(const Field<Type>& fld) const;
225 
226  //- Apply optional transformation
227  virtual tmp<Field<Type>> transform
228  (
229  const tmp<Field<Type>>& tfld
230  ) const;
231 
232 
233  // Mapping
234 
235  //- Map (and resize as needed) from self given a mapping object
236  virtual void autoMap(const FieldMapper& mapper);
237 
238  //- Reverse map the given PatchFunction1 onto this PatchFunction1
239  virtual void rmap
240  (
241  const PatchFunction1<Type>& pf1,
242  const labelList& addr
243  );
244 
245 
246  // I/O
247 
248  //- Ostream Operator
249  friend Ostream& operator<< <Type>
250  (
251  Ostream& os,
252  const PatchFunction1<Type>& func
253  );
254 
255  //- Write in dictionary format
256  virtual void writeData(Ostream& os) const;
257 };
258 
259 
260 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
261 
262 } // End namespace Foam
263 
264 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
265 
266 #define makePatchFunction1(Type) \
267  \
268  defineNamedTemplateTypeNameAndDebug(PatchFunction1<Type>, 0); \
269  \
270  defineTemplateRunTimeSelectionTable \
271  ( \
272  PatchFunction1<Type>, \
273  dictionary \
274  );
275 
276 #define makePatchFunction1Type(SS, Type) \
277  \
278  defineNamedTemplateTypeNameAndDebug(PatchFunction1Types::SS<Type>, 0); \
279  \
280  PatchFunction1<Type>::adddictionaryConstructorToTable \
281  <PatchFunction1Types::SS<Type>> \
282  add##SS##Type##ConstructorToTable_;
283 
284 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
285 
286 #ifdef NoRepository
287  #include "PatchFunction1.C"
288  #include "PatchFunction1New.C"
289 #endif
290 
291 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
292 
293 #endif
294 
295 // ************************************************************************* //
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:154
coordinateScaling.H
Foam::PatchFunction1::New
static autoPtr< PatchFunction1< Type > > New(const polyPatch &pp, const word &entryName, const dictionary &dict, const bool faceValues=true)
Selector.
Definition: PatchFunction1New.C:34
polyPatch.H
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:59
Foam::PatchFunction1::writeData
virtual void writeData(Ostream &os) const
Write in dictionary format.
Definition: PatchFunction1.C:225
Foam::refCount
Reference counter for various OpenFOAM components.
Definition: refCount.H:50
Foam::PatchFunction1::faceValues
bool faceValues() const
Whether to generate face or point values on patch.
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::patch
const polyPatch & patch() const
Reference to the patch.
Definition: PatchFunction1.C:103
Foam::PatchFunction1::faceValues_
const bool faceValues_
Whether to generate face or point values on patch.
Definition: PatchFunction1.H:98
Foam::PatchFunction1::returnType
Field< Type > returnType
Definition: PatchFunction1.H:106
Foam::PatchFunction1::clone
virtual tmp< PatchFunction1< Type > > clone() const =0
Construct and return a clone.
Foam::PatchFunction1::entryName
const polyPatch const word const word & entryName
Definition: PatchFunction1.H:120
Foam::PatchFunction1::type
const polyPatch const word & type
Definition: PatchFunction1.H:119
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:141
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:67
Field.H
PatchFunction1.C
Foam::func
void func(FieldField< Field, Type > &f, const FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Foam::PatchFunction1::operator
friend Ostream & operator(Ostream &os, const PatchFunction1< Type > &func)
Ostream Operator.
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:190
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:63
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:118
Foam::PatchFunction1::convertTimeBase
virtual void convertTimeBase(const Time &t)
Convert time.
Definition: PatchFunction1.C:117
Foam::PatchFunction1::name
const word & name() const
Return the name of the entry.
Definition: PatchFunction1.C:96
Foam::PatchFunction1::patch_
const polyPatch & patch_
Reference to the patch.
Definition: PatchFunction1.H:95
Foam::PatchFunction1::name_
const word name_
Name of entry.
Definition: PatchFunction1.H:92
Foam::PatchFunction1::dict
const polyPatch const word const word const dictionary & dict
Definition: PatchFunction1.H:121
Foam::List< label >
dictionary.H
declareRunTimeSelectionTable
#define declareRunTimeSelectionTable(autoPtr, baseType, argNames, argList, parList)
Declare a run-time selection.
Definition: runTimeSelectionTables.H:49
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:123
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::PatchFunction1::rmap
virtual void rmap(const PatchFunction1< Type > &pf1, const labelList &addr)
Reverse map the given PatchFunction1 onto this PatchFunction1.
Definition: PatchFunction1.C:217
constant
constant condensation/saturation model.
Foam::PatchFunction1::coordSys_
coordinateScaling< Type > coordSys_
Optional local co-ordinate system and scaling.
Definition: PatchFunction1.H:101
Foam::PatchFunction1::autoMap
virtual void autoMap(const FieldMapper &mapper)
Map (and resize as needed) from self given a mapping object.
Definition: PatchFunction1.C:211