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 (
180  trackingData& td,
181  const vector&
182 )
183 {
184  // Remove particle
185  td.keepParticle = false;
186 }
187 
188 
190 (
192  trackingData& td,
193  const vector&
194 )
195 {
196  // Remove particle
197  td.keepParticle = false;
198 }
199 
200 
202 (
204  trackingData& td
205 )
206 {
207  // Remove particle
208  td.switchProcessor = true;
209 }
210 
211 
213 (
215  trackingData& td
216 )
217 {
218  // Remove particle
219  td.keepParticle = false;
220 }
221 
222 
223 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
224 
226 {
227  if (os.format() == IOstream::ASCII)
228  {
229  os << static_cast<const particle&>(p)
230  << token::SPACE << p.displacement_
231  << token::SPACE << p.data_;
232  }
233  else
234  {
235  os << static_cast<const particle&>(p);
236  os.write
237  (
238  reinterpret_cast<const char*>(&p.displacement_),
239  sizeof(p.displacement_) + sizeof(p.data_)
240  );
241  }
242 
243  // Check state of Ostream
244  os.check("Ostream& operator<<(Ostream&, const findCellParticle&)");
245 
246  return os;
247 }
248 
249 
250 // ************************************************************************* //
void hitCyclicAMIPatch(Cloud< findCellParticle > &, trackingData &, const vector &)
Overridable function to handle the particle hitting a cyclicAMI.
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
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.
void hitCyclicACMIPatch(Cloud< findCellParticle > &, trackingData &, const vector &)
Overridable function to handle the particle hitting a cyclicACMI.
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:116
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:184
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
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
labelList f(nPoints)
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:119
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.