54 x.append(
new Type(iter()));
65 template<
class ParticleType>
71 const polyBoundaryMesh& pbm = pMesh.boundaryMesh();
75 if (Pstream::parRun())
79 if (isA<processorPolyPatch>(pbm[
patchi]))
81 const processorPolyPatch& ppp =
82 refCast<const processorPolyPatch>(pbm[
patchi]);
84 result[
patchi] = ppp.neighbProcNo();
93 template<
class ParticleType>
99 const polyBoundaryMesh& pbm = pMesh.boundaryMesh();
103 if (Pstream::parRun())
105 PstreamBuffers pBufs(Pstream::commsTypes::nonBlocking);
109 if (isA<processorPolyPatch>(pbm[
patchi]))
111 const processorPolyPatch& ppp =
112 refCast<const processorPolyPatch>(pbm[
patchi]);
114 UOPstream(ppp.neighbProcNo(), pBufs)()
123 if (isA<processorPolyPatch>(pbm[
patchi]))
125 const processorPolyPatch& ppp =
126 refCast<const processorPolyPatch>(pbm[
patchi]);
128 UIPstream(ppp.neighbProcNo(), pBufs)()
138 template<
class ParticleType>
141 const polyMesh& pMesh
150 if (isA<nonConformalCyclicPolyPatch>(pbm[
patchi]))
153 refCast<const nonConformalCyclicPolyPatch>(pbm[
patchi]);
163 template<
class ParticleType>
166 const polyBoundaryMesh& pbm = pMesh_.boundaryMesh();
172 const label nccPatchi =
173 patchNonConformalCyclicPatches_[
patchi][i];
175 const nonConformalCyclicPolyPatch& nccPp =
176 refCast<const nonConformalCyclicPolyPatch>(pbm[nccPatchi]);
178 if (nccPp.owner()) nccPp.rays();
186 template<
class ParticleType>
197 patchNbrProc_(patchNbrProc(pMesh)),
198 patchNbrProcPatch_(patchNbrProcPatch(pMesh)),
199 patchNonConformalCyclicPatches_(patchNonConformalCyclicPatches(pMesh)),
200 globalPositionsPtr_(),
209 if (particles.size())
218 template<
class ParticleType>
225 template<
class ParticleType>
228 delete(this->remove(&
p));
232 template<
class ParticleType>
239 if (pIter().
cell() == -1)
241 deleteParticle(pIter());
250 <<
"Cloud " << this->
name()
251 <<
" deleted " << lostCount <<
" lost particles" <<
endl;
256 template<
class ParticleType>
261 ParticleType::particleCount_ = 0;
266 template<
class ParticleType>
274 timeIndex_ = pMesh_.time().timeIndex();
278 template<
class ParticleType>
279 template<
class TrackCloudType>
282 TrackCloudType&
cloud,
283 typename ParticleType::trackingData& td
287 if (timeIndex_ != pMesh_.time().timeIndex())
293 globalPositionsPtr_.clear();
314 forAll(sendParticles, proci)
316 sendParticles[proci].
clear();
317 sendPatchIndices[proci].
clear();
328 ParticleType&
p = pIter();
331 const bool keepParticle =
p.move(
cloud, td);
341 if (td.sendToProc != -1)
347 <<
"Switch processor flag is true when no parallel "
348 <<
"transfer is possible. This is a bug."
353 p.prepareForParallelTransfer(cloud, td);
355 sendParticles[td.sendToProc].
append(this->remove(&
p));
357 sendPatchIndices[td.sendToProc].
append(td.sendToPatch);
376 forAll(sendParticles, proci)
378 if (sendParticles[proci].size())
380 UOPstream particleStream(proci, pBufs);
383 << sendPatchIndices[proci]
384 << sendParticles[proci];
393 bool transferred =
false;
394 forAll(receiveSizes, proci)
396 if (receiveSizes[proci])
402 reduce(transferred, orOp<bool>());
409 forAll(receiveSizes, proci)
411 if (receiveSizes[proci])
413 UIPstream particleStream(proci, pBufs);
415 const labelList receivePatchIndices(particleStream);
417 IDLList<ParticleType> newParticles(particleStream);
421 forAllIter(
typename Cloud<ParticleType>, newParticles, iter)
425 ParticleType&
p = iter();
429 p.correctAfterParallelTransfer(cloud, td);
431 addParticle(newParticles.remove(&
p));
443 if (td.patchNLocateBoundaryHits[
patchi] != 0)
446 <<
"Cloud " <<
name() <<
" did not accurately locate "
447 << td.patchNLocateBoundaryHits[
patchi]
448 <<
" particles that transferred to patch "
449 << pMesh_.boundaryMesh()[
patchi].name() <<
nl;
456 template<
class ParticleType>
464 pMesh_.tetBasePtIs();
465 pMesh_.oldCellCentres();
467 if (!globalPositionsPtr_.valid())
470 <<
"Global positions are not available. "
471 <<
"Cloud::storeGlobalPositions has not been called."
475 const vectorField& positions = globalPositionsPtr_();
482 const point&
pos = positions[particlei ++];
486 if (!iter().locate(pMesh_,
pos, celli))
497 <<
"Topology change of cloud " << this->
name()
498 <<
" lost " << lostCount <<
" particles" <<
endl;
503 template<
class ParticleType>
509 pMesh_.tetBasePtIs();
510 pMesh_.oldCellCentres();
513 patchNbrProc_ = patchNbrProc(pMesh_);
514 patchNbrProcPatch_ = patchNbrProcPatch(pMesh_);
515 patchNonConformalCyclicPatches_ = patchNonConformalCyclicPatches(pMesh_);
517 if (!globalPositionsPtr_.valid())
520 <<
"Global positions are not available. "
521 <<
"Cloud::storeGlobalPositions has not been called."
525 const vectorField& positions = globalPositionsPtr_();
538 const point&
pos = positions[particlei ++];
540 const remote tgtProcCell =
545 if (tgtProcCell ==
remote())
552 if (!iter().locate(pMesh_,
pos, celli))
560 sendCellIndices[proci].
append(celli);
562 sendParticles[proci].
append(this->remove(iter));
575 forAll(sendParticles, proci)
577 if (sendParticles[proci].size())
582 << sendCellIndices[proci]
583 << sendPositions[proci]
584 << sendParticles[proci];
593 forAll(sendParticles, proci)
595 if (receiveSizes[proci])
599 const labelList receiveCellIndices(particleStream);
600 const List<point> receivePositions(particleStream);
606 const label celli = receiveCellIndices[particlei];
607 const vector&
pos = receivePositions[particlei ++];
609 if (iter().locate(pMesh_,
pos, celli))
611 this->append(receiveParticles.
remove(iter));
615 receiveParticles.
remove(iter);
627 <<
"Mesh-to-mesh mapping of cloud " << this->
name()
628 <<
" lost " << lostCount <<
" particles" <<
endl;
633 template<
class ParticleType>
639 pMesh_.tetBasePtIs();
640 pMesh_.oldCellCentres();
643 patchNbrProc_ = patchNbrProc(pMesh_);
644 patchNbrProcPatch_ = patchNbrProcPatch(pMesh_);
645 patchNonConformalCyclicPatches_ = patchNonConformalCyclicPatches(pMesh_);
647 if (!globalPositionsPtr_.valid())
650 <<
"Global positions are not available. "
651 <<
"Cloud::storeGlobalPositions has not been called."
655 const vectorField& positions = globalPositionsPtr_();
663 cellParticleis[iter().cell()] ++;
665 forAll(cellParticlePositions, celli)
667 cellParticlePositions[celli].
resize(cellParticleis[celli]);
674 const label celli = iter().cell();
675 label& cellParticlei = cellParticleis[celli];
677 cellParticlePositions[celli][cellParticlei ++] =
678 positions[particlei ++];
690 cellParticlePositions,
700 cellParticles[iter().cell()].
append(this->remove(iter));
720 forAll(cellParticles, celli)
722 label cellParticlei = 0;
725 const point&
pos = cellParticlePositions[celli][cellParticlei++];
727 if (iter().locate(pMesh_,
pos, celli))
729 this->append(cellParticles[celli].remove(iter));
733 cellParticles[celli].remove(iter);
743 <<
"Distribution of cloud " << this->
name()
744 <<
" lost " << lostCount <<
" particles" <<
endl;
749 template<
class ParticleType>
754 this->db().time().path()/this->
name() +
"_positions.obj"
759 const point pos = pIter().position(pMesh_);
761 pObj<<
"v " <<
pos.x() <<
" " <<
pos.y() <<
" " <<
pos.z() <<
nl;
768 template<
class ParticleType>
776 globalPositionsPtr_.reset(
new vectorField(this->size()));
783 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.
static void listCombineGather(const List< commsStruct > &comms, List< T > &Value, const CombineOp &cop, const int tag, const label comm)
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 bool master(const label communicator=0)
Am I the master process.
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.
virtual void resetCpuTime()
Reset the CPU time (dummy)
virtual void cpuTimeIncrement(const label celli)
Cache the CPU time increment for celli (dummy)
static optionalCpuLoad & New(const word &name, const polyMesh &mesh, const bool loadBalancing)
Construct from polyMesh if loadBalancing is true.
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"))