PatchInjection.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) 2011-2023 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::PatchInjection
26 
27 Description
28  Patch injection.
29 
30  User specifies:
31  - Total mass to inject
32  - Name of patch
33  - Injection duration
34  - Initial parcel velocity
35  - Injection volume flow rate
36 
37  Properties:
38  - Parcel diameters obtained by distribution model
39  - Parcels injected randomly across the patch
40 
41 SourceFiles
42  PatchInjection.C
43 
44 \*---------------------------------------------------------------------------*/
45 
46 #ifndef PatchInjection_H
47 #define PatchInjection_H
48 
49 #include "InjectionModel.H"
50 #include "patchInjectionBase.H"
51 #include "Function1.H"
52 #include "interpolation.H"
53 
54 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55 
56 namespace Foam
57 {
58 
59 class distribution;
60 
61 /*---------------------------------------------------------------------------*\
62  Class PatchInjection Declaration
63 \*---------------------------------------------------------------------------*/
64 
65 template<class CloudType>
66 class PatchInjection
67 :
68  public InjectionModel<CloudType>,
69  public patchInjectionBase
70 {
71  // Private Data
72 
73  //- Injection duration [s]
74  const scalar duration_;
75 
76  //- Mass flow rate relative to SOI [kg/s]
77  autoPtr<Function1<scalar>> massFlowRate_;
78 
79  //- Number of parcels to introduce per second [1/s]
80  autoPtr<Function1<scalar>> parcelsPerSecond_;
81 
82  //- Fixed initial parcel velocity [m/s]
83  vector U0_;
84 
85  //- Name of the field from which to interpolate the initial parcel
86  // velocity
87  word U0Name_;
88 
89  //- Initial parcel interpolation engine. Invalid if using a fixed
90  // parcel velocity. Contains a null reference if using the carrier
91  // velocity (as the track data interpolation can be used). Contains an
92  // actual interpolation engine if using a different velocity.
93  tmpNrc<interpolation<vector>> U0InterpPtr_;
94 
95  //- Parcel size distribution model
96  const autoPtr<distribution> sizeDistribution_;
97 
98 
99 protected:
100 
101  // Protected Member Functions
102 
103  //- Pre injection hook
104  virtual void preInject
105  (
106  typename CloudType::parcelType::trackingData& td
107  );
108 
109  //- Post injection hook
110  virtual void postInject
111  (
112  const label parcelsAdded,
113  const scalar massAdded,
114  typename CloudType::parcelType::trackingData& td
115  );
116 
117 
118 public:
119 
120  //- Runtime type information
121  TypeName("patchInjection");
122 
123 
124  // Constructors
125 
126  //- Construct from dictionary
128  (
129  const dictionary& dict,
130  CloudType& owner,
131  const word& modelName
132  );
133 
134  //- Construct copy
136 
137  //- Construct and return a clone
139  {
141  (
142  new PatchInjection<CloudType>(*this)
143  );
144  }
145 
146 
147  //- Destructor
148  virtual ~PatchInjection();
149 
150 
151  // Member Functions
152 
153  //- Inherit topoChange from patchInjectionBase
155 
156  //- Set injector locations when mesh is updated
157  virtual void topoChange();
158 
159  //- Return the end-of-injection time
160  virtual scalar timeEnd() const;
161 
162  //- Number of parcels to introduce relative to SOI
163  virtual label nParcelsToInject(const scalar time0, const scalar time1);
164 
165  //- Parcel mass to introduce relative to SOI
166  virtual scalar massToInject(const scalar time0, const scalar time1);
167 
168 
169  // Injection geometry
170 
171  //- Inherit setPositionAndCell from patchInjectionBase
173 
174  //- Set the injection position and owner cell, tetFace and tetPt
175  virtual void setPositionAndCell
176  (
177  const label parcelI,
178  const label nParcels,
179  const scalar time,
180  barycentric& coordinates,
181  label& celli,
182  label& tetFacei,
183  label& tetPti,
184  label& facei
185  );
186 
187  virtual void setProperties
188  (
189  const label parcelI,
190  const label nParcels,
191  const scalar time,
192  typename CloudType::parcelType::trackingData& td,
193  typename CloudType::parcelType& parcel
194  );
195 
196  //- Flag to identify whether model fully describes the parcel
197  virtual bool fullyDescribed() const;
198 };
199 
200 
201 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
202 
203 } // End namespace Foam
204 
205 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
206 
207 #ifdef NoRepository
208  #include "PatchInjection.C"
209 #endif
210 
211 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
212 
213 #endif
214 
215 // ************************************************************************* //
const CloudType & owner() const
Return const access to the owner cloud.
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:80
ParcelType parcelType
Type of parcel the cloud was instantiated for.
Definition: DSMCCloud.H:225
Templated injection model class.
Patch injection.
virtual void topoChange()
Set injector locations when mesh is updated.
TypeName("patchInjection")
Runtime type information.
virtual ~PatchInjection()
Destructor.
virtual void preInject(typename CloudType::parcelType::trackingData &td)
Pre injection hook.
virtual void setProperties(const label parcelI, const label nParcels, const scalar time, typename CloudType::parcelType::trackingData &td, typename CloudType::parcelType &parcel)
virtual void postInject(const label parcelsAdded, const scalar massAdded, typename CloudType::parcelType::trackingData &td)
Post injection hook.
PatchInjection(const dictionary &dict, CloudType &owner, const word &modelName)
Construct from dictionary.
virtual autoPtr< InjectionModel< CloudType > > clone() const
Construct and return a clone.
virtual label nParcelsToInject(const scalar time0, const scalar time1)
Number of parcels to introduce relative to SOI.
virtual void setPositionAndCell(const fvMesh &mesh, randomGenerator &rndGen, barycentric &coordinates, label &celli, label &tetFacei, label &tetPti, label &facei)
Inherit setPositionAndCell from patchInjectionBase.
virtual bool fullyDescribed() const
Flag to identify whether model fully describes the parcel.
virtual scalar timeEnd() const
Return the end-of-injection time.
virtual scalar massToInject(const scalar time0, const scalar time1)
Parcel mass to introduce relative to SOI.
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 keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
Base class for patch-based injection models.
virtual void topoChange(const polyMesh &mesh)
Update patch geometry and derived info for injection locations.
virtual void setPositionAndCell(const fvMesh &mesh, randomGenerator &rndGen, barycentric &coordinates, label &celli, label &tetFacei, label &tetPti, label &facei)
Set the injection position and owner cell, tetFace and tetPt.
const dictionary & dict() const
Return const access to the cloud dictionary.
Definition: subModelBase.C:110
const word & modelName() const
Return const access to the name of the sub-model.
Definition: subModelBase.C:104
A class for managing temporary objects without reference counting.
Definition: tmpNrc.H:53
A class for handling words, derived from string.
Definition: word.H:62
Namespace for OpenFOAM.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59