LagrangianFieldSource.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::LagrangianFieldSource
26 
27 Description
28  Base class for Lagrangian source conditions
29 
30 SourceFiles
31  LagrangianFieldSource.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef LagrangianFieldSource_H
36 #define LagrangianFieldSource_H
37 
38 #include "dlLibraryTable.H"
39 #include "LagrangianFieldsFwd.H"
40 #include "LagrangianSubFieldsFwd.H"
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 namespace Foam
45 {
46 
47 // Forward declaration of classes
48 class regIOobject;
49 class dimensionSet;
50 class objectRegistry;
51 class dictionary;
52 class LagrangianMesh;
53 class LagrangianSubMesh;
54 class LagrangianModel;
55 class LagrangianSource;
56 class LagrangianInjection;
57 
58 template<class Type>
59 class LagrangianFieldSource;
60 
61 // Forward declaration of friend functions and operators
62 template<class Type>
64 
65 /*---------------------------------------------------------------------------*\
66  Class LagrangianFieldSource Declaration
67 \*---------------------------------------------------------------------------*/
68 
69 template<class Type>
71 {
72  // Private Data
73 
74  //- Optional list of libraries required for this field source value
75  fileNameList libs_;
76 
77  //- Reference to the internal IO object
78  const regIOobject& internalIo_;
79 
80  //- Reference to the internal field
81  const LagrangianInternalDynamicField<Type>& internalField_;
82 
83  //- Reference to the non-dynamic internal field
84  const LagrangianInternalField<Type>& internalNonDynamicField_;
85 
86 
87 public:
88 
89  //- Runtime type information
90  TypeName("LagrangianFieldSource");
91 
92 
93  //- Debug switch to disallow the use of genericLagrangianFieldSource
95 
96 
97  // Declare run-time constructor selection tables
98 
99  //- Select given internal field
101  (
102  autoPtr,
104  null,
105  (
106  const regIOobject& iIo
107  ),
108  (iIo)
109  );
110 
111  //- Select given internal field and dictionary
113  (
114  autoPtr,
116  dictionary,
117  (
118  const regIOobject& iIo,
119  const dictionary& dict
120  ),
121  (iIo, dict)
122  );
123 
124 
125  // Constructors
126 
127  //- Construct from internal field
129 
130  //- Construct from internal field and dictionary
132 
133  //- Disallow copy without setting the internal field reference
135 
136  //- Disallow clone without setting the internal field reference
138  {
140  return autoPtr<LagrangianFieldSource<Type>>(nullptr);
141  }
142 
143  //- Construct as copy setting the internal field reference
145  (
147  const regIOobject&
148  );
149 
150  //- Construct and return a clone setting the internal field reference
152  (
153  const regIOobject&
154  ) const = 0;
155 
156 
157  // Selectors
158 
159  //- Return a pointer to a new field source
161  (
162  const word& fieldSourceType,
163  const regIOobject&
164  );
165 
166  //- Return a pointer to a new field source created from a dictionary
168  (
169  const regIOobject&,
170  const dictionary&
171  );
172 
173 
174  //- Destructor
175  virtual ~LagrangianFieldSource();
176 
177 
178  // Member Functions
179 
180  // Access
181 
182  //- Return local objectRegistry
183  const objectRegistry& db() const;
184 
185  //- Return internal dimensions reference
186  const dimensionSet& internalDimensions() const;
187 
188  //- Return internal field reference
190 
191 
192  // Evaluation
193 
194  //- Return the source value
196  (
197  const LagrangianSource&,
198  const LagrangianSubMesh&
199  ) const;
200 
201  //- Return the internal coefficient
203  (
204  const LagrangianSource&,
205  const LagrangianSubMesh&
206  ) const;
207 
208  //- Return the source coefficient
210  (
211  const LagrangianSource&,
212  const LagrangianSubMesh&
213  ) const;
214 
215  //- Return the value for a continuous source
217  (
218  const LagrangianSource&,
219  const LagrangianSubMesh&
220  ) const;
221 
222  //- Return the value for an instantaneous injection
224  (
225  const LagrangianInjection&,
226  const LagrangianSubMesh&
227  ) const;
228 
229  //- Return the value for either a continuous source or an
230  // instantaneous injection
232  (
233  const LagrangianModel&,
234  const LagrangianSubMesh&
235  ) const;
236 
237  //- Lookup and return another field source
238  template<class OtherType>
240  (
241  const word& name,
242  const LagrangianModel&
243  ) const;
244 
245  //- Lookup and return another field source and then cast to a
246  // specified type. Handle errors.
247  template<class OtherType, class OtherFieldSourceType>
248  const OtherFieldSourceType& fieldSourceCast
249  (
250  const word& name,
251  const LagrangianModel&
252  ) const;
253 
254  //- Cast a model to the given type. Handle errors.
255  template<class OtherModelType>
256  const OtherModelType& modelCast
257  (
258  const LagrangianModel&
259  ) const;
260 
261  //- Lookup and return the value of another field source
262  template<class OtherType>
264  (
265  const word& name,
266  const LagrangianSource&,
267  const LagrangianSubMesh&
268  ) const;
269 
270  //- Lookup and return the value of another field source
271  template<class OtherType>
273  (
274  const word& name,
275  const LagrangianInjection&,
276  const LagrangianSubMesh&
277  ) const;
278 
279 
280  // I-O
281 
282  //- Write
283  virtual void write(Ostream&) const;
284 
285 
286  // Member Operators
287 
288  //- Ostream operator
289  friend Ostream& operator<< <Type>
290  (
291  Ostream&,
293  );
294 };
295 
296 
297 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
298 
299 } // End namespace Foam
300 
301 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
302 
303 #ifdef NoRepository
304  #include "LagrangianFieldSource.C"
305 #endif
306 
307 
308 #define addToLagrangianFieldSourceRunTimeSelection( \
309  TypeFieldSource, typeTypeFieldSource) \
310  addToRunTimeSelectionTable \
311  ( \
312  TypeFieldSource, \
313  typeTypeFieldSource, \
314  dictionary \
315  )
316 
317 
318 #define addNullConstructableToLagrangianFieldSourceRunTimeSelection( \
319  TypeFieldSource, typeTypeFieldSource) \
320  addToRunTimeSelectionTable \
321  ( \
322  TypeFieldSource, \
323  typeTypeFieldSource, \
324  null \
325  ); \
326  addToLagrangianFieldSourceRunTimeSelection \
327  ( \
328  TypeFieldSource, \
329  typeTypeFieldSource \
330  )
331 
332 
333 #define makeLagrangianTypeFieldSource( \
334  TypeFieldSource, typeTypeFieldSource) \
335  defineTypeNameAndDebug(typeTypeFieldSource, 0); \
336  addToLagrangianFieldSourceRunTimeSelection \
337  ( \
338  TypeFieldSource, \
339  typeTypeFieldSource \
340  )
341 
342 
343 #define makeNullConstructableLagrangianTypeFieldSource( \
344  TypeFieldSource, typeTypeFieldSource) \
345  defineTypeNameAndDebug(typeTypeFieldSource, 0); \
346  addNullConstructableToLagrangianFieldSourceRunTimeSelection \
347  ( \
348  TypeFieldSource, \
349  typeTypeFieldSource \
350  )
351 
352 
353 #define makeTemplateLagrangianTypeFieldSource(fieldType, type) \
354  defineNamedTemplateTypeNameAndDebug \
355  ( \
356  CAT4(type, Lagrangian, CAPITALIZE(fieldType), FieldSource), \
357  0 \
358  ); \
359  addToLagrangianFieldSourceRunTimeSelection \
360  ( \
361  CAT3(Lagrangian, CAPITALIZE(fieldType), FieldSource), \
362  CAT4(type, Lagrangian, CAPITALIZE(fieldType), FieldSource) \
363  );
364 
365 
366 #define makeNullConstructableTemplateLagrangianTypeFieldSource(fieldType, type)\
367  defineNamedTemplateTypeNameAndDebug \
368  ( \
369  CAT4(type, Lagrangian, CAPITALIZE(fieldType), FieldSource), \
370  0 \
371  ); \
372  addNullConstructableToLagrangianFieldSourceRunTimeSelection \
373  ( \
374  CAT3(Lagrangian, CAPITALIZE(fieldType), FieldSource), \
375  CAT4(type, Lagrangian, CAPITALIZE(fieldType), FieldSource) \
376  );
377 
378 
379 #define makeLagrangianFieldSources(type) \
380  FOR_ALL_FIELD_TYPES \
381  ( \
382  makeTemplateLagrangianTypeFieldSource, \
383  type \
384  )
385 
386 
387 #define makeNullConstructableLagrangianFieldSources(type) \
388  FOR_ALL_FIELD_TYPES \
389  ( \
390  makeNullConstructableTemplateLagrangianTypeFieldSource, \
391  type \
392  )
393 
394 
395 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
396 
397 #endif
398 
399 // ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Base class for Lagrangian source conditions.
const OtherFieldSourceType & fieldSourceCast(const word &name, const LagrangianModel &) const
Lookup and return another field source and then cast to a.
const dimensionSet & internalDimensions() const
Return internal dimensions reference.
virtual void write(Ostream &) const
Write.
static autoPtr< LagrangianFieldSource< Type > > New(const word &fieldSourceType, const regIOobject &)
Return a pointer to a new field source.
const objectRegistry & db() const
Return local objectRegistry.
tmp< LagrangianSubField< Type > > value(const LagrangianSource &, const LagrangianSubMesh &) const
Return the value for a continuous source.
const OtherModelType & modelCast(const LagrangianModel &) const
Cast a model to the given type. Handle errors.
TypeName("LagrangianFieldSource")
Runtime type information.
static int disallowGenericLagrangianFieldSource
Debug switch to disallow the use of genericLagrangianFieldSource.
tmp< LagrangianSubField< Type > > sourceCoeff(const LagrangianSource &, const LagrangianSubMesh &) const
Return the source coefficient.
virtual tmp< LagrangianSubField< Type > > sourceValue(const LagrangianSource &, const LagrangianSubMesh &) const
Return the source value.
virtual ~LagrangianFieldSource()
Destructor.
virtual tmp< LagrangianSubScalarField > internalCoeff(const LagrangianSource &, const LagrangianSubMesh &) const
Return the internal coefficient.
autoPtr< LagrangianFieldSource< Type > > clone() const
Disallow clone without setting the internal field reference.
LagrangianFieldSource(const regIOobject &)
Construct from internal field.
const LagrangianFieldSource< OtherType > & fieldSource(const word &name, const LagrangianModel &) const
Lookup and return another field source.
const LagrangianInternalDynamicField< Type > & internalField() const
Return internal field reference.
declareRunTimeSelectionTable(autoPtr, LagrangianFieldSource, null,(const regIOobject &iIo),(iIo))
Select given internal field.
Base class for Lagrangian injections. Minimal wrapper over LagrangianSource. Implements some utility ...
Base class for Lagrangian models.
Base class for Lagrangian sources. Minimal wrapper over LagrangianModel that provides an interface to...
Mesh that relates to a sub-section of a Lagrangian mesh. This is used to construct fields that relate...
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
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 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 name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
Ostream & operator<<(Ostream &os, const fvConstraints &constraints)
dictionary dict