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-2026 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 time
250  const Time& time() const;
251 
252  //- Return patch
253  const LagrangianPatch& patch() const;
254 
255  //- Return internal dimensions reference
256  const dimensionSet& internalDimensions() const;
257 
258  //- Return internal field reference
260 
261  //- Generate an internal sub field corresponding to this patch
263 
264  //- Generate a primitive sub field corresponding to this patch
266 
267  //- Return the type of the calculated form of LagrangianPatchField
268  static const word& calculatedType();
269 
270 
271  //- Reset to the given LagrangianPatchField
272  virtual void reset(const LagrangianPatchField<Type>&);
273 
274 
275  // Evaluation
276 
277  //- Initialise evaluation of the patch field
278  virtual void initEvaluate
279  (
282  );
283 
284  //- Evaluate the patch field
285  virtual void evaluate
286  (
289  );
290 
291 
292  // I-O
293 
294  //- Write
295  virtual void write(Ostream&) const;
296 
297 
298  // Member Operators
299 
300  //- Generate a sub-sub field corresponding to this patch
302 
303  //- Define assignment and compound assignment operations
304  #define MEMBER_OPERATOR(MemberOp, OtherType) \
305  virtual void operator MemberOp \
306  ( \
307  const LagrangianPatchField<OtherType>& \
308  ); \
309  virtual void operator MemberOp \
310  ( \
311  const LagrangianSubField<OtherType>& \
312  ); \
313  virtual void operator MemberOp \
314  ( \
315  const LagrangianSubSubField<OtherType>& \
316  ); \
317  virtual void operator MemberOp(const UList<OtherType>&); \
318  virtual void operator MemberOp(const OtherType&)
319  MEMBER_OPERATOR(=, Type);
320  MEMBER_OPERATOR(==, Type);
321  MEMBER_OPERATOR(+=, Type);
322  MEMBER_OPERATOR(-=, Type);
323  MEMBER_OPERATOR(*=, scalar);
324  MEMBER_OPERATOR(/=, scalar);
325  #undef MEMBER_OPERATOR
326 
327  //- Ostream operator
328  friend Ostream& operator<< <Type>
329  (
330  Ostream&,
332  );
333 };
334 
335 
336 template<class Type>
337 const LagrangianPatchField<Type>& operator+
338 (
339  const LagrangianPatchField<Type>& ptf,
340  const Type&
341 )
342 {
343  return ptf;
344 }
345 
346 
347 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
348 
349 } // End namespace Foam
350 
351 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
352 
354 
355 #ifdef NoRepository
356  #include "LagrangianPatchField.C"
358 #endif
359 
360 
361 #define addToLagrangianPatchFieldRunTimeSelection( \
362  PatchTypeField, typePatchTypeField) \
363  addToRunTimeSelectionTable \
364  ( \
365  PatchTypeField, \
366  typePatchTypeField, \
367  dictionary \
368  );
369 
370 
371 #define addNullConstructableToLagrangianPatchFieldRunTimeSelection( \
372  PatchTypeField, typePatchTypeField) \
373  addToRunTimeSelectionTable \
374  ( \
375  PatchTypeField, \
376  typePatchTypeField, \
377  LagrangianPatch \
378  ); \
379  addToLagrangianPatchFieldRunTimeSelection \
380  ( \
381  PatchTypeField, \
382  typePatchTypeField \
383  )
384 
385 
386 #define makeLagrangianPatchTypeField( \
387  PatchTypeField, typePatchTypeField) \
388  defineTypeNameAndDebug(typePatchTypeField, 0); \
389  addToLagrangianPatchFieldRunTimeSelection \
390  ( \
391  PatchTypeField, \
392  typePatchTypeField \
393  )
394 
395 
396 #define makeNullConstructableLagrangianPatchTypeField( \
397  PatchTypeField, typePatchTypeField) \
398  defineTypeNameAndDebug(typePatchTypeField, 0); \
399  addNullConstructableToLagrangianPatchFieldRunTimeSelection \
400  ( \
401  PatchTypeField, \
402  typePatchTypeField \
403  )
404 
405 
406 #define makeTemplateLagrangianPatchTypeField(fieldType, type) \
407  defineNamedTemplateTypeNameAndDebug \
408  ( \
409  CAT4(type, LagrangianPatch, CAPITALIZE(fieldType), Field), \
410  0 \
411  ); \
412  addToLagrangianPatchFieldRunTimeSelection \
413  ( \
414  CAT3(LagrangianPatch, CAPITALIZE(fieldType), Field), \
415  CAT4(type, LagrangianPatch, CAPITALIZE(fieldType), Field) \
416  )
417 
418 
419 #define makeNullConstructableTemplateLagrangianPatchTypeField(fieldType, type) \
420  defineNamedTemplateTypeNameAndDebug \
421  ( \
422  CAT4(type, LagrangianPatch, CAPITALIZE(fieldType), Field), \
423  0 \
424  ); \
425  addNullConstructableToLagrangianPatchFieldRunTimeSelection \
426  ( \
427  CAT3(LagrangianPatch, CAPITALIZE(fieldType), Field), \
428  CAT4(type, LagrangianPatch, CAPITALIZE(fieldType), Field) \
429  )
430 
431 
432 #define makeLagrangianPatchFields(type) \
433  FOR_ALL_FIELD_TYPES \
434  ( \
435  makeTemplateLagrangianPatchTypeField, \
436  type \
437  )
438 
439 
440 #define makeNullConstructableLagrangianPatchFields(type) \
441  FOR_ALL_FIELD_TYPES \
442  ( \
443  makeNullConstructableTemplateLagrangianPatchTypeField, \
444  type \
445  )
446 
447 
448 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
449 
450 #endif
451 
452 // ************************************************************************* //
#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.
const Time & time() const
Return time.
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 LagrangianInternalScalarDynamicField &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.
virtual void evaluate(PstreamBuffers &, const LagrangianInternalScalarDynamicField &fraction)
Evaluate the patch field.
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.
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
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:76
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:63
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:381
const unitSet fraction
Namespace for OpenFOAM.
word patchFieldType(const PatchField &pf)
Ostream & operator<<(Ostream &os, const fvConstraints &constraints)
dictionary dict
volScalarField & p