solidParticle.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) 2016-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::solidParticle
29 
30 Description
31  Simple solid spherical particle class with one-way coupling with the
32  continuous phase.
33 
34 SourceFiles
35  solidParticleI.H
36  solidParticle.C
37  solidParticleIO.C
38 
39 \*---------------------------------------------------------------------------*/
40 
41 #ifndef Foam_solidParticle_H
42 #define Foam_solidParticle_H
43 
44 #include "particle.H"
45 #include "IOstream.H"
46 #include "autoPtr.H"
47 #include "interpolationCellPoint.H"
48 #include "contiguous.H"
49 
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 
52 namespace Foam
53 {
54 
55 // Forward Declarations
56 class solidParticle;
57 class solidParticleCloud;
58 
59 Ostream& operator<<(Ostream&, const solidParticle&);
60 
61 /*---------------------------------------------------------------------------*\
62  Class solidParticle Declaration
63 \*---------------------------------------------------------------------------*/
64 
65 class solidParticle
66 :
67  public particle
68 {
69  // Private Data
70 
71  //- Diameter
72  scalar d_;
73 
74  //- Velocity of parcel
75  vector U_;
76 
77 
78 public:
79 
80  friend class Cloud<solidParticle>;
81 
82  //- Class used to pass tracking data to the trackToFace function
83  class trackingData
84  :
86  {
87  // Interpolators for continuous phase fields
88 
89  const interpolationCellPoint<scalar>& rhoInterp_;
90  const interpolationCellPoint<vector>& UInterp_;
91  const interpolationCellPoint<scalar>& nuInterp_;
92 
93  //- Local gravitational or other body-force acceleration
94  const vector& g_;
95 
96 
97  public:
98 
99  // Constructors
100 
102  (
103  const solidParticleCloud& cld,
107  const vector& g
108  )
109  :
110  particle::trackingData(cld),
111  rhoInterp_(rhoInterp),
112  UInterp_(UInterp),
113  nuInterp_(nuInterp),
114  g_(g)
115  {}
116 
117 
118  // Member Functions
119 
121  {
122  return nuInterp_;
123  }
124 
126  {
127  return UInterp_;
128  }
129 
131  {
132  return rhoInterp_;
133  }
134 
135  const vector& g() const noexcept { return g_; }
136  };
137 
139  // Static data members
140 
141  //- Size in bytes of the fields
142  static const std::size_t sizeofFields;
143 
144 
145  // Constructors
146 
147  //- Construct from a position and a cell
148  // Searches for the rest of the required topology.
149  // Other properties are zero initialised.
151  (
152  const polyMesh& mesh,
153  const vector& position,
154  const label celli = -1
155  )
156  :
157  particle(mesh, position, celli),
158  d_(0),
159  U_(Zero)
160  {}
161 
162  //- Construct from components
164  (
165  const polyMesh& mesh,
166  const barycentric& coordinates,
167  const label celli,
168  const label tetFacei,
169  const label tetPti,
170  const scalar d,
171  const vector& U
172  )
173  :
174  particle(mesh, coordinates, celli, tetFacei, tetPti),
175  d_(d),
176  U_(U)
177  {}
178 
179  //- Construct from Istream
181  (
182  const polyMesh& mesh,
183  Istream& is,
184  bool readFields = true,
185  bool newFormat = true
186  );
187 
188  //- Construct and return a clone
189  virtual autoPtr<particle> clone() const
190  {
191  return autoPtr<particle>(new solidParticle(*this));
192  }
193 
194  //- Factory class to read-construct particles (for parallel transfer)
195  class iNew
196  {
197  const polyMesh& mesh_;
198 
199  public:
200 
201  iNew(const polyMesh& mesh)
202  :
203  mesh_(mesh)
204  {}
205 
207  {
208  return autoPtr<solidParticle>::New(mesh_, is, true);
209  }
210  };
212 
213  // Member Functions
214 
215  // Access
216 
217  //- Return diameter
218  scalar d() const noexcept { return d_; }
219 
220  //- Return velocity
221  const vector& U() const noexcept { return U_; }
223 
224  // Tracking
225 
226  //- Move
227  bool move(solidParticleCloud&, trackingData&, const scalar);
228 
229 
230  // Patch interactions
231 
232  //- Overridable function to handle the particle hitting a patch
233  // Executed before other patch-hitting functions
235 
236  //- Overridable function to handle the particle hitting a
237  // processorPatch
239 
240  //- Overridable function to handle the particle hitting a wallPatch
242 
243  //- Transform the physical properties of the particle
244  // according to the given transformation tensor
245  virtual void transformProperties(const tensor& T);
246 
247  //- Transform the physical properties of the particle
248  // according to the given separation vector
249  virtual void transformProperties(const vector& separation);
250 
251 
252  // I-O
253 
254  static void readFields(Cloud<solidParticle>& c);
255 
256  static void writeFields(const Cloud<solidParticle>& c);
257 
258 
259  // Ostream Operator
260 
261  friend Ostream& operator<<(Ostream&, const solidParticle&);
262 };
263 
264 
265 // * * * * * * * * * * * * * * * * * Traits * * * * * * * * * * * * * * * * //
266 
267 //- Contiguous data for solidParticle
268 template<> struct is_contiguous<solidParticle> : std::true_type {};
269 
270 
271 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
272 
273 } // End namespace Foam
274 
275 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
276 
277 #endif
278 
279 // ************************************************************************* //
const interpolationCellPoint< scalar > & rhoInterp() const noexcept
const interpolationCellPoint< vector > & UInterp() const noexcept
const barycentric & coordinates() const noexcept
Return current particle coordinates.
Definition: particleI.H:116
const interpolationCellPoint< scalar > & nuInterp() const noexcept
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
bool hitPatch(solidParticleCloud &cloud, trackingData &td)
Overridable function to handle the particle hitting a patch.
Definition: solidParticle.C:84
scalar d() const noexcept
Return diameter.
Base particle class.
Definition: particle.H:69
const vector & U() const noexcept
Return velocity.
A cloud is a registry collection of lagrangian particles.
Definition: cloud.H:53
A Cloud of solid particles.
Base cloud calls templated on particle type.
Definition: Cloud.H:51
autoPtr< solidParticle > operator()(Istream &is) const
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
const direction noexcept
Definition: Scalar.H:258
const vector & g() const noexcept
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
Class used to pass tracking data to the trackToFace function.
Definition: solidParticle.H:84
static void writeFields(const Cloud< solidParticle > &c)
solidParticle(const polyMesh &mesh, const vector &position, const label celli=-1)
Construct from a position and a cell.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:77
void hitProcessorPatch(solidParticleCloud &cloud, trackingData &td)
Overridable function to handle the particle hitting a.
Definition: solidParticle.C:91
const polyMesh & mesh() const noexcept
Return the mesh database.
Definition: particleI.H:110
virtual autoPtr< particle > clone() const
Construct and return a clone.
A template class to specify that a data type can be considered as being contiguous in memory...
Definition: contiguous.H:70
const dimensionedScalar c
Speed of light in a vacuum.
bool move(solidParticleCloud &, trackingData &, const scalar)
Move.
Definition: solidParticle.C:33
static const std::size_t sizeofFields
Size in bytes of the fields.
trackingData(const solidParticleCloud &cld, const interpolationCellPoint< scalar > &rhoInterp, const interpolationCellPoint< vector > &UInterp, const interpolationCellPoint< scalar > &nuInterp, const vector &g)
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
iNew(const polyMesh &mesh)
static autoPtr< T > New(Args &&... args)
Construct autoPtr with forwarding arguments.
Definition: autoPtr.H:178
virtual void transformProperties(const tensor &T)
Transform the physical properties of the particle.
Tensor of scalars, i.e. Tensor<scalar>.
void hitWallPatch(solidParticleCloud &cloud, trackingData &td)
Overridable function to handle the particle hitting a wallPatch.
vector position() const
Return current particle position.
Definition: particleI.H:283
static void readFields(Cloud< solidParticle > &c)
Simple solid spherical particle class with one-way coupling with the continuous phase.
Definition: solidParticle.H:60
friend Ostream & operator<<(Ostream &, const solidParticle &)
Namespace for OpenFOAM.
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:127