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>
142 const polyMesh& pMesh
151 if (isA<nonConformalCyclicPolyPatch>(pbm[
patchi]))
154 refCast<const nonConformalCyclicPolyPatch>(pbm[
patchi]);
164 template<
class ParticleType>
173 const label nccPatchi =
174 patchNonConformalCyclicPatches_[
patchi][i];
177 refCast<const nonConformalCyclicPolyPatch>(pbm[nccPatchi]);
187 template<
class ParticleType>
198 patchNbrProc_(patchNbrProc(pMesh)),
199 patchNbrProcPatch_(patchNbrProcPatch(pMesh)),
200 patchNonConformalCyclicPatches_(patchNonConformalCyclicPatches(pMesh)),
201 globalPositionsPtr_(),
211 if (!ParticleType::instantaneous)
216 if (particles.size())
225 template<
class ParticleType>
232 template<
class ParticleType>
235 delete(this->remove(&
p));
239 template<
class ParticleType>
246 if (pIter().
cell() == -1)
257 <<
"Cloud " << this->
name()
258 <<
" deleted " << lostCount <<
" lost particles" <<
endl;
263 template<
class ParticleType>
271 ParticleType::particleCount = 0;
276 template<
class ParticleType>
284 timeIndex_ = pMesh_.time().timeIndex();
288 template<
class ParticleType>
289 template<
class TrackCloudType>
292 TrackCloudType&
cloud,
293 typename ParticleType::trackingData& td
297 if (!ParticleType::instantaneous && timeIndex_ != pMesh_.time().timeIndex())
303 globalPositionsPtr_.clear();
326 sendParticles[proci].
clear();
327 sendPatchIndices[proci].
clear();
338 ParticleType&
p = pIter();
341 const bool keepParticle =
p.move(
cloud, td);
351 if (td.sendToProc != -1)
357 <<
"Switch processor flag is true when no parallel "
358 <<
"transfer is possible. This is a bug."
363 p.prepareForParallelTransfer(cloud, td);
365 sendParticles[td.sendToProc].
append(this->remove(&
p));
367 sendPatchIndices[td.sendToProc].
append(td.sendToPatch);
386 forAll(sendParticles, proci)
388 if (sendParticles[proci].size())
390 UOPstream particleStream(proci, pBufs);
393 << sendPatchIndices[proci]
394 << sendParticles[proci];
403 bool transferred =
false;
404 forAll(receiveSizes, proci)
406 if (receiveSizes[proci])
412 reduce(transferred, orOp<bool>());
419 forAll(receiveSizes, proci)
421 if (receiveSizes[proci])
423 UIPstream particleStream(proci, pBufs);
425 const labelList receivePatchIndices(particleStream);
427 IDLList<ParticleType> newParticles(particleStream);
435 ParticleType&
p = iter();
439 p.correctAfterParallelTransfer(cloud, td);
441 addParticle(newParticles.remove(&
p));
453 if (td.patchNLocateBoundaryHits[
patchi] != 0)
456 <<
"Cloud " <<
name() <<
" did not accurately locate "
457 << td.patchNLocateBoundaryHits[
patchi]
458 <<
" particles that transferred to patch "
459 << pMesh_.boundaryMesh()[
patchi].name() <<
nl;
466 template<
class ParticleType>
475 pMesh_.tetBasePtIs();
476 pMesh_.oldCellCentres();
478 if (!globalPositionsPtr_.valid())
481 <<
"Global positions are not available. "
482 <<
"Cloud::storeGlobalPositions has not been called."
486 const vectorField& positions = globalPositionsPtr_();
493 const point&
pos = positions[particlei ++];
508 <<
"Topology change of cloud " << this->
name()
509 <<
" lost " << lostCount <<
" particles" <<
endl;
514 template<
class ParticleType>
518 pMesh_.tetBasePtIs();
519 pMesh_.oldCellCentres();
522 patchNbrProc_ = patchNbrProc(pMesh_);
523 patchNbrProcPatch_ = patchNbrProcPatch(pMesh_);
524 patchNonConformalCyclicPatches_ = patchNonConformalCyclicPatches(pMesh_);
526 if (!globalPositionsPtr_.valid())
529 <<
"Global positions are not available. "
530 <<
"Cloud::storeGlobalPositions has not been called."
534 const vectorField& positions = globalPositionsPtr_();
547 const point&
pos = positions[particlei ++];
549 const remote tgtProcCell =
554 if (tgtProcCell ==
remote())
569 sendCellIndices[proci].
append(celli);
571 sendParticles[proci].
append(this->remove(iter));
584 forAll(sendParticles, proci)
586 if (sendParticles[proci].size())
591 << sendCellIndices[proci]
592 << sendPositions[proci]
593 << sendParticles[proci];
602 forAll(sendParticles, proci)
604 if (receiveSizes[proci])
608 const labelList receiveCellIndices(particleStream);
609 const List<point> receivePositions(particleStream);
615 const label celli = receiveCellIndices[particlei];
616 const vector&
pos = receivePositions[particlei ++];
620 this->append(receiveParticles.
remove(iter));
624 receiveParticles.
remove(iter);
636 <<
"Mesh-to-mesh mapping of cloud " << this->
name()
637 <<
" lost " << lostCount <<
" particles" <<
endl;
642 template<
class ParticleType>
649 pMesh_.tetBasePtIs();
650 pMesh_.oldCellCentres();
653 patchNbrProc_ = patchNbrProc(pMesh_);
654 patchNbrProcPatch_ = patchNbrProcPatch(pMesh_);
655 patchNonConformalCyclicPatches_ = patchNonConformalCyclicPatches(pMesh_);
657 if (!globalPositionsPtr_.valid())
660 <<
"Global positions are not available. "
661 <<
"Cloud::storeGlobalPositions has not been called."
665 const vectorField& positions = globalPositionsPtr_();
673 cellParticleis[iter().cell()] ++;
675 forAll(cellParticlePositions, celli)
677 cellParticlePositions[celli].
resize(cellParticleis[celli]);
684 const label celli = iter().cell();
685 label& cellParticlei = cellParticleis[celli];
687 cellParticlePositions[celli][cellParticlei ++] =
688 positions[particlei ++];
700 cellParticlePositions,
710 cellParticles[iter().cell()].
append(this->remove(iter));
730 forAll(cellParticles, celli)
732 label cellParticlei = 0;
735 const point&
pos = cellParticlePositions[celli][cellParticlei++];
739 this->append(cellParticles[celli].remove(iter));
743 cellParticles[celli].remove(iter);
753 <<
"Distribution of cloud " << this->
name()
754 <<
" lost " << lostCount <<
" particles" <<
endl;
759 template<
class ParticleType>
764 this->db().time().path()/this->
name() +
"_positions.obj"
769 const point pos = pIter().position(pMesh_);
771 pObj<<
"v " <<
pos.x() <<
" " <<
pos.y() <<
" " <<
pos.z() <<
nl;
778 template<
class ParticleType>
786 globalPositionsPtr_.reset(
new vectorField(this->size()));
793 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.
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"))