Loading...
Searching...
No Matches
passivePositionParticle.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) 2017-2024 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::passivePositionParticle
28
29Description
30 Passive particle, transferring in old format (i.e. position instead of
31 coordinates). Used for e.g. redistributePar.
32
33SourceFiles
34 passivePositionParticle.H
35
36\*---------------------------------------------------------------------------*/
37
38#ifndef Foam_passivePositionParticle_H
39#define Foam_passivePositionParticle_H
40
41#include "passiveParticle.H"
42
43// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44
45namespace Foam
46{
47
48// Forward Declarations
51
52/*---------------------------------------------------------------------------*\
53 Class passivePositionParticle Declaration
54\*---------------------------------------------------------------------------*/
55
57:
58 public passiveParticle
59{
60 // Private Member Data
61
62 //- Cached position
63 point cachedPosition_;
64
65
66public:
67
68 // Constructors
69
70 //- Construct from Istream in old format
72 (
73 const polyMesh& mesh,
74 Istream& is,
75 bool readFields,
76 bool newFormat
77 )
78 :
79 passiveParticle(mesh, is, readFields, newFormat),
80 cachedPosition_(position())
81 {}
82
83 //- Construct from a position and a cell.
84 // Searches for the rest of the required topology.
86 (
87 const polyMesh& mesh,
88 const vector& position,
89 const label celli = -1
90 )
91 :
93 cachedPosition_(position)
94 {}
95
96 //- Construct as copy
98 :
100 cachedPosition_(p.cachedPosition_)
101 {}
102
103 //- Return a clone
104 virtual autoPtr<particle> clone() const
105 {
106 return particle::Clone(*this);
107 }
108
109
110 //- Factory class to read-construct particles (for parallel transfer)
111 class iNew
112 {
113 const polyMesh& mesh_;
114
115 public:
116
117 iNew(const polyMesh& mesh)
118 :
119 mesh_(mesh)
120 {}
121
123 {
126 // Read in old format
127 new passivePositionParticle(mesh_, is, true, false)
128 );
129 }
130 };
131
132
133 // Member Functions
134
135 const point& cachedPosition() const noexcept
136 {
137 return cachedPosition_;
138 }
139
140
141 // Friend Operators
142
143 friend Ostream& operator<<
144 (
145 Ostream& os,
146 const passivePositionParticle& ppi
147 )
148 {
149 // Copy data into old format structure. Exact opposite of
150 // particleIO.C reading old format.
152
153 p.position = ppi.cachedPosition_;
154 p.celli = ppi.cell();
155 p.facei = ppi.face();
156 p.stepFraction = ppi.stepFraction();
157 p.tetFacei = ppi.tetFace();
158 p.tetPti = ppi.tetPt();
159 p.origProc = ppi.origProc();
160 p.origId = ppi.origId();
161
162 if (os.format() == IOstreamOption::ASCII)
163 {
164 os << p.position
165 << token::SPACE << p.celli
166 << token::SPACE << p.facei
167 << token::SPACE << p.stepFraction
168 << token::SPACE << p.tetFacei
169 << token::SPACE << p.tetPti
170 << token::SPACE << p.origProc
171 << token::SPACE << p.origId;
172 }
173 else
174 {
175 const std::size_t sizeofFields
176 (
179 );
180
181 os.write
182 (
183 reinterpret_cast<const char*>(&p.position),
184 sizeofFields
185 );
186 }
187 return os;
188 }
189};
190
191
192// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
193
194} // End namespace Foam
195
196// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
197
198#endif
199
200// ************************************************************************* //
@ ASCII
"ascii" (normal default)
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition Istream.H:60
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
vector position() const
Return current particle position.
Definition particleI.H:283
static void readFields(TrackCloudType &c)
Read the fields associated with the owner cloud.
static autoPtr< particle > Clone(const Derived &p)
Clone a particle.
Definition particle.H:552
const polyMesh & mesh() const noexcept
Return the mesh database.
Definition particleI.H:110
Copy of base particle.
passiveParticle(const polyMesh &mesh, const barycentric &coordinates, const label celli, const label tetFacei, const label tetPti)
Construct from components.
Factory class to read-construct particles (for parallel transfer).
autoPtr< passivePositionParticle > operator()(Istream &is) const
Copy of base particle but without particle locating and preserving read location.
passivePositionParticle(const polyMesh &mesh, const barycentric &coordinates, const label celli, const label tetFacei, const label tetPti)
Construct from components (known location).
virtual autoPtr< particle > clone() const
Return a clone.
passivePositionParticle(const polyMesh &mesh, Istream &is, bool readFields, bool newFormat)
Construct from Istream in old format.
passivePositionParticle(const polyMesh &mesh, const vector &position, const label celli=-1)
Construct from a position and a cell.
passivePositionParticle(const passivePositionParticle &p)
Construct as copy.
const point & cachedPosition() const noexcept
Mesh consisting of general polyhedral cells.
Definition polyMesh.H:79
@ SPACE
Space [isspace].
Definition token.H:144
volScalarField & p
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
vector point
Point is a vector.
Definition point.H:37
const direction noexcept
Definition scalarImpl.H:265
Vector< scalar > vector
Definition vector.H:57
Old particle positions content for OpenFOAM-1706 and earlier.
Definition particle.H:123