particle: Removed polyMesh reference
This reference represents unnecessary storage. The mesh can be obtained from tracking data or passed to the particle evolution functions by argument. In addition, removing the mesh reference makes it possible to construct as particle from an Istream without the need for an iNew class. This simplifies stream-based transfer, and makes it possible for particles to be communicated by a polyDistributionMap.
This commit is contained in:
@ -59,14 +59,9 @@ Foam::findCellParticle::findCellParticle
|
||||
{}
|
||||
|
||||
|
||||
Foam::findCellParticle::findCellParticle
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
Istream& is,
|
||||
bool readFields
|
||||
)
|
||||
Foam::findCellParticle::findCellParticle(Istream& is, bool readFields)
|
||||
:
|
||||
particle(mesh, is, readFields)
|
||||
particle(is, readFields)
|
||||
{
|
||||
if (readFields)
|
||||
{
|
||||
@ -117,7 +112,7 @@ bool Foam::findCellParticle::move
|
||||
// Hit endpoint or patch. If patch hit could do fancy stuff but just
|
||||
// to use the patch point is good enough for now.
|
||||
td.cellToData()[cell()].append(data());
|
||||
td.cellToEnd()[cell()].append(position());
|
||||
td.cellToEnd()[cell()].append(position(td.mesh));
|
||||
}
|
||||
|
||||
return td.keepParticle;
|
||||
@ -188,7 +183,10 @@ void Foam::findCellParticle::hitProcessorPatch
|
||||
)
|
||||
{
|
||||
const processorPolyPatch& ppp =
|
||||
static_cast<const processorPolyPatch&>(mesh().boundaryMesh()[patch()]);
|
||||
static_cast<const processorPolyPatch&>
|
||||
(
|
||||
td.mesh.boundaryMesh()[patch(td.mesh)]
|
||||
);
|
||||
|
||||
if (ppp.transform().transforms())
|
||||
{
|
||||
|
||||
@ -140,12 +140,7 @@ public:
|
||||
);
|
||||
|
||||
//- Construct from Istream
|
||||
findCellParticle
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
Istream& is,
|
||||
bool readFields = true
|
||||
);
|
||||
findCellParticle(Istream& is, bool readFields = true);
|
||||
|
||||
//- Construct and return a clone
|
||||
autoPtr<particle> clone() const
|
||||
@ -153,27 +148,11 @@ public:
|
||||
return autoPtr<particle>(new findCellParticle(*this));
|
||||
}
|
||||
|
||||
//- Factory class to read-construct particles used for
|
||||
// parallel transfer
|
||||
class iNew
|
||||
//- Construct from Istream and return
|
||||
static autoPtr<findCellParticle> New(Istream& is)
|
||||
{
|
||||
const polyMesh& mesh_;
|
||||
|
||||
public:
|
||||
|
||||
iNew(const polyMesh& mesh)
|
||||
:
|
||||
mesh_(mesh)
|
||||
{}
|
||||
|
||||
autoPtr<findCellParticle> operator()(Istream& is) const
|
||||
{
|
||||
return autoPtr<findCellParticle>
|
||||
(
|
||||
new findCellParticle(mesh_, is, true)
|
||||
);
|
||||
}
|
||||
};
|
||||
return autoPtr<findCellParticle>(new findCellParticle(is));
|
||||
}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
@ -108,7 +108,7 @@ void Foam::functionObjects::nearWallFields::calcAddressing()
|
||||
|
||||
forAllConstIter(Cloud<findCellParticle>, cloud, iter)
|
||||
{
|
||||
const vector p = iter().position();
|
||||
const vector p = iter().position(mesh_);
|
||||
str.write(linePointRef(p, p + iter().displacement()));
|
||||
}
|
||||
}
|
||||
@ -135,7 +135,7 @@ void Foam::functionObjects::nearWallFields::calcAddressing()
|
||||
forAllConstIter(Cloud<findCellParticle>, cloud, iter)
|
||||
{
|
||||
const findCellParticle& tp = iter();
|
||||
start[nPatchFaces++] = tp.position();
|
||||
start[nPatchFaces++] = tp.position(mesh_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -145,14 +145,9 @@ Foam::streamlinesParticle::streamlinesParticle
|
||||
{}
|
||||
|
||||
|
||||
Foam::streamlinesParticle::streamlinesParticle
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
Istream& is,
|
||||
bool readFields
|
||||
)
|
||||
Foam::streamlinesParticle::streamlinesParticle(Istream& is, bool readFields)
|
||||
:
|
||||
particle(mesh, is, readFields)
|
||||
particle(is, readFields)
|
||||
{
|
||||
if (readFields)
|
||||
{
|
||||
@ -212,7 +207,7 @@ bool Foam::streamlinesParticle::move
|
||||
td.keepParticle = true;
|
||||
td.sendToProc = -1;
|
||||
|
||||
const scalar maxDt = mesh().bounds().mag();
|
||||
const scalar maxDt = td.mesh.bounds().mag();
|
||||
|
||||
while (td.keepParticle && td.sendToProc == -1 && lifeTime_ > 0)
|
||||
{
|
||||
@ -229,11 +224,11 @@ bool Foam::streamlinesParticle::move
|
||||
sampledPositions_.append
|
||||
(
|
||||
td.trackOutside_
|
||||
? transform_.invTransformPosition(position())
|
||||
: position()
|
||||
? transform_.invTransformPosition(position(td.mesh))
|
||||
: position(td.mesh)
|
||||
);
|
||||
sampledAges_.append(age_);
|
||||
vector U = interpolateFields(td, position(), cell(), face());
|
||||
vector U = interpolateFields(td, position(td.mesh), cell(), face());
|
||||
|
||||
if (!td.trackForward_)
|
||||
{
|
||||
@ -260,7 +255,7 @@ bool Foam::streamlinesParticle::move
|
||||
{
|
||||
// Sub-cycling. Cross the cell in nSubCycle steps.
|
||||
particle copy(*this);
|
||||
copy.trackToFace(maxDt*U, 1);
|
||||
copy.trackToFace(td.mesh, maxDt*U, 1);
|
||||
dt *= (copy.stepFraction() - stepFraction())/td.nSubCycle_;
|
||||
}
|
||||
else if (subIter == td.nSubCycle_ - 1)
|
||||
@ -289,7 +284,7 @@ bool Foam::streamlinesParticle::move
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "streamlinesParticle: Removing stagnant particle:"
|
||||
<< position() << " sampled positions:"
|
||||
<< position(td.mesh) << " sampled positions:"
|
||||
<< sampledPositions_.size() << endl;
|
||||
}
|
||||
td.keepParticle = false;
|
||||
@ -300,17 +295,17 @@ bool Foam::streamlinesParticle::move
|
||||
sampledPositions_.append
|
||||
(
|
||||
td.trackOutside_
|
||||
? transform_.invTransformPosition(position())
|
||||
: position()
|
||||
? transform_.invTransformPosition(position(td.mesh))
|
||||
: position(td.mesh)
|
||||
);
|
||||
sampledAges_.append(age_);
|
||||
interpolateFields(td, position(), cell(), face());
|
||||
interpolateFields(td, position(td.mesh), cell(), face());
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "streamlinesParticle: Removing particle:" << position()
|
||||
<< " sampled positions:" << sampledPositions_.size()
|
||||
<< endl;
|
||||
Pout<< "streamlinesParticle: Removing particle:"
|
||||
<< position(td.mesh) << " sampled positions:"
|
||||
<< sampledPositions_.size() << endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -362,7 +357,10 @@ void Foam::streamlinesParticle::hitCyclicPatch
|
||||
)
|
||||
{
|
||||
const cyclicPolyPatch& cpp =
|
||||
static_cast<const cyclicPolyPatch&>(mesh().boundaryMesh()[patch()]);
|
||||
static_cast<const cyclicPolyPatch&>
|
||||
(
|
||||
td.mesh.boundaryMesh()[patch(td.mesh)]
|
||||
);
|
||||
|
||||
// End this track
|
||||
if (!td.trackOutside_ && cpp.transform().transformsPosition())
|
||||
@ -424,7 +422,10 @@ void Foam::streamlinesParticle::hitProcessorPatch
|
||||
)
|
||||
{
|
||||
const processorPolyPatch& ppp =
|
||||
static_cast<const processorPolyPatch&>(mesh().boundaryMesh()[patch()]);
|
||||
static_cast<const processorPolyPatch&>
|
||||
(
|
||||
td.mesh.boundaryMesh()[patch(td.mesh)]
|
||||
);
|
||||
|
||||
// End this track
|
||||
if (!td.trackOutside_ && ppp.transform().transformsPosition())
|
||||
|
||||
@ -205,7 +205,7 @@ public:
|
||||
//- Construct from components
|
||||
streamlinesParticle
|
||||
(
|
||||
const polyMesh& c,
|
||||
const polyMesh& mesh,
|
||||
const vector& position,
|
||||
const label celli,
|
||||
const label lifeTime,
|
||||
@ -213,12 +213,7 @@ public:
|
||||
);
|
||||
|
||||
//- Construct from Istream
|
||||
streamlinesParticle
|
||||
(
|
||||
const polyMesh& c,
|
||||
Istream& is,
|
||||
bool readFields = true
|
||||
);
|
||||
streamlinesParticle(Istream& is, bool readFields = true);
|
||||
|
||||
//- Construct copy
|
||||
streamlinesParticle(const streamlinesParticle& p);
|
||||
@ -229,26 +224,11 @@ public:
|
||||
return autoPtr<particle>(new streamlinesParticle(*this));
|
||||
}
|
||||
|
||||
//- Factory class to read-construct particles used for parallel transfer
|
||||
class iNew
|
||||
//- Construct from Istream and return
|
||||
static autoPtr<streamlinesParticle> New(Istream& is)
|
||||
{
|
||||
const polyMesh& mesh_;
|
||||
|
||||
public:
|
||||
|
||||
iNew(const polyMesh& mesh)
|
||||
:
|
||||
mesh_(mesh)
|
||||
{}
|
||||
|
||||
autoPtr<streamlinesParticle> operator()(Istream& is) const
|
||||
{
|
||||
return autoPtr<streamlinesParticle>
|
||||
(
|
||||
new streamlinesParticle(mesh_, is, true)
|
||||
);
|
||||
}
|
||||
};
|
||||
return autoPtr<streamlinesParticle>(new streamlinesParticle(is));
|
||||
}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
Reference in New Issue
Block a user