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-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::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 passivePositionParticle_H
39#define passivePositionParticle_H
40
41#include "passiveParticle.H"
42
43// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44
45namespace Foam
46{
47
48// Forward Declarations
49class passivePositionParticle;
50Ostream& operator<<(Ostream& os, const passivePositionParticle& ppi);
51
52/*---------------------------------------------------------------------------*\
53 Class passivePositionParticle Declaration
54\*---------------------------------------------------------------------------*/
55
56class passivePositionParticle
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 //- Construct and return a clone
104 virtual autoPtr<particle> clone() const
105 {
107 }
108
109
110 //- Factory class to read-construct particles (for parallel transfer)
111 class iNew
112 {
113 const polyMesh& mesh_;
114
115 public:
117 iNew(const polyMesh& mesh)
118 :
119 mesh_(mesh)
120 {}
123 {
125 (
126 // Read in old format
127 new passivePositionParticle(mesh_, is, true, false)
128 );
129 }
130 };
131
133 const point& cachedPosition() const
134 {
135 return cachedPosition_;
136 }
137
138
139 // Friend Operators
141 friend Ostream& operator<<
142 (
143 Ostream& os,
144 const passivePositionParticle& ppi
145 )
146 {
147 // Copy data into old format structure. Exact opposite of
148 // particleIO.C reading old format.
150
151 p.position = ppi.cachedPosition_;
152 p.celli = ppi.cell();
153 p.facei = ppi.face();
154 p.stepFraction = ppi.stepFraction();
155 p.tetFacei = ppi.tetFace();
156 p.tetPti = ppi.tetPt();
157 p.origProc = ppi.origProc();
158 p.origId = ppi.origId();
159
160 if (os.format() == IOstream::ASCII)
161 {
162 os << p.position
163 << token::SPACE << p.celli
164 << token::SPACE << p.facei
165 << token::SPACE << p.stepFraction
166 << token::SPACE << p.tetFacei
167 << token::SPACE << p.tetPti
168 << token::SPACE << p.origProc
169 << token::SPACE << p.origId;
170 }
171 else
172 {
173 const std::size_t sizeofFields
174 (
177 );
178
179 os.write
180 (
181 reinterpret_cast<const char*>(&p.position),
182 sizeofFields
183 );
184 }
185 return os;
186 }
187};
188
189
190// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
191
192} // End namespace Foam
193
194// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
195
196#endif
197
198// ************************************************************************* //
streamFormat format() const noexcept
Get the current stream format.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
virtual Ostream & write(const char c)
Write character.
Definition: OBJstream.C:78
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
vector position() const
Return current particle position.
Definition: particleI.H:314
static void readFields(TrackCloudType &c)
Read the fields associated with the owner cloud.
const polyMesh & mesh() const noexcept
Return the mesh database.
Definition: particleI.H:137
Copy of base particle.
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.
virtual autoPtr< particle > clone() const
Construct and return a clone.
passivePositionParticle(const polyMesh &mesh, Istream &is, bool readFields, bool newFormat)
Construct from Istream in old format.
passivePositionParticle(const passivePositionParticle &p)
Construct as copy.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
@ SPACE
Space [isspace].
Definition: token.H:125
volScalarField & p
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
vector point
Point is a vector.
Definition: point.H:43
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Old particle positions content for OpenFOAM-1706 and earlier.
Definition: particle.H:117