34 Foam::vector Foam::streamlinesParticle::interpolateFields
36 const trackingData& td,
37 const point& position,
48 bool interpolatedU =
false;
51 forAll(td.scalarInterp_, fieldi)
53 #define InterpolateType(Type, nullArg) \
54 if (td.Type##Interp_.set(fieldi)) \
57 td.Type##Interp_[fieldi].interpolate \
64 sampled##Type##s_.setSize(td.Type##Interp_.size()); \
65 sampled##Type##s_[fieldi].append \
67 td.trackOutside_ ? transform_.invTransform(s) : s \
71 #undef InterpolateType
75 td.vectorInterp_.set(fieldi)
76 && &td.vectorInterp_[fieldi] == &td.UInterp_
80 U = sampledvectors_[fieldi].last();
87 U = td.UInterp_.interpolate(
position, celli, facei);
94 void Foam::streamlinesParticle::endTrack(trackingData& td)
96 const label n = sampledPositions_.size();
98 const label trackPartIndex =
99 td.trackForward_ ? trackPartIndex_ : -1 - trackPartIndex_;
101 if (!td.trackForward_)
reverse(sampledPositions_);
102 td.allPositions_.append(sampledPositions_);
103 sampledPositions_.clear();
105 td.allTracks_.append(List<label>(
n, trackIndex_));
106 td.allTrackParts_.append(List<label>(
n, trackPartIndex));
109 if (!td.trackForward_)
reverse(sampledAges_);
110 td.allAges_.append(sampledAges_);
111 sampledAges_.clear();
113 forAll(td.scalarInterp_, fieldi)
115 #define EndTrackType(Type, nullArg) \
116 if (td.Type##Interp_.set(fieldi)) \
118 if (!td.trackForward_) reverse(sampled##Type##s_[fieldi]); \
119 td.all##Type##s_[fieldi].append(sampled##Type##s_[fieldi]); \
120 sampled##Type##s_[fieldi].clear(); \
135 label& nLocateBoundaryHits,
136 const label lifeTime,
137 const label trackIndex
140 particle(mesh, position, celli, nLocateBoundaryHits),
142 trackIndex_(trackIndex),
155 is >> lifeTime_ >> trackIndex_ >> trackPartIndex_ >> age_
156 >> transform_ >> sampledPositions_ >> sampledAges_;
158 #define ReadSampledTypes(Type, nullArg) \
159 List<List<Type>> sampled##Type##s; \
160 is >> sampled##Type##s; \
161 sampled##Type##s_.setSize(sampled##Type##s.size()); \
162 forAll(sampled##Type##s, i) \
164 sampled##Type##s_[i].transfer(sampled##Type##s[i]); \
167 #undef ReadSampledTypes
173 "streamlinesParticle::streamlinesParticle"
174 "(const Cloud<streamlinesParticle>&, Istream&, bool)"
185 lifeTime_(
p.lifeTime_),
186 trackIndex_(
p.trackIndex_),
187 trackPartIndex_(
p.trackPartIndex_),
189 transform_(
p.transform_),
190 sampledPositions_(
p.sampledPositions_),
191 sampledAges_(
p.sampledAges_)
193 , sampled##Type##s_(
p.sampled##Type##s_)
224 sampledPositions_.append
227 ? transform_.invTransformPosition(position(td.
mesh))
230 sampledAges_.append(age_);
238 scalar magU =
mag(
U);
254 else if (subIter == 0)
270 *(1 - trackToAndHitFace(dt*
U, 0,
cloud, td));
286 Pout<<
"streamlinesParticle: Removing stagnant particle:"
287 << position(td.
mesh) <<
" sampled positions:"
288 << sampledPositions_.size() <<
endl;
295 sampledPositions_.append
298 ? transform_.invTransformPosition(position(td.
mesh))
301 sampledAges_.append(age_);
302 interpolateFields(td, position(td.
mesh),
cell(),
face());
306 Pout<<
"streamlinesParticle: Removing particle:"
307 << position(td.
mesh) <<
" sampled positions:"
308 << sampledPositions_.size() <<
endl;
378 const vector& displacement,
379 const scalar fraction,
397 if (result) endTrack(td);
455 c.checkFieldIOobject(
c, lifeTime);
462 c.checkFieldIOobject(
c, trackIndex);
469 c.checkFieldIOobject(
c, trackPartIndex);
476 c.checkFieldIOobject(
c, age);
490 c.checkFieldIOobject(
c, sampledPositions);
497 c.checkFieldIOobject(
c, sampledAges);
502 iter().lifeTime_ = lifeTime[i];
503 iter().trackIndex_ = trackIndex[i];
504 iter().trackPartIndex_ = trackPartIndex[i];
505 iter().age_ = age[i];
507 iter().sampledPositions_.transfer(sampledPositions[i]);
508 iter().sampledAges_.transfer(sampledAges[i]);
565 lifeTime[i] = iter().lifeTime_;
566 trackIndex[i] = iter().trackIndex_;
567 trackPartIndex[i] = iter().trackPartIndex_;
568 age[i] = iter().age_;
570 sampledPositions[i] = iter().sampledPositions_;
571 sampledAges[i] = iter().sampledAges_;
575 lifeTime.
write(np > 0);
576 trackIndex.
write(np > 0);
577 trackPartIndex.
write(np > 0);
580 sampledPositions.
write(np > 0);
581 sampledAges.
write(np > 0);
590 os << static_cast<const particle&>(
p)
598 #define WriteSampledTypes(Type, nullArg) \
599 << token::SPACE << p.sampled##Type##s_
601 #undef WriteSampledTypes
604 os.
check(
"Ostream& operator<<(Ostream&, const streamlinesParticle&)");
#define forAll(list, i)
Loop across all elements in list.
#define forAllIter(Container, container, iter)
Iterate across all elements in the container object of type.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
A primitive field of type <Type> with automated input and output.
A List of objects of type <Type> with automated input and output.
virtual bool check(const char *operation) const
Check IOstream status for given operation.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
static Form uniform(const Cmpt &s)
Return a VectorSpace with all elements = s.
scalar mag() const
The magnitude of the bounding box span.
A cell is defined as a list of faces with extra functionality.
A cloud is a collection of lagrangian particles.
virtual const transformer & transform() const
Return transformation between the coupled patches.
Ostream & write(Ostream &os) const
Write.
A face is a list of labels corresponding to mesh vertices.
label sendToProc
Processor to send the particle to. -1 indicates that this.
bool keepParticle
Flag to indicate whether to keep particle (false = delete)
const polyMesh & mesh
Reference to the mesh.
static void readFields(TrackCloudType &c)
Read the fields associated with the owner cloud.
void hitCyclicPatch(TrackCloudType &, trackingData &)
Overridable function to handle the particle hitting a.
void hitProcessorPatch(TrackCloudType &, trackingData &)
Overridable function to handle the particle hitting a.
scalar trackToFace(const polyMesh &mesh, const vector &displacement, const scalar fraction)
As particle::track, but stops when a face is hit.
scalar stepFraction() const
Return the fraction of time-step completed.
vector position(const polyMesh &mesh) const
Return current particle position.
bool hitNonConformalCyclicPatch(const vector &displacement, const scalar fraction, const label patchi, TrackCloudType &cloud, trackingData &td)
Overridable function to handle the particle hitting an.
static void writeFields(const TrackCloudType &c)
Write the fields associated with the owner cloud.
Mesh consisting of general polyhedral cells.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
const boundBox & bounds() const
Return mesh bounding box.
Neighbour processor patch.
virtual const transformer & transform() const
Return null transform between processor patches.
virtual bool write(const bool write=true) const
Write using setting from DB.
A Cloud of streamlines particles.
const scalar trackLength_
Particle class that samples fields as it passes through. Used in streamlines calculation.
bool move(streamlinesCloud &, trackingData &)
Track all particles to their end point.
static void writeFields(const Cloud< streamlinesParticle > &)
Write.
void hitProcessorPatch(streamlinesCloud &, trackingData &)
Overridable function to handle the particle hitting a.
bool hitNonConformalCyclicPatch(const vector &displacement, const scalar fraction, const label patchi, streamlinesCloud &cloud, trackingData &td)
Overridable function to handle the particle hitting an.
void hitSymmetryPatch(streamlinesCloud &, trackingData &)
Overridable function to handle the particle hitting a.
void hitCyclicPatch(streamlinesCloud &, trackingData &)
Overridable function to handle the particle hitting a cyclic.
void hitWallPatch(streamlinesCloud &, trackingData &)
Overridable function to handle the particle hitting a wallPatch.
void hitSymmetryPlanePatch(streamlinesCloud &, trackingData &)
Overridable function to handle the particle hitting a.
static void readFields(Cloud< streamlinesParticle > &)
Read.
streamlinesParticle(const polyMesh &mesh, const vector &position, const label celli, label &nLocateBoundaryHits, const label lifeTime, const label trackIndex)
Construct from components.
virtual void transformProperties(const transformer &)
Transform the physical properties of the particle.
void hitWedgePatch(streamlinesCloud &, trackingData &)
Overridable function to handle the particle hitting a wedge.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
bool valid(const PtrList< ModelType > &l)
const dimensionedScalar c
Speed of light in a vacuum.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
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.
errorManip< error > abort(error &err)
static const Identity< scalar > I
vector point
Point is a vector.
void reverse(UList< T > &, const label n)
Vector< scalar > vector
A scalar version of the templated Vector.
dimensionSet transform(const dimensionSet &)
dimensioned< scalar > mag(const dimensioned< Type > &)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
prefixOSstream Pout(cout, "Pout")
Ostream & operator<<(Ostream &os, const fvConstraints &constraints)
FOR_ALL_FIELD_TYPES(makeFieldSourceTypedef)
#define InterpolateType(Type, nullArg)
#define WriteSampledTypes(Type, nullArg)
#define EndTrackType(Type, nullArg)
#define SampledTypesInit(Type, nullArg)
#define ReadSampledTypes(Type, nullArg)