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-2024 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 "interpolationCellPoint.H"
47 #include "contiguous.H"
48 
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 
51 namespace Foam
52 {
53 
54 // Forward Declarations
55 class solidParticle;
56 class solidParticleCloud;
57 
58 Ostream& operator<<(Ostream&, const solidParticle&);
59 
60 /*---------------------------------------------------------------------------*\
61  Class solidParticle Declaration
62 \*---------------------------------------------------------------------------*/
63 
64 class solidParticle
65 :
66  public particle
67 {
68  // Private Data
69 
70  //- Diameter
71  scalar d_;
72 
73  //- Velocity of parcel
74  vector U_;
75 
76 
77 public:
78 
79  friend class Cloud<solidParticle>;
80 
81  //- Class used to pass tracking data to the trackToFace function
82  class trackingData
83  :
85  {
86  // Interpolators for continuous phase fields
87 
88  const interpolationCellPoint<scalar>& rhoInterp_;
89  const interpolationCellPoint<vector>& UInterp_;
90  const interpolationCellPoint<scalar>& nuInterp_;
91 
92  //- Local gravitational or other body-force acceleration
93  const vector& g_;
94 
95 
96  public:
97 
98  // Constructors
99 
101  (
102  const solidParticleCloud& cld,
106  const vector& g
107  )
108  :
109  particle::trackingData(cld),
110  rhoInterp_(rhoInterp),
111  UInterp_(UInterp),
112  nuInterp_(nuInterp),
113  g_(g)
114  {}
115 
116 
117  // Member Functions
118 
120  {
121  return nuInterp_;
122  }
123 
125  {
126  return UInterp_;
127  }
128 
130  {
131  return rhoInterp_;
132  }
133 
134  const vector& g() const noexcept { return g_; }
135  };
136 
138  // Static data members
139 
140  //- Size in bytes of the fields
141  static const std::size_t sizeofFields;
142 
143 
144  // Constructors
145 
146  //- Construct from a position and a cell
147  // Searches for the rest of the required topology.
148  // Other properties are zero initialised.
150  (
151  const polyMesh& mesh,
152  const vector& position,
153  const label celli = -1
154  )
155  :
156  particle(mesh, position, celli),
157  d_(0),
158  U_(Zero)
159  {}
160 
161  //- Construct from components
163  (
164  const polyMesh& mesh,
165  const barycentric& coordinates,
166  const label celli,
167  const label tetFacei,
168  const label tetPti,
169  const scalar d,
170  const vector& U
171  )
172  :
173  particle(mesh, coordinates, celli, tetFacei, tetPti),
174  d_(d),
175  U_(U)
176  {}
177 
178  //- Construct from Istream
180  (
181  const polyMesh& mesh,
182  Istream& is,
183  bool readFields = true,
184  bool newFormat = true
185  );
186 
187  //- Return a clone
188  virtual autoPtr<particle> clone() const
189  {
190  return particle::Clone(*this);
191  }
192 
193  //- Factory class to read-construct particles (for parallel transfer)
194  class iNew
195  {
196  const polyMesh& mesh_;
197 
198  public:
199 
200  iNew(const polyMesh& mesh)
201  :
202  mesh_(mesh)
203  {}
204 
206  {
207  return autoPtr<solidParticle>::New(mesh_, is, true);
208  }
209  };
211 
212  // Member Functions
213 
214  // Access
215 
216  //- Return diameter
217  scalar d() const noexcept { return d_; }
218 
219  //- Return velocity
220  const vector& U() const noexcept { return U_; }
222 
223  // Tracking
224 
225  //- Move
226  bool move(solidParticleCloud&, trackingData&, const scalar);
227 
228 
229  // Patch interactions
230 
231  //- Overridable function to handle the particle hitting a patch
232  // Executed before other patch-hitting functions
234 
235  //- Overridable function to handle the particle hitting a
236  // processorPatch
238 
239  //- Overridable function to handle the particle hitting a wallPatch
241 
242  //- Transform the physical properties of the particle
243  // according to the given transformation tensor
244  virtual void transformProperties(const tensor& T);
245 
246  //- Transform the physical properties of the particle
247  // according to the given separation vector
248  virtual void transformProperties(const vector& separation);
249 
250 
251  // I-O
252 
253  static void readFields(Cloud<solidParticle>& c);
254 
255  static void writeFields(const Cloud<solidParticle>& c);
256 
257 
258  // Ostream Operator
259 
260  friend Ostream& operator<<(Ostream&, const solidParticle&);
261 };
262 
263 
264 // * * * * * * * * * * * * * * * * * Traits * * * * * * * * * * * * * * * * //
265 
266 //- Contiguous data for solidParticle
267 template<> struct is_contiguous<solidParticle> : std::true_type {};
268 
269 
270 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
271 
272 } // End namespace Foam
273 
274 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
275 
276 #endif
277 
278 // ************************************************************************* //
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
wallPoints::trackData td(isBlockedFace, regionToBlockSize)
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
static autoPtr< particle > Clone(const Derived &p)
Clone a particle.
Definition: particle.H:552
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:83
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
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:75
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:59
friend Ostream & operator<<(Ostream &, const solidParticle &)
Namespace for OpenFOAM.
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:127