findCellParticle.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2013-2018 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "findCellParticle.H"
27 
28 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
29 
31 (
32  const polyMesh& mesh,
33  const barycentric& coordinates,
34  const label celli,
35  const label tetFacei,
36  const label tetPtI,
37  const vector& displacement,
38  const label data
39 )
40 :
41  particle(mesh, coordinates, celli, tetFacei, tetPtI),
42  displacement_(displacement),
43  data_(data)
44 {}
45 
46 
48 (
49  const polyMesh& mesh,
50  const vector& position,
51  const label celli,
52  const vector& displacement,
53  const label data
54 )
55 :
56  particle(mesh, position, celli),
57  displacement_(displacement),
58  data_(data)
59 {}
60 
61 
63 (
64  const polyMesh& mesh,
65  Istream& is,
66  bool readFields
67 )
68 :
69  particle(mesh, is, readFields)
70 {
71  if (readFields)
72  {
73  if (is.format() == IOstream::ASCII)
74  {
75  is >> displacement_;
76  data_ = readLabel(is);
77  }
78  else
79  {
80  is.read
81  (
82  reinterpret_cast<char*>(&displacement_),
83  sizeof(displacement_) + sizeof(data_)
84  );
85  }
86  }
87 
88  // Check state of Istream
89  is.check
90  (
91  "findCellParticle::findCellParticle"
92  "(const Cloud<findCellParticle>&, Istream&, bool)"
93  );
94 }
95 
96 
97 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
98 
100 (
102  trackingData& td,
103  const scalar maxTrackLen
104 )
105 {
106  td.switchProcessor = false;
107  td.keepParticle = true;
108 
109  while (td.keepParticle && !td.switchProcessor && stepFraction() < 1)
110  {
111  const scalar f = 1 - stepFraction();
112  trackToAndHitFace(f*displacement_, f, cloud, td);
113  }
114 
115  if (!td.switchProcessor)
116  {
117  // Hit endpoint or patch. If patch hit could do fancy stuff but just
118  // to use the patch point is good enough for now.
119  td.cellToData()[cell()].append(data());
120  td.cellToEnd()[cell()].append(position());
121  }
122 
123  return td.keepParticle;
124 }
125 
126 
128 {
129  return false;
130 }
131 
132 
134 (
136  trackingData& td
137 )
138 {
139  // Remove particle
140  td.keepParticle = false;
141 }
142 
143 
145 (
147  trackingData& td
148 )
149 {
150  // Remove particle
151  td.keepParticle = false;
152 }
153 
154 
156 (
158  trackingData& td
159 )
160 {
161  // Remove particle
162  td.keepParticle = false;
163 }
164 
165 
167 (
169  trackingData& td
170 )
171 {
172  // Remove particle
173  td.keepParticle = false;
174 }
175 
176 
178 (
179  const vector&,
180  const scalar,
182  trackingData& td
183 )
184 {
185  // Remove particle
186  td.keepParticle = false;
187 }
188 
189 
191 (
192  const vector&,
193  const scalar,
195  trackingData& td
196 )
197 {
198  // Remove particle
199  td.keepParticle = false;
200 }
201 
202 
204 (
205  const vector&,
206  const scalar,
208  trackingData& td
209 )
210 {
211  // Remove particle
212  td.keepParticle = false;
213 }
214 
215 
217 (
219  trackingData& td
220 )
221 {
222  // Remove particle
223  td.switchProcessor = true;
224 }
225 
226 
228 (
230  trackingData& td
231 )
232 {
233  // Remove particle
234  td.keepParticle = false;
235 }
236 
237 
238 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
239 
241 {
242  if (os.format() == IOstream::ASCII)
243  {
244  os << static_cast<const particle&>(p)
245  << token::SPACE << p.displacement_
246  << token::SPACE << p.data_;
247  }
248  else
249  {
250  os << static_cast<const particle&>(p);
251  os.write
252  (
253  reinterpret_cast<const char*>(&p.displacement_),
254  sizeof(p.displacement_) + sizeof(p.data_)
255  );
256  }
257 
258  // Check state of Ostream
259  os.check("Ostream& operator<<(Ostream&, const findCellParticle&)");
260 
261  return os;
262 }
263 
264 
265 // ************************************************************************* //
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
void hitCyclicACMIPatch(const vector &, const scalar, Cloud< findCellParticle > &, trackingData &)
Overridable function to handle the particle hitting a cyclicACMI.
bool move(Cloud< findCellParticle > &, trackingData &, const scalar)
Track all particles to their end point.
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:92
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
void hitCyclicPatch(Cloud< findCellParticle > &, trackingData &)
Overridable function to handle the particle hitting a cyclic.
void hitSymmetryPatch(Cloud< findCellParticle > &, trackingData &)
Overridable function to handle the particle hitting a.
Base particle class.
Definition: particle.H:84
void hitProcessorPatch(Cloud< findCellParticle > &, trackingData &)
void hitWedgePatch(Cloud< findCellParticle > &, trackingData &)
Overridable function to handle the particle hitting a wedge.
virtual Istream & read(token &)=0
Return next token from stream.
bool switchProcessor
Flag to switch processor.
Definition: particle.H:110
findCellParticle(const polyMesh &mesh, const barycentric &coordinates, const label celli, const label tetFacei, const label tetPtI, const vector &displacement, const label data)
Construct from components.
void append(const T &)
Append an element at the end of the list.
Definition: ListI.H:177
streamFormat format() const
Return current stream format.
Definition: IOstream.H:377
label readLabel(Istream &is)
Definition: label.H:64
Base cloud calls templated on particle type.
Definition: Cloud.H:52
void hitCyclicAMIPatch(const vector &, const scalar, Cloud< findCellParticle > &, trackingData &)
Overridable function to handle the particle hitting a cyclicAMI.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
labelList f(nPoints)
void hitCyclicRepeatAMIPatch(const vector &, const scalar, Cloud< findCellParticle > &, trackingData &)
Overridable function to handle the particle hitting a.
bool hitPatch(Cloud< findCellParticle > &, trackingData &)
Overridable function to handle the particle hitting a patch.
List< List< point > > & cellToEnd()
bool keepParticle
Flag to indicate whether to keep particle (false = delete)
Definition: particle.H:113
A cell is defined as a list of faces with extra functionality.
Definition: cell.H:56
Ostream & operator<<(Ostream &, const ensightPart &)
Particle class that finds cells by tracking.
virtual Ostream & write(const token &)=0
Write next token to stream.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
volScalarField & p
void hitWallPatch(Cloud< findCellParticle > &, trackingData &)
Overridable function to handle the particle hitting a wallPatch.
Class used to pass tracking data to the trackToFace function.
void hitSymmetryPlanePatch(Cloud< findCellParticle > &, trackingData &)
Overridable function to handle the particle hitting a.