injectedParticle.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) 2016-2019 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::injectedParticle
28 
29 Description
30  Primarily stores particle properties so that it can be injected at a later
31  time. Note that this stores its own local position as opposed to the
32  base particle class barycentric coordinates since the particle is not
33  (usually) attached to a mesh, and instead used for post-processing.
34 
35 SourceFiles
36  injectedParticle.C
37  injectedParticleIO.C
38 
39 SeeAlso
40  Foam::functionObjects::extractEulerianParticles
41 
42 \*---------------------------------------------------------------------------*/
43 
44 #ifndef injectedParticle_H
45 #define injectedParticle_H
46 
47 #include "particle.H"
48 #include "IOstream.H"
49 #include "autoPtr.H"
50 
51 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 
53 namespace Foam
54 {
55 
56 // Forward declarations
57 class injectedParticle;
58 Ostream& operator<<(Ostream&, const injectedParticle&);
59 
60 /*---------------------------------------------------------------------------*\
61  Class injectedParticle Declaration
62 \*---------------------------------------------------------------------------*/
63 
64 class injectedParticle
65 :
66  public particle
67 {
68 protected:
69 
70  // Protected data
71 
72  // Particle properties
73 
74  //- Position
76 
77  //- Tag
78  label tag_;
79 
80  //- Start of injection [s]
81  scalar soi_;
82 
83  //- Diameter [m]
84  scalar d_;
85 
86  //- Velocity [m/s]
87  vector U_;
88 
89 
90 public:
91 
92  // Static Data Members
93 
94  //- Size in bytes of the fields
95  static const std::size_t sizeofFields;
96 
97  //- Runtime type information
98  TypeName("injectedParticle");
99 
100  //- String representation of properties
102  (
103  particle,
104  " tag"
105  + " soi"
106  + " d"
107  + " (Ux Uy Uz)";
108  );
109 
110 
111  // Constructors
112 
113  //- Construct from a position and a cell.
114  // Searches for the rest of the required topology.
115  // Other properties are zero initialised.
116  inline injectedParticle
117  (
118  const polyMesh& mesh,
119  const vector& position,
120  const label celli = -1
121  );
122 
123  //- Construct from components
124  inline injectedParticle
125  (
126  const polyMesh& mesh,
127  const vector& position,
128  const label tag,
129  const scalar soi,
130  const scalar d,
131  const vector& U,
132  const bool doLocate = true
133  );
134 
135  //- Construct from Istream
137  (
138  const polyMesh& mesh,
139  Istream& is,
140  bool readFields = true,
141  bool newFormat = true
142  );
143 
144  //- Construct as a copy
146 
147  //- Construct as a copy
149 
150  //- Construct and return a (basic particle) clone
151  virtual autoPtr<particle> clone() const
152  {
153  return autoPtr<particle>(new injectedParticle(*this));
154  }
155 
156  //- Construct and return a (basic particle) clone
157  virtual autoPtr<particle> clone(const polyMesh& mesh) const
158  {
159  return autoPtr<particle>(new injectedParticle(*this, mesh));
160  }
161 
162  //- Factory class to read-construct particles used for
163  // parallel transfer
164  class iNew
165  {
166  const polyMesh& mesh_;
167 
168  public:
169 
170  iNew(const polyMesh& mesh)
171  :
172  mesh_(mesh)
173  {}
174 
176  {
178  (
179  new injectedParticle(mesh_, is, true)
180  );
181  }
182  };
183 
184 
185  // Member Functions
186 
187  // Access
188 
189  //- Return const access to the tag
190  inline label tag() const;
191 
192  //- Return const access to the start of injection
193  inline scalar soi() const;
194 
195  //- Return const access to diameter
196  inline scalar d() const;
197 
198  //- Return const access to velocity
199  inline const vector& U() const;
200 
201 
202  // Edit
203 
204  //- Return the tag
205  inline label& tag();
206 
207  //- Return the start of injection
208  inline scalar& soi();
209 
210  //- Return access to diameter
211  inline scalar& d();
212 
213  //- Return access to velocity
214  inline vector& U();
215 
216 
217  // I-O
218 
219  //- Read fields
220  static void readFields(Cloud<injectedParticle>& c);
221 
222  //- Write individual parcel properties to stream
223  void writeProperties
224  (
225  Ostream& os,
226  const wordRes& filters,
227  const word& delim,
228  const bool namesOnly
229  ) const;
230 
231  //- Write fields
232  static void writeFields(const Cloud<injectedParticle>& c);
233 
234  //- Read particle fields as objects from the obr registry
235  static void readObjects
236  (
238  const objectRegistry& obr
239  );
240 
241  //- Write particle fields as objects into the obr registry
242  static void writeObjects
243  (
244  const Cloud<injectedParticle>& c,
245  objectRegistry& obr
246  );
247 
248  //- Write the particle position and cell
249  // Note: This uses the local particle position, and bypasses the
250  // barycentric description
251  virtual void writePosition(Ostream&) const;
252 
253 
254  // Ostream Operator
255 
256  friend Ostream& operator<<
257  (
258  Ostream&,
259  const injectedParticle&
260  );
261 };
262 
263 
264 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
265 
266 } // End namespace Foam
267 
268 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
269 
270 #include "injectedParticleI.H"
271 
272 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
273 
274 #endif
275 
276 // ************************************************************************* //
Foam::injectedParticle::d
scalar d() const
Return const access to diameter.
Definition: injectedParticleI.H:79
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::injectedParticle::iNew
Factory class to read-construct particles used for.
Definition: injectedParticle.H:163
Foam::injectedParticle::iNew::operator()
autoPtr< injectedParticle > operator()(Istream &is) const
Definition: injectedParticle.H:174
Foam::injectedParticle::writeFields
static void writeFields(const Cloud< injectedParticle > &c)
Write fields.
Definition: injectedParticleIO.C:132
Foam::injectedParticle::clone
virtual autoPtr< particle > clone() const
Construct and return a (basic particle) clone.
Definition: injectedParticle.H:150
Foam::injectedParticle::readObjects
static void readObjects(Cloud< injectedParticle > &c, const objectRegistry &obr)
Read particle fields as objects from the obr registry.
Definition: injectedParticleIO.C:199
Foam::injectedParticle::U
const vector & U() const
Return const access to velocity.
Definition: injectedParticleI.H:85
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:60
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
IOstream.H
Foam::injectedParticle::AddToPropertyList
AddToPropertyList(particle, " tag"+" soi"+" d"+" (Ux Uy Uz)";)
String representation of properties.
Foam::injectedParticle::tag
label tag() const
Return const access to the tag.
Definition: injectedParticleI.H:67
Foam::particle::position
vector position() const
Return current particle position.
Definition: particleI.H:314
Foam::injectedParticle::soi_
scalar soi_
Start of injection [s].
Definition: injectedParticle.H:80
Foam::injectedParticle::iNew::iNew
iNew(const polyMesh &mesh)
Definition: injectedParticle.H:169
Foam::particle::mesh
const polyMesh & mesh() const
Return the mesh database.
Definition: particleI.H:137
Foam::injectedParticle
Primarily stores particle properties so that it can be injected at a later time. Note that this store...
Definition: injectedParticle.H:63
Foam::injectedParticle::readFields
static void readFields(Cloud< injectedParticle > &c)
Read fields.
Definition: injectedParticleIO.C:96
injectedParticleI.H
os
OBJstream os(runTime.globalPath()/outputName)
Foam::injectedParticle::injectedParticle
injectedParticle(const polyMesh &mesh, const vector &position, const label celli=-1)
Construct from a position and a cell.
Definition: injectedParticleI.H:32
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::injectedParticle::position_
point position_
Position.
Definition: injectedParticle.H:74
Foam::injectedParticle::sizeofFields
static const std::size_t sizeofFields
Size in bytes of the fields.
Definition: injectedParticle.H:94
Foam::injectedParticle::tag_
label tag_
Tag.
Definition: injectedParticle.H:77
Foam::injectedParticle::d_
scalar d_
Diameter [m].
Definition: injectedParticle.H:83
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::injectedParticle::soi
scalar soi() const
Return const access to the start of injection.
Definition: injectedParticleI.H:73
Foam::Vector< scalar >
Foam::particle
Base particle class.
Definition: particle.H:76
Foam::Cloud< injectedParticle >
Foam::wordRes
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:51
Foam::injectedParticle::writeProperties
void writeProperties(Ostream &os, const wordRes &filters, const word &delim, const bool namesOnly) const
Write individual parcel properties to stream.
Definition: injectedParticleIO.C:176
Foam::injectedParticle::writeObjects
static void writeObjects(const Cloud< injectedParticle > &c, objectRegistry &obr)
Write particle fields as objects into the obr registry.
Definition: injectedParticleIO.C:228
particle.H
Foam::injectedParticle::TypeName
TypeName("injectedParticle")
Runtime type information.
Foam::constant::universal::c
const dimensionedScalar c
Speed of light in a vacuum.
Foam::injectedParticle::writePosition
virtual void writePosition(Ostream &) const
Write the particle position and cell.
Definition: injectedParticleIO.C:257
Foam::injectedParticle::clone
virtual autoPtr< particle > clone(const polyMesh &mesh) const
Construct and return a (basic particle) clone.
Definition: injectedParticle.H:156
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::injectedParticle::U_
vector U_
Velocity [m/s].
Definition: injectedParticle.H:86
autoPtr.H