41 template<
class ParticleType>
45 for (
const polyPatch&
pp : polyMesh_.boundaryMesh())
47 const auto* camipp = isA<cyclicAMIPolyPatch>(
pp);
49 if (camipp && camipp->owner())
51 ok = (camipp->AMI().singlePatchProc() != -1);
62 <<
"Particle tracking across AMI patches is only currently " 63 <<
"supported for cases where the AMI patches reside on a " 71 template<
class ParticleType>
83 globalPositionsPtr_(),
84 geometryType_(
cloud::geometryType::COORDINATES)
87 (void)polyMesh_.oldCellCentres();
92 (void)polyMesh_.tetBasePtIs();
103 template<
class ParticleType>
110 template<
class ParticleType>
113 delete(this->
remove(&
p));
117 template<
class ParticleType>
120 for (ParticleType&
p : *
this)
125 <<
"deleting lost particle at position " <<
p.position()
134 template<
class ParticleType>
139 ParticleType::particleCount_ = 0;
144 template<
class ParticleType>
145 template<
class TrackCloudType>
148 TrackCloudType&
cloud,
149 typename ParticleType::trackingData& td,
150 const scalar trackTime
167 for (ParticleType&
p : *
this)
173 globalPositionsPtr_.clear();
188 PstreamBuffers pBufs(Pstream::commsTypes::nonBlocking);
189 pBufs.allowClearRecv(
false);
192 PtrList<UOPstream> UOPstreamPtrs(Pstream::nProcs());
201 forAll(UOPstreamPtrs, proci)
203 auto* osptr = UOPstreamPtrs.get(proci);
211 for (ParticleType&
p : *
this)
214 const bool keepParticle =
p.move(cloud, td, trackTime);
220 if (td.switchProcessor)
226 || !
p.onBoundaryFace()
227 || procPatchNeighbours[
p.patch()] < 0
231 <<
"Switch processor flag is true when no parallel " 232 <<
"transfer is possible. This is a bug." 237 const label patchi =
p.patch();
239 const label toProci =
241 refCast<const processorPolyPatch>(
pbm[patchi])
246 auto* osptr = UOPstreamPtrs.get(toProci);
249 osptr =
new UOPstream(toProci, pBufs);
250 UOPstreamPtrs.set(toProci, osptr);
253 p.prepareForParallelTransfer();
256 (*osptr) << procPatchNeighbours[patchi] <<
p;
268 if (!Pstream::parRun())
273 pBufs.finishedNeighbourSends(neighbourProcs);
282 for (
const label proci : neighbourProcs)
284 if (pBufs.recvDataCount(proci))
286 UIPstream is(proci, pBufs);
291 label patchi = pTraits<label>(is);
292 auto* newp =
new ParticleType(polyMesh_, is);
295 patchi = procPatches[patchi];
297 (*newp).correctAfterParallelTransfer(patchi, td);
306 template<
class ParticleType>
309 if (!globalPositionsPtr_)
312 <<
"Global positions are not available. " 313 <<
"Cloud::storeGlobalPositions has not been called." 319 cellWallFacesPtr_.clear();
324 (void)polyMesh_.tetBasePtIs();
325 (void)polyMesh_.oldCellCentres();
327 const vectorField& positions = globalPositionsPtr_();
330 for (ParticleType&
p : *
this)
332 p.autoMap(positions[i], mapper);
338 template<
class ParticleType>
343 this->db().time().
path()/this->
name() +
"_positions.obj" 346 for (
const ParticleType&
p : *
this)
348 const point position(
p.position());
350 << position.x() <<
' ' 351 << position.y() <<
' ' 352 << position.z() <<
nl;
357 template<
class ParticleType>
365 globalPositionsPtr_.reset(
new vectorField(this->size()));
369 for (
const ParticleType&
p : *
this)
371 positions[i] =
p.position();
Template class for intrusive linked lists.
const polyBoundaryMesh & pbm
void cloudReset(const Cloud< ParticleType > &c)
Reset the particles.
errorManipArg< error, int > exit(error &err, const int errNo=1)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Various mesh related information for a parallel run. Upon construction, constructs all info using par...
const labelList & processorPatches() const noexcept
Return list of processor patch labels.
constexpr char nl
The newline '\n' character (0x0a)
Cloud(const polyMesh &mesh, const word &cloudName, const IDLList< ParticleType > &particles)
Construct from mesh and a list of particles.
Ostream & endl(Ostream &os)
Add newline and flush stream.
void autoMap(const mapPolyMesh &)
Remap the cells of particles corresponding to the.
#define forAll(list, i)
Loop across all elements in list.
void addParticle(ParticleType *pPtr)
Transfer particle to cloud.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
void storeGlobalPositions() const
Call this before a topology change.
const word cloudName(propsDict.get< word >("cloud"))
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
A class for handling words, derived from Foam::string.
A cloud is a registry collection of lagrangian particles.
errorManip< error > abort(error &err)
Base cloud calls templated on particle type.
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO...
OBJstream os(runTime.globalPath()/outputName)
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
void deleteLostParticles()
Remove lost particles from cloud and delete.
const labelList & processorPatchNeighbours() const noexcept
Return processorPatchIndices of the neighbours processor patches. -1 if not running parallel...
rAUs append(new volScalarField(IOobject::groupName("rAU", phase1.name()), 1.0/(U1Eqn.A()+byDt(max(phase1.residualAlpha() - alpha1, scalar(0)) *rho1))))
const labelList & procNeighbours() const
The neighbour processor connections (ascending order) associated with the local rank.
void move(TrackCloudType &cloud, typename ParticleType::trackingData &td, const scalar trackTime)
Move the particles.
vector point
Point is a vector.
#define WarningInFunction
Report a warning using Foam::Warning.
const processorTopology & topology() const noexcept
The processor to processor topology.
const dimensionedScalar c
Speed of light in a vacuum.
Field< vector > vectorField
Specialisation of Field<T> for vector.
Mesh consisting of general polyhedral cells.
void deleteParticle(ParticleType &p)
Remove particle from cloud and delete.
bool returnReduceOr(const bool value, const label comm=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
void writePositions() const
Write positions to <cloudName>_positions.obj file.
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())