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-------------------------------------------------------------------------------
10License
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
26Class
27 Foam::injectedParticle
28
29Description
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
35SourceFiles
36 injectedParticle.C
37 injectedParticleIO.C
38
39SeeAlso
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
53namespace Foam
54{
55
56// Forward declarations
57class injectedParticle;
58Ostream& operator<<(Ostream&, const injectedParticle&);
59
60/*---------------------------------------------------------------------------*\
61 Class injectedParticle Declaration
62\*---------------------------------------------------------------------------*/
65:
66 public particle
67{
68protected:
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
90public:
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:
170 iNew(const polyMesh& mesh)
171 :
172 mesh_(mesh)
173 {}
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 (
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
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// ************************************************************************* //
Base cloud calls templated on particle type.
Definition: Cloud.H:68
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
Factory class to read-construct particles used for.
autoPtr< injectedParticle > operator()(Istream &is) const
iNew(const polyMesh &mesh)
Primarily stores particle properties so that it can be injected at a later time. Note that this store...
TypeName("injectedParticle")
Runtime type information.
static void readFields(Cloud< injectedParticle > &c)
Read fields.
virtual autoPtr< particle > clone(const polyMesh &mesh) const
Construct and return a (basic particle) clone.
const vector & U() const
Return const access to velocity.
scalar d() const
Return const access to diameter.
scalar soi() const
Return const access to the start of injection.
virtual autoPtr< particle > clone() const
Construct and return a (basic particle) clone.
static const std::size_t sizeofFields
Size in bytes of the fields.
static void writeObjects(const Cloud< injectedParticle > &c, objectRegistry &obr)
Write particle fields as objects into the obr registry.
scalar d_
Diameter [m].
static void readObjects(Cloud< injectedParticle > &c, const objectRegistry &obr)
Read particle fields as objects from the obr registry.
static void writeFields(const Cloud< injectedParticle > &c)
Write fields.
void writeProperties(Ostream &os, const wordRes &filters, const word &delim, const bool namesOnly) const
Write individual parcel properties to stream.
scalar soi_
Start of injection [s].
virtual void writePosition(Ostream &) const
Write the particle position and cell.
label tag() const
Return const access to the tag.
AddToPropertyList(particle, " tag"+" soi"+" d"+" (Ux Uy Uz)";)
String representation of properties.
vector U_
Velocity [m/s].
point position_
Position.
Registry of regIOobjects.
Base particle class.
Definition: particle.H:79
vector position() const
Return current particle position.
Definition: particleI.H:314
const polyMesh & mesh() const noexcept
Return the mesh database.
Definition: particleI.H:137
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:54
A class for handling words, derived from Foam::string.
Definition: word.H:68
volScalarField & p
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
#define AddToPropertyList(ParcelType, str)
Add to existing static 'propertyList' for particle properties.
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73