PatchInjection.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2017 OpenFOAM Foundation
9  Copyright (C) 2021 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::PatchInjection
29 
30 Group
31  grpLagrangianIntermediateInjectionSubModels
32 
33 Description
34  Patch injection.
35 
36  User specifies:
37  - Total mass to inject
38  - Name of patch
39  - Injection duration
40  - Initial parcel velocity
41  - Injection volume flow rate
42 
43  Properties:
44  - Parcel diameters obtained by distribution model
45  - Parcels injected randomly across the patch
46 
47 SourceFiles
48  PatchInjection.C
49 
50 \*---------------------------------------------------------------------------*/
51 
52 #ifndef PatchInjection_H
53 #define PatchInjection_H
54 
55 #include "InjectionModel.H"
56 #include "patchInjectionBase.H"
57 
58 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
59 
60 namespace Foam
61 {
62 
63 class distributionModel;
64 
65 /*---------------------------------------------------------------------------*\
66  Class PatchInjection Declaration
67 \*---------------------------------------------------------------------------*/
68 
69 template<class CloudType>
70 class PatchInjection
71 :
72  public InjectionModel<CloudType>,
73  public patchInjectionBase
74 {
75 public:
76 
77  // Public Data Types
78 
79  //- Velocity type enumeration
81  {
82  vtFixedValue,
83  vtPatchValue,
85  };
86 
87  //- Velocity type names
89 
90 
91 private:
92 
93  // Private data
94 
95  //- Injection duration [s]
96  scalar duration_;
97 
98  //- Number of parcels to introduce per second []
99  const label parcelsPerSecond_;
100 
101  //- Velocity type
102  const velocityType velocityType_;
103 
104  //- Initial parcel velocity [m/s]
105  // Note: Only used for vtFixedValue
106  const vector U0_;
107 
108  //- Flow rate profile relative to SOI []
109  autoPtr<Function1<scalar>> flowRateProfile_;
110 
111  //- Parcel size distribution model
112  const autoPtr<distributionModel> sizeDistribution_;
113 
114  //- Current parcel being processed
115  label currentParceli_;
116 
117  //- Current face being processed
118  label currentFacei_;
119 
120 
121 public:
122 
123  //- Runtime type information
124  TypeName("patchInjection");
125 
126 
127  // Constructors
128 
129  //- Construct from dictionary
131  (
132  const dictionary& dict,
133  CloudType& owner,
134  const word& modelName
135  );
136 
137  //- Construct copy
139 
140  //- Construct and return a clone
142  {
144  (
145  new PatchInjection<CloudType>(*this)
146  );
147  }
148 
149 
150  //- Destructor
151  virtual ~PatchInjection() = default;
152 
153 
154  // Member Functions
155 
156  //- Inherit updateMesh from patchInjectionBase
158 
159  //- Set injector locations when mesh is updated
160  virtual void updateMesh();
161 
162  //- Return the end-of-injection time
163  virtual scalar timeEnd() const;
164 
165  //- Number of parcels to introduce relative to SOI
166  virtual label parcelsToInject(const scalar time0, const scalar time1);
167 
168  //- Volume of parcels to introduce relative to SOI
169  virtual scalar volumeToInject(const scalar time0, const scalar time1);
170 
171 
172  // Injection geometry
173 
174  //- Inherit setPositionAndCell from patchInjectionBase
176 
177  //- Set the injection position and owner cell, tetFace and tetPt
178  virtual void setPositionAndCell
179  (
180  const label parcelI,
181  const label nParcels,
182  const scalar time,
183  vector& position,
184  label& cellOwner,
185  label& tetFacei,
186  label& tetPti
187  );
188 
189  virtual void setProperties
190  (
191  const label parcelI,
192  const label nParcels,
193  const scalar time,
194  typename CloudType::parcelType& parcel
195  );
196 
197  //- Flag to identify whether model fully describes the parcel
198  virtual bool fullyDescribed() const;
199 
200  //- Return flag to identify whether or not injection of parcelI is
201  // permitted
202  virtual bool validInjection(const label parcelI);
203 };
204 
205 
206 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
207 
208 } // End namespace Foam
209 
210 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
211 
212 #ifdef NoRepository
213  #include "PatchInjection.C"
214 #endif
215 
216 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
217 
218 #endif
219 
220 // ************************************************************************* //
virtual void setProperties(const label parcelI, const label nParcels, const scalar time, typename CloudType::parcelType &parcel)
Set the parcel properties.
virtual scalar volumeToInject(const scalar time0, const scalar time1)
Volume of parcels to introduce relative to SOI.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
Templated injection model class.
virtual void updateMesh(const polyMesh &mesh)
Update patch geometry and derived info for injection locations.
virtual void updateMesh()
Set injector locations when mesh is updated.
const word & modelName() const
Return const access to the name of the sub-model.
Definition: subModelBase.C:98
const dictionary & dict() const
Return const access to the cloud dictionary.
Definition: subModelBase.C:104
virtual scalar timeEnd() const
Return the end-of-injection time.
static const Enum< velocityType > velocityTypeNames_
Velocity type names.
const CloudType & owner() const
Return const access to the owner cloud.
User supplied fixed value.
virtual bool fullyDescribed() const
Flag to identify whether model fully describes the parcel.
virtual bool validInjection(const label parcelI)
Return flag to identify whether or not injection of parcelI is.
A class for handling words, derived from Foam::string.
Definition: word.H:63
virtual autoPtr< InjectionModel< CloudType > > clone() const
Construct and return a clone.
TypeName("patchInjection")
Runtime type information.
PatchInjection(const dictionary &dict, CloudType &owner, const word &modelName)
Construct from dictionary.
ParcelType parcelType
Type of parcel the cloud was instantiated for.
Definition: DSMCCloud.H:290
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
Patch internal cell values.
virtual ~PatchInjection()=default
Destructor.
label setPositionAndCell(const fvMesh &mesh, const scalar fraction01, Random &rnd, vector &position, label &cellOwner, label &tetFacei, label &tetPti)
Set the injection position and owner cell, tetFace and tetPt.
velocityType
Velocity type enumeration.
Patch injection.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
virtual label parcelsToInject(const scalar time0, const scalar time1)
Number of parcels to introduce relative to SOI.
virtual void setPositionAndCell(const label parcelI, const label nParcels, const scalar time, vector &position, label &cellOwner, label &tetFacei, label &tetPti)
Set the injection position and owner cell, tetFace and tetPt.
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:67
Namespace for OpenFOAM.