LagrangianModelRefI.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) 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 \*---------------------------------------------------------------------------*/
25 
26 #include "LagrangianModelRef.H"
27 
28 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
29 
31 :
32  source_(NullObjectRef<LagrangianSource>()),
34  injection_(NullObjectRef<LagrangianInjection>())
35 {}
36 
37 
39 (
40  const LagrangianSource& source,
42 )
43 :
44  source_(source),
45  S_(S),
46  injection_(NullObjectRef<LagrangianInjection>())
47 {}
48 
49 
51 (
52  const LagrangianInjection& injection
53 )
54 :
55  source_(NullObjectRef<LagrangianSource>()),
57  injection_(injection)
58 {}
59 
60 
61 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
62 
64 {
65  return notNull(source_);
66 }
67 
68 
69 inline const Foam::LagrangianSource&
71 {
72  if (!isSource())
73  {
75  << "Invalid Lagrangian source reference requested."
76  << exit(FatalError);
77  }
78 
79  return source_;
80 }
81 
82 
85 {
86  if (!isSource())
87  {
89  << "Invalid Lagrangian source reference requested."
90  << exit(FatalError);
91  }
92 
93  return S_;
94 }
95 
96 
98 {
99  return notNull(injection_);
100 }
101 
102 
103 inline const Foam::LagrangianInjection&
105 {
106  if (!isInjection())
107  {
109  << "Invalid Lagrangian injection reference requested."
110  << exit(FatalError);
111  }
112 
113  return injection_;
114 }
115 
116 
117 // ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Base class for Lagrangian injections. Minimal wrapper over LagrangianSource. Implements some utility ...
bool isInjection() const
Check if the injection reference is valid.
const LagrangianSubScalarField & S() const
Access the source field.
const LagrangianInjection & injection() const
Access the injection model.
LagrangianModelRef()
Construct null.
const LagrangianSource & source() const
Access the source model.
bool isSource() const
Check if the source reference is valid.
Base class for Lagrangian sources. Minimal wrapper over LagrangianModel that provides an interface to...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
tmp< fvMatrix< Type > > S(const Pair< tmp< volScalarField::Internal >> &, const VolField< Type > &)
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
bool notNull(const T &t)
Return true if t is not a reference to the nullObject of type T.
Definition: nullObjectI.H:64
const T & NullObjectRef()
Return const reference to the nullObject of type T.
Definition: nullObjectI.H:27
error FatalError