53 x.append(
new Type(iter()));
64 template<
class ParticleType>
70 const polyBoundaryMesh& pbm = pMesh.boundaryMesh();
74 if (Pstream::parRun())
78 if (isA<processorPolyPatch>(pbm[
patchi]))
80 const processorPolyPatch& ppp =
81 refCast<const processorPolyPatch>(pbm[
patchi]);
83 result[
patchi] = ppp.neighbProcNo();
92 template<
class ParticleType>
98 const polyBoundaryMesh& pbm = pMesh.boundaryMesh();
102 if (Pstream::parRun())
104 PstreamBuffers pBufs(Pstream::commsTypes::nonBlocking);
108 if (isA<processorPolyPatch>(pbm[
patchi]))
110 const processorPolyPatch& ppp =
111 refCast<const processorPolyPatch>(pbm[
patchi]);
113 UOPstream(ppp.neighbProcNo(), pBufs)()
122 if (isA<processorPolyPatch>(pbm[
patchi]))
124 const processorPolyPatch& ppp =
125 refCast<const processorPolyPatch>(pbm[
patchi]);
127 UIPstream(ppp.neighbProcNo(), pBufs)()
137 template<
class ParticleType>
140 const polyMesh& pMesh
149 if (isA<nonConformalCyclicPolyPatch>(pbm[
patchi]))
152 refCast<const nonConformalCyclicPolyPatch>(pbm[
patchi]);
162 template<
class ParticleType>
165 const polyBoundaryMesh& pbm = pMesh_.boundaryMesh();
171 const label nccPatchi =
172 patchNonConformalCyclicPatches_[
patchi][i];
174 const nonConformalCyclicPolyPatch& nccPp =
175 refCast<const nonConformalCyclicPolyPatch>(pbm[nccPatchi]);
177 if (nccPp.owner()) nccPp.rays();
185 template<
class ParticleType>
196 patchNbrProc_(patchNbrProc(pMesh)),
197 patchNbrProcPatch_(patchNbrProcPatch(pMesh)),
198 patchNonConformalCyclicPatches_(patchNonConformalCyclicPatches(pMesh)),
199 globalPositionsPtr_(),
208 if (particles.size())
217 template<
class ParticleType>
224 template<
class ParticleType>
227 delete(this->remove(&
p));
231 template<
class ParticleType>
236 ParticleType&
p = pIter();
241 <<
"deleting lost particle at position "
242 <<
p.position(pMesh_) <<
endl;
250 template<
class ParticleType>
255 ParticleType::particleCount_ = 0;
260 template<
class ParticleType>
268 timeIndex_ = pMesh_.time().timeIndex();
272 template<
class ParticleType>
273 template<
class TrackCloudType>
276 TrackCloudType&
cloud,
277 typename ParticleType::trackingData& td
281 if (timeIndex_ != pMesh_.time().timeIndex())
287 globalPositionsPtr_.clear();
303 forAll(sendParticles, proci)
305 sendParticles[proci].
clear();
306 sendPatchIndices[proci].
clear();
312 ParticleType&
p = pIter();
315 const bool keepParticle =
p.move(
cloud, td);
320 if (td.sendToProc != -1)
326 <<
"Switch processor flag is true when no parallel "
327 <<
"transfer is possible. This is a bug."
332 p.prepareForParallelTransfer(
cloud, td);
334 sendParticles[td.sendToProc].
append(this->remove(&
p));
336 sendPatchIndices[td.sendToProc].
append(td.sendToPatch);
355 forAll(sendParticles, proci)
357 if (sendParticles[proci].size())
359 UOPstream particleStream(proci, pBufs);
362 << sendPatchIndices[proci]
363 << sendParticles[proci];
372 bool transferred =
false;
373 forAll(receiveSizes, proci)
375 if (receiveSizes[proci])
381 reduce(transferred, orOp<bool>());
388 forAll(receiveSizes, proci)
390 if (receiveSizes[proci])
392 UIPstream particleStream(proci, pBufs);
394 const labelList receivePatchIndices(particleStream);
396 IDLList<ParticleType> newParticles(particleStream);
400 forAllIter(
typename Cloud<ParticleType>, newParticles, iter)
404 ParticleType&
p = iter();
408 p.correctAfterParallelTransfer(cloud, td);
410 addParticle(newParticles.remove(&
p));
418 template<
class ParticleType>
426 pMesh_.tetBasePtIs();
427 pMesh_.oldCellCentres();
429 if (!globalPositionsPtr_.valid())
432 <<
"Global positions are not available. "
433 <<
"Cloud::storeGlobalPositions has not been called."
437 const vectorField& positions = globalPositionsPtr_();
443 iter().map(pMesh_, positions[particlei++], celli);
448 template<
class ParticleType>
454 pMesh_.tetBasePtIs();
455 pMesh_.oldCellCentres();
458 patchNbrProc_ = patchNbrProc(pMesh_);
459 patchNbrProcPatch_ = patchNbrProcPatch(pMesh_);
460 patchNonConformalCyclicPatches_ = patchNonConformalCyclicPatches(pMesh_);
462 if (!globalPositionsPtr_.valid())
465 <<
"Global positions are not available. "
466 <<
"Cloud::storeGlobalPositions has not been called."
470 const vectorField& positions = globalPositionsPtr_();
481 const point&
pos = positions[particlei ++];
483 const remote tgtProcCell =
486 if (tgtProcCell ==
remote())
489 <<
"Particle at " <<
pos <<
" mapped to a location outside "
490 <<
"of the new mesh. This particle will be removed." <<
nl;
500 sendParticles[tgtProcCell.
proci].
append(this->remove(iter));
515 forAll(sendParticles, proci)
517 if (sendParticles[proci].size())
522 << sendCellIndices[proci]
523 << sendPositions[proci]
524 << sendParticles[proci];
533 forAll(sendParticles, proci)
535 if (receiveSizes[proci])
539 const labelList receiveCellIndices(particleStream);
540 const List<point> receivePositions(particleStream);
546 const label celli = receiveCellIndices[particlei];
547 const vector&
pos = receivePositions[particlei ++];
549 iter().map(pMesh_,
pos, celli);
550 this->append(receiveParticles.
remove(iter));
557 template<
class ParticleType>
563 pMesh_.tetBasePtIs();
564 pMesh_.oldCellCentres();
567 patchNbrProc_ = patchNbrProc(pMesh_);
568 patchNbrProcPatch_ = patchNbrProcPatch(pMesh_);
569 patchNonConformalCyclicPatches_ = patchNonConformalCyclicPatches(pMesh_);
571 if (!globalPositionsPtr_.valid())
574 <<
"Global positions are not available. "
575 <<
"Cloud::storeGlobalPositions has not been called."
579 const vectorField& positions = globalPositionsPtr_();
587 cellParticleis[iter().cell()] ++;
589 forAll(cellParticlePositions, celli)
591 cellParticlePositions[celli].
resize(cellParticleis[celli]);
598 const label celli = iter().cell();
599 label& cellParticlei = cellParticleis[celli];
601 cellParticlePositions[celli][cellParticlei ++] =
602 positions[particlei ++];
614 cellParticlePositions,
624 cellParticles[iter().cell()].
append(this->remove(iter));
642 forAll(cellParticles, celli)
644 label cellParticlei = 0;
647 const point&
pos = cellParticlePositions[celli][cellParticlei++];
649 iter().map(pMesh_,
pos, celli);
651 this->append(cellParticles[celli].remove(iter));
657 template<
class ParticleType>
662 this->db().time().path()/this->
name() +
"_positions.obj"
667 const point pos = pIter().position(pMesh_);
669 pObj<<
"v " <<
pos.x() <<
" " <<
pos.y() <<
" " <<
pos.z() <<
nl;
676 template<
class ParticleType>
684 globalPositionsPtr_.reset(
new vectorField(this->size()));
691 positions[particlei++] = iter().position(pMesh_);
Combination-Reduction operation for a parallel run. The information from all nodes is collected on th...
#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.
Base cloud calls templated on particle type.
void changeTimeStep()
Change the particles' state from the end of the previous time.
void deleteParticle(ParticleType &)
Remove particle from cloud and delete.
void writePositions() const
Write positions to <cloudName>_positions.obj file.
const labelListList & patchNonConformalCyclicPatches() const
Return map from patch index to connected non-conformal cyclics.
virtual void topoChange(const polyTopoChangeMap &)
Update topology using the given map.
virtual void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
const labelList & patchNbrProcPatch() const
Map from patch index to the corresponding patch index on the.
void deleteLostParticles()
Remove lost particles from cloud and delete.
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
void cloudReset(const Cloud< ParticleType > &c)
Reset the particles.
Cloud(const polyMesh &mesh, const word &cloudName, const IDLList< ParticleType > &particles)
Construct from mesh and a list of particles.
const labelList & patchNbrProc() const
Map from patch index to the neighbouring processor index.
void storeGlobalPositions() const
Call this before a topology change. Stores the particles global.
void addParticle(ParticleType *pPtr)
Transfer particle to cloud.
void move(TrackCloudType &cloud, typename ParticleType::trackingData &td)
Move the particles.
Template class for intrusive linked lists.
void operator=(const ILList< LListBase, T > &)
Assignment operator.
void append(const T &)
Append an element at the end of the list.
void resize(const label)
Alias for setSize(const label)
void clear()
Clear the list, i.e. set size to zero.
virtual void flush()
Flush stream.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
void finishedSends(const bool block=true)
Mark all sends as having been done. This will start receives.
void clear()
Clear storage and reset.
T * remove(T *p)
Remove and return element.
Input inter-processor communications stream operating on external buffer.
bool empty() const
Return true if the UList is empty (ie, size() is zero)
Output inter-processor communications stream operating on external buffer.
static label nProcs(const label communicator=0)
Number of processes in parallel run.
static bool & parRun()
Is this a parallel run?
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
label size() const
Return the number of elements in the UPtrList.
A cell is defined as a list of faces with extra functionality.
A cloud is a collection of lagrangian particles.
const labelListList & constructMap() const
From subsetted data to new reconstructed data.
const labelListList & subMap() const
From subsetted data back to original data.
static void distribute(const Pstream::commsTypes commsType, const List< labelPair > &schedule, const label constructSize, const labelListList &subMap, const bool subHasFlip, const labelListList &constructMap, const bool constructHasFlip, List< T > &, const negateOp &negOp, const int tag=UPstream::msgType())
Distribute data. Note:schedule only used for.
Class containing functor to negate primitives. Dummy for all other types.
remote srcToTgtPoint(const label srcCelli, const point &p) const
Find the target processor and cell associated with a point in a.
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
label nOldCells() const
Number of cells in mesh before distribution.
const distributionMap & cellMap() const
Cell distribute map.
Class containing mesh-to-mesh mapping information.
const meshToMesh & mapper() const
Return meshToMesh mapper.
Mesh consisting of general polyhedral cells.
const labelIOList & tetBasePtIs() const
Return the tetBasePtIs.
virtual const pointField & oldCellCentres() const
Return old cell centres for mesh motion.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
const labelList & reverseCellMap() const
Reverse cell map.
Struct for keeping processor, element (cell, face, point) index.
label elementi
Element index.
label proci
Processor index.
A class for handling words, derived from string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define WarningInFunction
Report a warning using Foam::Warning.
const dimensionedScalar c
Speed of light in a vacuum.
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensionedScalar pos(const dimensionedScalar &ds)
List< label > labelList
A List of labels.
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.
word name(const bool)
Return a word representation of a bool.
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
Field< vector > vectorField
Specialisation of Field<T> for vector.
void operator()(IDLList< Type > &x, const IDLList< Type > &y) const
List operator to append one list onto another.
const word cloudName(propsDict.lookup("cloudName"))