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-2022 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 vector& position,
34  const label celli,
35  const vector& displacement,
36  const label data
37 )
38 :
39  particle(mesh, position, celli),
40  displacement_(displacement),
41  data_(data)
42 {}
43 
44 
46 :
47  particle(is, readFields)
48 {
49  if (readFields)
50  {
51  if (is.format() == IOstream::ASCII)
52  {
53  is >> displacement_;
54  data_ = readLabel(is);
55  }
56  else
57  {
58  is.read
59  (
60  reinterpret_cast<char*>(&displacement_),
61  sizeof(displacement_) + sizeof(data_)
62  );
63  }
64  }
65 
66  // Check state of Istream
67  is.check
68  (
69  "findCellParticle::findCellParticle"
70  "(const Cloud<findCellParticle>&, Istream&, bool)"
71  );
72 }
73 
74 
75 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
76 
78 (
80  trackingData& td
81 )
82 {
83  td.keepParticle = true;
84  td.sendToProc = -1;
85 
86  while (td.keepParticle && td.sendToProc == -1 && stepFraction() < 1)
87  {
88  const scalar f = 1 - stepFraction();
89  trackToAndHitFace(f*displacement_, f, cloud, td);
90  }
91 
92  if (td.sendToProc == -1)
93  {
94  // Hit endpoint or patch. If patch hit could do fancy stuff but just
95  // to use the patch point is good enough for now.
96  td.cellToData()[cell()].append(data());
97  td.cellToEnd()[cell()].append(position(td.mesh));
98  }
99 
100  return td.keepParticle;
101 }
102 
103 
105 (
107  trackingData& td
108 )
109 {
110  // Remove particle
111  td.keepParticle = false;
112 }
113 
114 
116 (
118  trackingData& td
119 )
120 {
121  // Remove particle
122  td.keepParticle = false;
123 }
124 
125 
127 (
129  trackingData& td
130 )
131 {
132  // Remove particle
133  td.keepParticle = false;
134 }
135 
136 
138 (
140  trackingData& td
141 )
142 {
143  // Remove particle
144  td.keepParticle = false;
145 }
146 
147 
149 (
151  trackingData& td
152 )
153 {
154  const processorPolyPatch& ppp =
155  static_cast<const processorPolyPatch&>
156  (
157  td.mesh.boundaryMesh()[patch(td.mesh)]
158  );
159 
160  if (ppp.transform().transforms())
161  {
162  td.keepParticle = false;
163  }
164  else
165  {
167  }
168 }
169 
170 
172 (
174  trackingData& td
175 )
176 {
177  // Remove particle
178  td.keepParticle = false;
179 }
180 
181 
182 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
183 
185 {
186  if (os.format() == IOstream::ASCII)
187  {
188  os << static_cast<const particle&>(p)
189  << token::SPACE << p.displacement_
190  << token::SPACE << p.data_;
191  }
192  else
193  {
194  os << static_cast<const particle&>(p);
195  os.write
196  (
197  reinterpret_cast<const char*>(&p.displacement_),
198  sizeof(p.displacement_) + sizeof(p.data_)
199  );
200  }
201 
202  // Check state of Ostream
203  os.check("Ostream& operator<<(Ostream&, const findCellParticle&)");
204 
205  return os;
206 }
207 
208 
209 // ************************************************************************* //
Base cloud calls templated on particle type.
Definition: Cloud.H:74
streamFormat format() const
Return current stream format.
Definition: IOstream.H:374
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:60
virtual Istream & read(token &)=0
Return next token from stream.
void append(const T &)
Append an element at the end of the list.
Definition: ListI.H:178
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
virtual Ostream & write(const char)=0
Write character.
A cell is defined as a list of faces with extra functionality.
Definition: cell.H:60
A cloud is a collection of lagrangian particles.
Definition: cloud.H:55
Database for solution and other reduced data.
Definition: data.H:54
Class used to pass tracking data to the trackToFace function.
List< List< point > > & cellToEnd()
Particle class that finds cells by tracking.
findCellParticle(const polyMesh &mesh, const vector &position, const label celli, const vector &displacement, const label data)
Construct from a position and a cell, searching for the rest of the.
void hitWallPatch(Cloud< findCellParticle > &, trackingData &)
Overridable function to handle the particle hitting a wallPatch.
void hitProcessorPatch(Cloud< findCellParticle > &, trackingData &)
void hitSymmetryPatch(Cloud< findCellParticle > &, trackingData &)
Overridable function to handle the particle hitting a.
void hitSymmetryPlanePatch(Cloud< findCellParticle > &, trackingData &)
Overridable function to handle the particle hitting a.
void hitWedgePatch(Cloud< findCellParticle > &, trackingData &)
Overridable function to handle the particle hitting a wedge.
void hitCyclicPatch(Cloud< findCellParticle > &, trackingData &)
Overridable function to handle the particle hitting a cyclic.
bool move(Cloud< findCellParticle > &, trackingData &)
Track all particles to their end point.
label sendToProc
Processor to send the particle to. -1 indicates that this.
Definition: particle.H:113
bool keepParticle
Flag to indicate whether to keep particle (false = delete)
Definition: particle.H:109
const polyMesh & mesh
Reference to the mesh.
Definition: particle.H:106
Base particle class.
Definition: particle.H:83
static void readFields(TrackCloudType &c)
Read the fields associated with the owner cloud.
void hitProcessorPatch(TrackCloudType &, trackingData &)
Overridable function to handle the particle hitting a.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:403
Neighbour processor patch.
virtual const transformer & transform() const
Return null transform between processor patches.
bool transforms() const
Return true if the transformer transforms a type.
Definition: transformerI.H:133
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 readFields(const typename GeoFieldType::Mesh &mesh, const IOobjectList &objects, const HashSet< word > &selectedFields, LIFOStack< regIOobject * > &storedObjects)
Read the selected GeometricFields of the specified type.
Definition: ReadFields.C:244
label readLabel(Istream &is)
Definition: label.H:64
Ostream & operator<<(Ostream &, const ensightPart &)
labelList f(nPoints)
volScalarField & p