LagrangianPatchField.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2025 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::LagrangianPatchField
26 
27 Description
28  Base class for Lagrangian boundary conditions
29 
30 SourceFiles
31  LagrangianPatchField.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef LagrangianPatchField_H
36 #define LagrangianPatchField_H
37 
38 #include "LagrangianPatch.H"
39 #include "LagrangianFieldsFwd.H"
40 #include "SubField.H"
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 namespace Foam
45 {
46 
47 // Forward declaration of classes
48 class objectRegistry;
49 class dictionary;
50 class LagrangianMesh;
51 class LagrangianSubMesh;
52 
53 template<class Type>
54 class LagrangianPatchField;
55 
56 template<class Type>
57 class calculatedLagrangianPatchField;
58 
59 // Forward declaration of friend functions and operators
60 template<class Type>
62 
63 /*---------------------------------------------------------------------------*\
64  Class LagrangianPatchField Declaration
65 \*---------------------------------------------------------------------------*/
66 
67 template<class Type>
69 {
70  // Private Data
71 
72  //- Reference to patch
73  const LagrangianPatch& patch_;
74 
75 
76 protected:
77 
78  // Protected Data
79 
80  //- Reference to the internal IO object
81  const regIOobject& internalIo_;
82 
83  //- Reference to the internal field
85 
86  //- Reference to the non-dynamic internal field
88 
89 
90 public:
91 
92  //- Declare friendship with patch fields of different types
93  template<class Type2>
94  friend class LagrangianPatchField;
95 
96 
97  // Public Type Definitions
98 
99  //- The patch type
100  typedef LagrangianPatch Patch;
101 
102  //- The calculated patch field type
104 
105 
106  //- Runtime type information
107  TypeName("LagrangianPatchField");
108 
109 
110  //- Debug switch to disallow the use of genericLagrangianPatchField
112 
113 
114  // Declare run-time constructor selection tables
115 
116  //- Select given patch and internal field
118  (
119  autoPtr,
122  (
123  const LagrangianPatch& p,
124  const regIOobject& iIo
125  ),
126  (p, iIo)
127  );
128 
129  //- Select given patch, internal field and dictionary
131  (
132  autoPtr,
134  dictionary,
135  (
136  const LagrangianPatch& p,
137  const regIOobject& iIo,
138  const dictionary& dict
139  ),
140  (p, iIo, dict)
141  );
142 
143 
144  // Constructors
145 
146  //- Construct from patch and internal field
148  (
149  const LagrangianPatch&,
150  const regIOobject&
151  );
152 
153  //- Construct from patch, internal field and dictionary
155  (
156  const LagrangianPatch&,
157  const regIOobject&,
158  const dictionary&
159  );
160 
161  //- Construct as copy
163 
164  //- Construct as copy setting the internal field reference
166  (
168  const regIOobject&
169  );
170 
171  //- Construct as copy setting the patch and the internal field reference
173  (
175  const LagrangianPatch&,
176  const regIOobject&
177  );
178 
179  //- Construct and return a clone
180  virtual autoPtr<LagrangianPatchField<Type>> clone() const = 0;
181 
182  //- Construct and return a clone setting the internal field reference
184  (
185  const regIOobject&
186  ) const = 0;
187 
188  //- Construct and return a clone onto a new patch
189  // and setting the internal field reference
191  (
192  const LagrangianPatch&,
193  const regIOobject&
194  ) const
195  {
197  return autoPtr<LagrangianPatchField<Type>>(nullptr);
198  }
199 
200 
201  // Selectors
202 
203  //- Return a pointer to a new LagrangianPatchField with a given type
204  // name, corresponding to a LagrangianPatch and internal field
206  (
207  const word& patchFieldType,
208  const word& actualPatchType,
209  const LagrangianPatch& p,
210  const regIOobject&
211  );
212 
213  //- Return a pointer to a new LagrangianPatchField with a given type
214  // name, corresponding to a LagrangianPatch and internal field
216  (
217  const word&,
218  const LagrangianPatch&,
219  const regIOobject&
220  );
221 
222  //- Return a pointer to a new LagrangianPatchField corresponding to a
223  // LagrangianPatch and internal field, with type and parameters
224  // specified in a dictionary
226  (
227  const LagrangianPatch&,
228  const regIOobject&,
229  const dictionary&
230  );
231 
232  //- Return a pointer to a new calculatedPointPatchField
233  template<class Type2>
236 
237 
238  //- Destructor
239  virtual ~LagrangianPatchField();
240 
241 
242  // Member Functions
243 
244  // Access
245 
246  //- Return local objectRegistry
247  const objectRegistry& db() const;
248 
249  //- Return patch
250  const LagrangianPatch& patch() const;
251 
252  //- Return internal dimensions reference
253  const dimensionSet& internalDimensions() const;
254 
255  //- Return internal field reference
257 
258  //- Generate an internal sub field corresponding to this patch
260 
261  //- Generate a primitive sub field corresponding to this patch
263 
264  //- Return the type of the calculated form of LagrangianPatchField
265  static const word& calculatedType();
266 
267 
268  //- Reset to the given LagrangianPatchField
269  virtual void reset(const LagrangianPatchField<Type>&);
270 
271 
272  // Evaluation
273 
274  //- Initialise evaluation of the patch field
275  virtual void initEvaluate
276  (
279  );
280 
281  //- Evaluate the patch field
282  virtual void evaluate
283  (
286  );
287 
288 
289  // I-O
290 
291  //- Write
292  virtual void write(Ostream&) const;
293 
294 
295  // Member Operators
296 
297  //- Generate a sub-sub field corresponding to this patch
299 
300  //- Define assignment and compound assignment operations
301  #define MEMBER_OPERATOR(MemberOp, OtherType) \
302  virtual void operator MemberOp \
303  ( \
304  const LagrangianPatchField<OtherType>& \
305  ); \
306  virtual void operator MemberOp \
307  ( \
308  const LagrangianSubField<OtherType>& \
309  ); \
310  virtual void operator MemberOp \
311  ( \
312  const LagrangianSubSubField<OtherType>& \
313  ); \
314  virtual void operator MemberOp(const UList<OtherType>&); \
315  virtual void operator MemberOp(const OtherType&)
316  MEMBER_OPERATOR(=, Type);
317  MEMBER_OPERATOR(==, Type);
318  MEMBER_OPERATOR(+=, Type);
319  MEMBER_OPERATOR(-=, Type);
320  MEMBER_OPERATOR(*=, scalar);
321  MEMBER_OPERATOR(/=, scalar);
322  #undef MEMBER_OPERATOR
323 
324  //- Ostream operator
325  friend Ostream& operator<< <Type>
326  (
327  Ostream&,
329  );
330 };
331 
332 
333 template<class Type>
334 const LagrangianPatchField<Type>& operator+
335 (
336  const LagrangianPatchField<Type>& ptf,
337  const Type&
338 )
339 {
340  return ptf;
341 }
342 
343 
344 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
345 
346 } // End namespace Foam
347 
348 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
349 
351 
352 #ifdef NoRepository
353  #include "LagrangianPatchField.C"
355 #endif
356 
357 
358 #define addToLagrangianPatchFieldRunTimeSelection( \
359  PatchTypeField, typePatchTypeField) \
360  addToRunTimeSelectionTable \
361  ( \
362  PatchTypeField, \
363  typePatchTypeField, \
364  dictionary \
365  );
366 
367 
368 #define addNullConstructableToLagrangianPatchFieldRunTimeSelection( \
369  PatchTypeField, typePatchTypeField) \
370  addToRunTimeSelectionTable \
371  ( \
372  PatchTypeField, \
373  typePatchTypeField, \
374  LagrangianPatch \
375  ); \
376  addToLagrangianPatchFieldRunTimeSelection \
377  ( \
378  PatchTypeField, \
379  typePatchTypeField \
380  )
381 
382 
383 #define makeLagrangianPatchTypeField( \
384  PatchTypeField, typePatchTypeField) \
385  defineTypeNameAndDebug(typePatchTypeField, 0); \
386  addToLagrangianPatchFieldRunTimeSelection \
387  ( \
388  PatchTypeField, \
389  typePatchTypeField \
390  )
391 
392 
393 #define makeNullConstructableLagrangianPatchTypeField( \
394  PatchTypeField, typePatchTypeField) \
395  defineTypeNameAndDebug(typePatchTypeField, 0); \
396  addNullConstructableToLagrangianPatchFieldRunTimeSelection \
397  ( \
398  PatchTypeField, \
399  typePatchTypeField \
400  )
401 
402 
403 #define makeTemplateLagrangianPatchTypeField(fieldType, type) \
404  defineNamedTemplateTypeNameAndDebug \
405  ( \
406  CAT4(type, LagrangianPatch, CAPITALIZE(fieldType), Field), \
407  0 \
408  ); \
409  addToLagrangianPatchFieldRunTimeSelection \
410  ( \
411  CAT3(LagrangianPatch, CAPITALIZE(fieldType), Field), \
412  CAT4(type, LagrangianPatch, CAPITALIZE(fieldType), Field) \
413  )
414 
415 
416 #define makeNullConstructableTemplateLagrangianPatchTypeField(fieldType, type) \
417  defineNamedTemplateTypeNameAndDebug \
418  ( \
419  CAT4(type, LagrangianPatch, CAPITALIZE(fieldType), Field), \
420  0 \
421  ); \
422  addNullConstructableToLagrangianPatchFieldRunTimeSelection \
423  ( \
424  CAT3(LagrangianPatch, CAPITALIZE(fieldType), Field), \
425  CAT4(type, LagrangianPatch, CAPITALIZE(fieldType), Field) \
426  )
427 
428 
429 #define makeLagrangianPatchFields(type) \
430  FOR_ALL_FIELD_TYPES \
431  ( \
432  makeTemplateLagrangianPatchTypeField, \
433  type \
434  )
435 
436 
437 #define makeNullConstructableLagrangianPatchFields(type) \
438  FOR_ALL_FIELD_TYPES \
439  ( \
440  makeNullConstructableTemplateLagrangianPatchTypeField, \
441  type \
442  )
443 
444 
445 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
446 
447 #endif
448 
449 // ************************************************************************* //
#define MEMBER_OPERATOR(MemberOp, OtherType)
Define assignment and compound assignment operations.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Base class for Lagrangian boundary conditions.
virtual ~LagrangianPatchField()
Destructor.
static autoPtr< LagrangianPatchField< Type > > New(const word &patchFieldType, const word &actualPatchType, const LagrangianPatch &p, const regIOobject &)
Return a pointer to a new LagrangianPatchField with a given type.
const dimensionSet & internalDimensions() const
Return internal dimensions reference.
tmp< LagrangianSubSubField< Type > > operator()() const
Generate a sub-sub field corresponding to this patch.
virtual void write(Ostream &) const
Write.
LagrangianPatch Patch
The patch type.
calculatedLagrangianPatchField< Type > Calculated
The calculated patch field type.
const LagrangianInternalDynamicField< Type > & internalField_
Reference to the internal field.
virtual void reset(const LagrangianPatchField< Type > &)
Reset to the given LagrangianPatchField.
const LagrangianPatch & patch() const
Return patch.
const LagrangianInternalField< Type > & internalNonDynamicField_
Reference to the non-dynamic internal field.
static autoPtr< LagrangianPatchField< Type > > NewCalculatedType(const LagrangianPatchField< Type2 > &)
Return a pointer to a new calculatedPointPatchField.
const regIOobject & internalIo_
Reference to the internal IO object.
const objectRegistry & db() const
Return local objectRegistry.
TypeName("LagrangianPatchField")
Runtime type information.
virtual void initEvaluate(PstreamBuffers &, const LagrangianScalarInternalDynamicField &fraction)
Initialise evaluation of the patch field.
friend class LagrangianPatchField
Declare friendship with patch fields of different types.
static int disallowGenericLagrangianPatchField
Debug switch to disallow the use of genericLagrangianPatchField.
virtual autoPtr< LagrangianPatchField< Type > > clone() const =0
Construct and return a clone.
tmp< LagrangianSubSubField< Type > > internalSubField() const
Generate an internal sub field corresponding to this patch.
SubField< Type > primitiveSubField() const
Generate a primitive sub field corresponding to this patch.
const LagrangianInternalDynamicField< Type > & internalField() const
Return internal field reference.
static const word & calculatedType()
Return the type of the calculated form of LagrangianPatchField.
virtual void evaluate(PstreamBuffers &, const LagrangianScalarInternalDynamicField &fraction)
Evaluate the patch field.
declareRunTimeSelectionTable(autoPtr, LagrangianPatchField, LagrangianPatch,(const LagrangianPatch &p, const regIOobject &iIo),(p, iIo))
Select given patch and internal field.
Base class for Lagrangian patches.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
Buffers for inter-processor communications streams (UOPstream, UIPstream).
Pre-declare related SubField type.
Definition: SubField.H:63
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A calculated boundary condition for Lagrangian. This condition does not provide any evaluation functi...
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Dimension set for the base types.
Definition: dimensionSet.H:125
Registry of regIOobjects.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:55
A class for managing temporary objects.
Definition: tmp.H:55
A class for handling words, derived from string.
Definition: word.H:62
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:381
Namespace for OpenFOAM.
word patchFieldType(const PatchField &pf)
Ostream & operator<<(Ostream &os, const fvConstraints &constraints)
dictionary dict
volScalarField & p