55 x.append(
new Type(iter()));
66 template<
class ParticleType>
72 const polyBoundaryMesh& pbm = pMesh.boundary();
76 if (Pstream::parRun())
80 if (isA<processorPolyPatch>(pbm[
patchi]))
82 const processorPolyPatch& ppp =
83 refCast<const processorPolyPatch>(pbm[
patchi]);
85 result[
patchi] = ppp.neighbProcNo();
94 template<
class ParticleType>
100 const polyBoundaryMesh& pbm = pMesh.boundary();
104 if (Pstream::parRun())
106 PstreamBuffers pBufs(Pstream::commsTypes::nonBlocking);
110 if (isA<processorPolyPatch>(pbm[
patchi]))
112 const processorPolyPatch& ppp =
113 refCast<const processorPolyPatch>(pbm[
patchi]);
115 UOPstream(ppp.neighbProcNo(), pBufs)()
124 if (isA<processorPolyPatch>(pbm[
patchi]))
126 const processorPolyPatch& ppp =
127 refCast<const processorPolyPatch>(pbm[
patchi]);
129 UIPstream(ppp.neighbProcNo(), pBufs)()
139 template<
class ParticleType>
143 const polyMesh& pMesh
152 if (isA<nonConformalCyclicPolyPatch>(pbm[
patchi]))
155 refCast<const nonConformalCyclicPolyPatch>(pbm[
patchi]);
165 template<
class ParticleType>
174 const label nccPatchi =
175 patchNonConformalCyclicPatches_[
patchi][i];
178 refCast<const nonConformalCyclicPolyPatch>(pbm[nccPatchi]);
188 template<
class ParticleType>
199 patchNbrProc_(patchNbrProc(pMesh)),
200 patchNbrProcPatch_(patchNbrProcPatch(pMesh)),
201 patchNonConformalCyclicPatches_(patchNonConformalCyclicPatches(pMesh)),
202 globalPositionsPtr_(),
212 if (!ParticleType::instantaneous)
217 if (particles.size())
226 template<
class ParticleType>
233 template<
class ParticleType>
236 delete(this->remove(&
p));
240 template<
class ParticleType>
247 if (pIter().
cell() == -1)
249 deleteParticle(pIter());
259 <<
" deleted " << lostCount <<
" lost particles" <<
endl;
264 template<
class ParticleType>
272 ParticleType::particleCount = 0;
277 template<
class ParticleType>
285 timeIndex_ = pMesh_.time().timeIndex();
289 template<
class ParticleType>
290 template<
class TrackCloudType>
293 TrackCloudType&
cloud,
294 typename ParticleType::trackingData& td
298 if (!ParticleType::instantaneous && timeIndex_ != pMesh_.time().timeIndex())
304 globalPositionsPtr_.clear();
325 forAll(sendParticles, proci)
327 sendParticles[proci].
clear();
339 ParticleType&
p = pIter();
342 const bool keepParticle =
p.move(
cloud, td);
352 if (td.sendToProc != -1)
358 <<
"Switch processor flag is true when no parallel "
359 <<
"transfer is possible. This is a bug."
364 p.prepareForParallelTransfer(cloud, td);
366 sendParticles[td.sendToProc].
append(this->remove(&
p));
368 sendPatchIndices[td.sendToProc].
append(td.sendToPatch);
387 forAll(sendParticles, proci)
389 if (sendParticles[proci].size())
391 UOPstream particleStream(proci, pBufs);
394 << sendPatchIndices[proci]
395 << sendParticles[proci];
404 bool transferred =
false;
405 forAll(receiveSizes, proci)
407 if (receiveSizes[proci])
413 reduce(transferred, orOp<bool>());
420 forAll(receiveSizes, proci)
422 if (receiveSizes[proci])
424 UIPstream particleStream(proci, pBufs);
426 const labelList receivePatchIndices(particleStream);
428 IDLList<ParticleType> newParticles(particleStream);
436 ParticleType&
p = iter();
440 p.correctAfterParallelTransfer(cloud, td);
442 addParticle(newParticles.remove(&
p));
454 if (td.patchNLocateBoundaryHits[
patchi] != 0)
457 <<
"Cloud " <<
name() <<
" did not accurately locate "
458 << td.patchNLocateBoundaryHits[
patchi]
459 <<
" particles that transferred to patch "
460 << pMesh_.boundary()[
patchi].name() <<
nl;
467 template<
class ParticleType>
476 pMesh_.tetBasePtIs();
477 pMesh_.oldCellCentres();
479 if (!globalPositionsPtr_.valid())
482 <<
"Global positions are not available. "
483 <<
"Cloud::storeGlobalPositions has not been called."
487 const vectorField& positions = globalPositionsPtr_();
496 const point&
pos = positions[particlei ++];
500 if (!iter().
locate(searchEngine,
pos, celli))
511 <<
"Topology change of cloud " << this->
name()
512 <<
" lost " << lostCount <<
" particles" <<
endl;
517 template<
class ParticleType>
521 pMesh_.tetBasePtIs();
522 pMesh_.oldCellCentres();
525 patchNbrProc_ = patchNbrProc(pMesh_);
526 patchNbrProcPatch_ = patchNbrProcPatch(pMesh_);
527 patchNonConformalCyclicPatches_ = patchNonConformalCyclicPatches(pMesh_);
529 if (!globalPositionsPtr_.valid())
532 <<
"Global positions are not available. "
533 <<
"Cloud::storeGlobalPositions has not been called."
537 const vectorField& positions = globalPositionsPtr_();
552 const point&
pos = positions[particlei ++];
554 const remote tgtProcCell =
559 if (tgtProcCell ==
remote())
566 if (!iter().
locate(searchEngine,
pos, celli))
574 sendCellIndices[proci].
append(celli);
576 sendParticles[proci].
append(this->remove(iter));
589 forAll(sendParticles, proci)
591 if (sendParticles[proci].size())
596 << sendCellIndices[proci]
597 << sendPositions[proci]
598 << sendParticles[proci];
607 forAll(sendParticles, proci)
609 if (receiveSizes[proci])
613 const labelList receiveCellIndices(particleStream);
614 const List<point> receivePositions(particleStream);
620 const label celli = receiveCellIndices[particlei];
621 const vector&
pos = receivePositions[particlei ++];
623 if (iter().
locate(searchEngine,
pos, celli))
625 this->append(receiveParticles.
remove(iter));
629 receiveParticles.
remove(iter);
641 <<
"Mesh-to-mesh mapping of cloud " << this->
name()
642 <<
" lost " << lostCount <<
" particles" <<
endl;
647 template<
class ParticleType>
654 pMesh_.tetBasePtIs();
655 pMesh_.oldCellCentres();
658 patchNbrProc_ = patchNbrProc(pMesh_);
659 patchNbrProcPatch_ = patchNbrProcPatch(pMesh_);
660 patchNonConformalCyclicPatches_ = patchNonConformalCyclicPatches(pMesh_);
662 if (!globalPositionsPtr_.valid())
665 <<
"Global positions are not available. "
666 <<
"Cloud::storeGlobalPositions has not been called."
672 const vectorField& positions = globalPositionsPtr_();
680 cellParticleis[iter().cell()] ++;
682 forAll(cellParticlePositions, celli)
684 cellParticlePositions[celli].
resize(cellParticleis[celli]);
691 const label celli = iter().cell();
692 label& cellParticlei = cellParticleis[celli];
694 cellParticlePositions[celli][cellParticlei ++] =
695 positions[particlei ++];
707 cellParticlePositions,
717 cellParticles[iter().cell()].
append(this->remove(iter));
737 forAll(cellParticles, celli)
739 label cellParticlei = 0;
742 const point&
pos = cellParticlePositions[celli][cellParticlei++];
744 if (iter().
locate(searchEngine,
pos, celli))
746 this->append(cellParticles[celli].remove(iter));
750 cellParticles[celli].remove(iter);
760 <<
"Distribution of cloud " << this->
name()
761 <<
" lost " << lostCount <<
" particles" <<
endl;
766 template<
class ParticleType>
771 this->
time().path()/this->
name() +
"_positions.obj"
776 const point pos = pIter().position(pMesh_);
778 pObj<<
"v " <<
pos.x() <<
" " <<
pos.y() <<
" " <<
pos.z() <<
nl;
785 template<
class ParticleType>
793 globalPositionsPtr_.reset(
new vectorField(this->size()));
800 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.
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.
Base class for clouds. Provides a basic evolution algorithm, models, and a database for caching deriv...
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.
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.
Mesh object that implements searches within the local cells and faces.
static const meshSearch & New(const polyMesh &mesh, const pointInCellShapes=pointInCellShapes::tets)
Lookup or construct from mesh and cell decomposition option.
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.
bool locate(const polyMesh &mesh, const point &position, barycentric &coordinates, label &celli, label &facei, label &faceTrii, const scalar stepFraction, const string &debugPrefix=NullObjectRef< string >())
Initialise the location at the given position. Returns whether or not a.
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.
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.
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
void operator()(IDLList< Type > &x, const IDLList< Type > &y) const
List operator to append one list onto another.
const word cloudName(propsDict.lookup("cloudName"))