PatchInteractionModel.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) 2019 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::PatchInteractionModel
29 
30 Group
31  grpLagrangianIntermediatePatchInteractionSubModels
32 
33 Description
34  Templated patch interaction model class
35 
36 SourceFiles
37  PatchInteractionModel.C
38  PatchInteractionModelNew.C
39 
40 \*---------------------------------------------------------------------------*/
41 
42 #ifndef PatchInteractionModel_H
43 #define PatchInteractionModel_H
44 
45 #include "IOdictionary.H"
46 #include "autoPtr.H"
47 #include "runTimeSelectionTables.H"
48 #include "polyPatch.H"
49 #include "wallPolyPatch.H"
50 #include "tetIndices.H"
51 #include "CloudSubModelBase.H"
52 #include "writeFile.H"
53 
54 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55 
56 namespace Foam
57 {
58 
59 /*---------------------------------------------------------------------------*\
60  Class PatchInteractionModel Declaration
61 \*---------------------------------------------------------------------------*/
62 
63 template<class CloudType>
64 class PatchInteractionModel
65 :
66  public CloudSubModelBase<CloudType>,
67  public functionObjects::writeFile
68 {
69 public:
70 
71  // Public enumerations
72 
73  // Interaction types
75  {
76  itNone,
77  itRebound,
79  itEscape,
80  itOther
81  };
82 
84 
85 
86 protected:
87 
88  // Protected data
89 
90  //- Name of velocity field - default = "U"
91  const word UName_;
92 
93 
94  // Counters
95 
96  //- Number of parcels escaped
97  label escapedParcels_;
98 
99  //- Mass of parcels escaped
100  scalar escapedMass_;
102  //- Maximum relative U with patch for particle to be removed
103  scalar Urmax_;
104 
105 
106  // Protected Member Functions
107 
108  //- Output file header information
109  virtual void writeFileHeader(Ostream& os);
110 
111 
112 public:
113 
114  //- Runtime type information
115  TypeName("patchInteractionModel");
116 
117  //- Declare runtime constructor selection table
119  (
120  autoPtr,
122  dictionary,
123  (
124  const dictionary& dict,
126  ),
127  (dict, owner)
128  );
129 
130 
131  // Constructors
132 
133  //- Construct null from owner
135 
136  //- Construct from components
138  (
139  const dictionary& dict,
140  CloudType& owner,
141  const word& type
142  );
143 
144  //- Construct copy
146 
147  //- Construct and return a clone
148  virtual autoPtr<PatchInteractionModel<CloudType>> clone() const = 0;
149 
150 
151  //- Destructor
152  virtual ~PatchInteractionModel() = default;
153 
154 
155  //- Selector
157  (
158  const dictionary& dict,
160  );
161 
162 
163  // Access
164 
165  //- Return name of velocity field
166  const word& UName() const;
167 
168  //- Return Urmax
169  const scalar& Urmax() const;
170 
171  // Member Functions
172 
173  //- Convert interaction result to word
174  static word interactionTypeToWord(const interactionType& itEnum);
175 
176  //- Convert word to interaction result
177  static interactionType wordToInteractionType(const word& itWord);
178 
179  //- Apply velocity correction
180  // Returns true if particle remains in same cell
181  virtual bool correct
182  (
183  typename CloudType::parcelType& p,
184  const polyPatch& pp,
185  bool& keepParticle
186  ) = 0;
187 
188  //- Add to escaped parcels
189  virtual void addToEscapedParcels(const scalar mass);
190 
191  //- Post-evolve hook
192  virtual void postEvolve();
193 
194  //- Write patch interaction info
195  virtual void info();
196 };
197 
198 
199 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
200 
201 } // End namespace Foam
202 
203 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
204 
205 #define makePatchInteractionModel(CloudType) \
206  \
207  typedef Foam::CloudType::kinematicCloudType kinematicCloudType; \
208  defineNamedTemplateTypeNameAndDebug \
209  ( \
210  Foam::PatchInteractionModel<kinematicCloudType>, \
211  0 \
212  ); \
213  \
214  namespace Foam \
215  { \
216  defineTemplateRunTimeSelectionTable \
217  ( \
218  PatchInteractionModel<kinematicCloudType>, \
219  dictionary \
220  ); \
221  }
222 
223 
224 #define makePatchInteractionModelType(SS, CloudType) \
225  \
226  typedef Foam::CloudType::kinematicCloudType kinematicCloudType; \
227  defineNamedTemplateTypeNameAndDebug(Foam::SS<kinematicCloudType>, 0); \
228  \
229  Foam::PatchInteractionModel<kinematicCloudType>:: \
230  adddictionaryConstructorToTable<Foam::SS<kinematicCloudType>> \
231  add##SS##CloudType##kinematicCloudType##ConstructorToTable_;
232 
233 
234 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
235 
236 #ifdef NoRepository
237  #include "PatchInteractionModel.C"
238 #endif
239 
240 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
241 
242 #endif
244 // ************************************************************************* //
PatchInteractionModel(CloudType &owner)
Construct null from owner.
static word interactionTypeToWord(const interactionType &itEnum)
Convert interaction result to word.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
label escapedParcels_
Number of parcels escaped.
const word UName_
Name of velocity field - default = "U".
virtual void addToEscapedParcels(const scalar mass)
Add to escaped parcels.
virtual void info()
Write patch interaction info.
const dictionary & dict() const
Return const access to the cloud dictionary.
Definition: subModelBase.C:104
Templated patch interaction model class.
virtual autoPtr< PatchInteractionModel< CloudType > > clone() const =0
Construct and return a clone.
const CloudType & owner() const
Return const access to the owner cloud.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: POSIX.C:799
declareRunTimeSelectionTable(autoPtr, PatchInteractionModel, dictionary,(const dictionary &dict, CloudType &owner),(dict, owner))
Declare runtime constructor selection table.
A class for handling words, derived from Foam::string.
Definition: word.H:63
scalar Urmax_
Maximum relative U with patch for particle to be removed.
static autoPtr< PatchInteractionModel< CloudType > > New(const dictionary &dict, CloudType &owner)
Selector.
const scalar & Urmax() const
Return Urmax.
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)
TypeName("patchInteractionModel")
Runtime type information.
const word & UName() const
Return name of velocity field.
virtual ~PatchInteractionModel()=default
Destructor.
virtual bool correct(typename CloudType::parcelType &p, const polyPatch &pp, bool &keepParticle)=0
Apply velocity correction.
scalar escapedMass_
Mass of parcels escaped.
virtual void writeFileHeader(Ostream &os)
Output file header information.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
Macros to ease declaration of run-time selection tables.
volScalarField & p
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:69
virtual void postEvolve()
Post-evolve hook.
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:67
static interactionType wordToInteractionType(const word &itWord)
Convert word to interaction result.
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
Namespace for OpenFOAM.