RecycleInteraction.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) 2020 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::RecycleInteraction
28 
29 Group
30  grpLagrangianIntermediatePatchInteractionSubModels
31 
32 Description
33  Patch interaction model to perform
34  parcel transfer and recycle from one patch to another.
35 
36  Parcels that hit a given 'outflow' patch
37  are recycled to a given 'inflow' patch, with optional:
38  - recycle fraction [0-1]
39 
40 Usage
41  Minimal example by using
42  \c constant/reactingCloud1Properties.subModels.multiInteractionCoeffs
43  \verbatim
44  multiInteractionCoeffs
45  {
46  ...
47 
48  model1
49  {
50  // Mandatory entries (unmodifiable)
51  patchInteractionModel recycleInteraction;
52 
53  recycleInteractionCoeffs
54  {
55  recyclePatches
56  (
57  (<outletPatch1> <inletPatch1>)
58  (<outletPatch2> <inletPatch2>)
59  ...
60  );
61 
62  recycleFraction 0.8; // [0-1]
63 
64  // Optional entries (unmodifiable)
65  outputByInjectorId false;
66  }
67  }
68 
69  ...
70  }
71  \endverbatim
72 
73  where the entries mean:
74  \table
75  Property | Description | Type | Reqd | Dflt
76  patchInteractionModel | Type name: recycleInteraction <!--
77  --> | word | yes | -
78  recyclePatches | Names of outlet-inlet patch pairs <!--
79  --> | (word word) | yes | -
80  recycleFraction | Fraction of parcels recycled from <!--
81  --> outlet to inlet | scalar | yes | -
82  outputByInjectorId | Flag to output escaped/mass <!--
83  --> particles sorted by injectorID | bool | no | false
84  \endtable
85 
86 SourceFiles
87  RecycleInteraction.C
88 
89 \*---------------------------------------------------------------------------*/
90 
91 #ifndef RecycleInteraction_H
92 #define RecycleInteraction_H
93 
94 #include "patchInjectionBase.H"
95 #include "IDLList.H"
96 #include "PtrList.H"
97 #include "PatchInteractionModel.H"
98 
99 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
100 
101 namespace Foam
102 {
103 /*---------------------------------------------------------------------------*\
104  Class RecycleInteraction Declaration
105 \*---------------------------------------------------------------------------*/
106 
107 template<class CloudType>
108 class RecycleInteraction
109 :
110  public PatchInteractionModel<CloudType>
111 {
112 protected:
113 
114  typedef typename CloudType::parcelType parcelType;
115 
116  // Protected Data
117 
118  //- Reference to mesh
119  const fvMesh& mesh_;
120 
121  //- Outlet-inlet patch pair to apply parcel recycling
122  List<Pair<word>> recyclePatches_;
123 
124  //- Patch IDs of recyclePatches
125  List<Pair<label>> recyclePatchesIds_;
126 
127  //- Parcel IDs of recycled parcels
128  List<IDLList<parcelType>> recycledParcels_;
129 
130 
131  // Bookkeeping for particle fates
132 
133  //- Number of parcels removed
134  List<List<label>> nRemoved_;
135 
136  //- Mass of parcels removed
137  List<List<scalar>> massRemoved_;
138 
139  //- Number of parcels injected
140  List<List<label>> nInjected_;
142  //- Mass of parcels injected
144 
145 
146  //- Injector ID to local index map
148 
149  //- Injection patch pointer
151 
152  //- Parcel fraction to be recycled from outlet to inlet
153  const scalar recycleFraction_;
155  //- Flag to output escaped/mass particles sorted by injectorID
156  bool outputByInjectorId_;
157 
158 
159  // Protected Member Functions
160 
161  //- Output file header information
162  virtual void writeFileHeader(Ostream& os);
163 
165 public:
166 
167  //- Runtime type information
168  TypeName("recycleInteraction");
170 
171  // Constructors
172 
173  //- Construct from dictionary
175 
176  //- Construct copy from owner cloud and patch interaction model
178 
179  //- Construct and return a clone using supplied owner cloud
181  {
183  (
185  );
186  }
188 
189  //- Destructor
190  virtual ~RecycleInteraction() = default;
191 
193  // Member Functions
194 
195  //- Apply velocity correction
196  // Returns true if particle remains in same cell
197  virtual bool correct
198  (
199  typename CloudType::parcelType& p,
200  const polyPatch& pp,
201  bool& keepParticle
202  );
204  //- Post-evolve hook
205  virtual void postEvolve();
206 
207  //- Write patch interaction info
208  virtual void info();
209 };
210 
211 
212 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
214 } // End namespace Foam
215 
216 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
217 
218 #ifdef NoRepository
219  #include "RecycleInteraction.C"
220 #endif
221 
222 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
223 
224 #endif
225 
226 // ************************************************************************* //
List< List< scalar > > massInjected_
Mass of parcels injected.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:56
PtrList< patchInjectionBase > injectionPatchPtr_
Injection patch pointer.
List< List< scalar > > massRemoved_
Mass of parcels removed.
TypeName("recycleInteraction")
Runtime type information.
List< List< label > > nRemoved_
Number of parcels removed.
List< IDLList< parcelType > > recycledParcels_
Parcel IDs of recycled parcels.
const dictionary & dict() const
Return const access to the cloud dictionary.
Definition: subModelBase.C:104
bool outputByInjectorId_
Flag to output escaped/mass particles sorted by injectorID.
virtual void postEvolve()
Post-evolve hook.
const fvMesh & mesh_
Reference to mesh.
List< Pair< word > > recyclePatches_
Outlet-inlet patch pair to apply parcel recycling.
Map< label > injIdToIndex_
Injector ID to local index map.
virtual autoPtr< PatchInteractionModel< CloudType > > clone() const
Construct and return a clone using supplied owner cloud.
Intrusive doubly-linked list.
Patch interaction model to perform parcel transfer and recycle from one patch to another.
CloudType::parcelType parcelType
const scalar recycleFraction_
Parcel fraction to be recycled from outlet to inlet.
A cloud is a registry collection of lagrangian particles.
Definition: cloud.H:53
ParcelType parcelType
Type of parcel the cloud was instantiated for.
Definition: DSMCCloud.H:290
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
OBJstream os(runTime.globalPath()/outputName)
virtual void writeFileHeader(Ostream &os)
Output file header information.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
Definition: List.H:55
virtual void info()
Write patch interaction info.
List< List< label > > nInjected_
Number of parcels injected.
virtual bool correct(typename CloudType::parcelType &p, const polyPatch &pp, bool &keepParticle)
Apply velocity correction.
RecycleInteraction(const dictionary &dict, CloudType &cloud)
Construct from dictionary.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
virtual ~RecycleInteraction()=default
Destructor.
volScalarField & p
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:69
List< Pair< label > > recyclePatchesIds_
Patch IDs of recyclePatches.
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:67
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
Namespace for OpenFOAM.