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_;
141 
142  //- Mass of parcels injected
143  List<List<scalar>> massInjected_;
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_;
154 
155  //- Flag to output escaped/mass particles sorted by injectorID
157 
158 
159  // Protected Member Functions
160 
161  //- Output file header information
162  virtual void writeFileHeader(Ostream& os);
163 
164 
165 public:
166 
167  //- Runtime type information
168  TypeName("recycleInteraction");
169 
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  }
187 
188 
189  //- Destructor
190  virtual ~RecycleInteraction() = default;
191 
192 
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  );
203 
204  //- Post-evolve hook
205  virtual void postEvolve();
206 
207  //- Write patch interaction info to stream
208  virtual void info(Ostream& os);
209 };
210 
211 
212 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
213 
214 } // End namespace Foam
215 
216 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
217 
218 #ifdef NoRepository
219  #include "RecycleInteraction.C"
220 #endif
221 
222 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
223 
224 #endif
225 
226 // ************************************************************************* //
Foam::RecycleInteraction::recyclePatchesIds_
List< Pair< label > > recyclePatchesIds_
Patch IDs of recyclePatches.
Definition: RecycleInteraction.H:162
Foam::RecycleInteraction::injectionPatchPtr_
PtrList< patchInjectionBase > injectionPatchPtr_
Injection patch pointer.
Definition: RecycleInteraction.H:187
PatchInteractionModel.H
Foam::RecycleInteraction::parcelType
CloudType::parcelType parcelType
Definition: RecycleInteraction.H:151
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::RecycleInteraction::recyclePatches_
List< Pair< word > > recyclePatches_
Outlet-inlet patch pair to apply parcel recycling.
Definition: RecycleInteraction.H:159
Foam::RecycleInteraction::massRemoved_
List< List< scalar > > massRemoved_
Mass of parcels removed.
Definition: RecycleInteraction.H:174
Foam::RecycleInteraction::correct
virtual bool correct(typename CloudType::parcelType &p, const polyPatch &pp, bool &keepParticle)
Apply velocity correction.
Definition: RecycleInteraction.C:157
Foam::Map< label >
Foam::RecycleInteraction::writeFileHeader
virtual void writeFileHeader(Ostream &os)
Output file header information.
Definition: RecycleInteraction.C:33
Foam::RecycleInteraction::recycledParcels_
List< IDLList< parcelType > > recycledParcels_
Parcel IDs of recycled parcels.
Definition: RecycleInteraction.H:165
Foam::RecycleInteraction::RecycleInteraction
RecycleInteraction(const dictionary &dict, CloudType &cloud)
Construct from dictionary.
Definition: RecycleInteraction.C:64
Foam::RecycleInteraction::~RecycleInteraction
virtual ~RecycleInteraction()=default
Destructor.
Foam::RecycleInteraction::TypeName
TypeName("recycleInteraction")
Runtime type information.
Foam::RecycleInteraction::mesh_
const fvMesh & mesh_
Reference to mesh.
Definition: RecycleInteraction.H:156
Foam::RecycleInteraction::outputByInjectorId_
bool outputByInjectorId_
Flag to output escaped/mass particles sorted by injectorID.
Definition: RecycleInteraction.H:193
Foam::PatchInteractionModel
Templated patch interaction model class.
Definition: KinematicCloud.H:89
RecycleInteraction.C
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:68
Foam::RecycleInteraction::nInjected_
List< List< label > > nInjected_
Number of parcels injected.
Definition: RecycleInteraction.H:177
Foam::RecycleInteraction::postEvolve
virtual void postEvolve()
Post-evolve hook.
Definition: RecycleInteraction.C:204
Foam::PtrList
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: List.H:59
Foam::DSMCCloud
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:71
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::RecycleInteraction::info
virtual void info(Ostream &os)
Write patch interaction info to stream.
Definition: RecycleInteraction.C:372
os
OBJstream os(runTime.globalPath()/outputName)
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
patchInjectionBase.H
Foam::RecycleInteraction
Patch interaction model to perform parcel transfer and recycle from one patch to another.
Definition: RecycleInteraction.H:145
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::cloud
A cloud is a registry collection of lagrangian particles.
Definition: cloud.H:57
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:63
Foam::RecycleInteraction::massInjected_
List< List< scalar > > massInjected_
Mass of parcels injected.
Definition: RecycleInteraction.H:180
PtrList.H
Foam::RecycleInteraction::injIdToIndex_
Map< label > injIdToIndex_
Injector ID to local index map.
Definition: RecycleInteraction.H:184
Foam::DSMCCloud::parcelType
ParcelType parcelType
Type of parcel the cloud was instantiated for.
Definition: DSMCCloud.H:220
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::RecycleInteraction::nRemoved_
List< List< label > > nRemoved_
Number of parcels removed.
Definition: RecycleInteraction.H:171
Foam::RecycleInteraction::clone
virtual autoPtr< PatchInteractionModel< CloudType > > clone() const
Construct and return a clone using supplied owner cloud.
Definition: RecycleInteraction.H:217
IDLList.H
Intrusive doubly-linked list.
Foam::RecycleInteraction::recycleFraction_
const scalar recycleFraction_
Parcel fraction to be recycled from outlet to inlet.
Definition: RecycleInteraction.H:190