functionObjects: nearWallFields: Fixed failed patch faces
Corrected a few issues with the utilisation of the tracking within the nearWallFields function object. The tracking is now done over a displacement from the initial location, which prevents trying to track to a location outside the mesh when the patch face is warped and the centre lies outside the tracking decomposition. Also fixed the end criteria so that it does not suffer from round off error in the step fraction. The upshot of these changes is that the faces on which the near wall cells were not being set are now being set properly, and uninitialised data is no longer being written out.
This commit is contained in:
@ -34,13 +34,12 @@ Foam::findCellParticle::findCellParticle
|
||||
const label celli,
|
||||
const label tetFacei,
|
||||
const label tetPtI,
|
||||
const point& end,
|
||||
const vector& displacement,
|
||||
const label data
|
||||
)
|
||||
:
|
||||
particle(mesh, coordinates, celli, tetFacei, tetPtI),
|
||||
start_(position()),
|
||||
end_(end),
|
||||
displacement_(displacement),
|
||||
data_(data)
|
||||
{}
|
||||
|
||||
@ -50,13 +49,12 @@ Foam::findCellParticle::findCellParticle
|
||||
const polyMesh& mesh,
|
||||
const vector& position,
|
||||
const label celli,
|
||||
const point& end,
|
||||
const vector& displacement,
|
||||
const label data
|
||||
)
|
||||
:
|
||||
particle(mesh, position, celli),
|
||||
start_(this->position()),
|
||||
end_(end),
|
||||
displacement_(displacement),
|
||||
data_(data)
|
||||
{}
|
||||
|
||||
@ -74,15 +72,15 @@ Foam::findCellParticle::findCellParticle
|
||||
{
|
||||
if (is.format() == IOstream::ASCII)
|
||||
{
|
||||
is >> start_ >> end_;
|
||||
is >> displacement_;
|
||||
data_ = readLabel(is);
|
||||
}
|
||||
else
|
||||
{
|
||||
is.read
|
||||
(
|
||||
reinterpret_cast<char*>(&start_),
|
||||
sizeof(start_) + sizeof(end_) + sizeof(data_)
|
||||
reinterpret_cast<char*>(&displacement_),
|
||||
sizeof(displacement_) + sizeof(data_)
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -111,10 +109,10 @@ bool Foam::findCellParticle::move
|
||||
while (td.keepParticle && !td.switchProcessor && stepFraction() < 1)
|
||||
{
|
||||
const scalar f = 1 - stepFraction();
|
||||
trackToAndHitFace(f*(end_ - start_), f, cloud, td);
|
||||
trackToAndHitFace(f*displacement_, f, cloud, td);
|
||||
}
|
||||
|
||||
if (stepFraction() == 1 || !td.keepParticle)
|
||||
if (!td.switchProcessor)
|
||||
{
|
||||
// Hit endpoint or patch. If patch hit could do fancy stuff but just
|
||||
// to use the patch point is good enough for now.
|
||||
@ -229,8 +227,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const findCellParticle& p)
|
||||
if (os.format() == IOstream::ASCII)
|
||||
{
|
||||
os << static_cast<const particle&>(p)
|
||||
<< token::SPACE << p.start_
|
||||
<< token::SPACE << p.end_
|
||||
<< token::SPACE << p.displacement_
|
||||
<< token::SPACE << p.data_;
|
||||
}
|
||||
else
|
||||
@ -238,8 +235,8 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const findCellParticle& p)
|
||||
os << static_cast<const particle&>(p);
|
||||
os.write
|
||||
(
|
||||
reinterpret_cast<const char*>(&p.start_),
|
||||
sizeof(p.start_) + sizeof(p.end_) + sizeof(p.data_)
|
||||
reinterpret_cast<const char*>(&p.displacement_),
|
||||
sizeof(p.displacement_) + sizeof(p.data_)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -63,11 +63,8 @@ class findCellParticle
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Start point to track from
|
||||
point start_;
|
||||
|
||||
//- End point to track to
|
||||
point end_;
|
||||
//- Displacement over which to track
|
||||
vector displacement_;
|
||||
|
||||
//- Passive data
|
||||
label data_;
|
||||
@ -126,7 +123,7 @@ public:
|
||||
const label celli,
|
||||
const label tetFacei,
|
||||
const label tetPtI,
|
||||
const point& end,
|
||||
const vector& displacement,
|
||||
const label data
|
||||
);
|
||||
|
||||
@ -137,7 +134,7 @@ public:
|
||||
const polyMesh& mesh,
|
||||
const vector& position,
|
||||
const label celli,
|
||||
const point& end,
|
||||
const vector& displacement,
|
||||
const label data
|
||||
);
|
||||
|
||||
@ -180,28 +177,16 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Point to track from
|
||||
const point& start() const
|
||||
//- Displacement over which to track
|
||||
const vector& displacement() const
|
||||
{
|
||||
return start_;
|
||||
return displacement_;
|
||||
}
|
||||
|
||||
//- Point to track from
|
||||
point& start()
|
||||
//- Displacement over which to track
|
||||
vector& displacement()
|
||||
{
|
||||
return start_;
|
||||
}
|
||||
|
||||
//- Point to track to
|
||||
const point& end() const
|
||||
{
|
||||
return end_;
|
||||
}
|
||||
|
||||
//- Point to track to
|
||||
point& end()
|
||||
{
|
||||
return end_;
|
||||
return displacement_;
|
||||
}
|
||||
|
||||
//- Transported label
|
||||
|
||||
@ -79,17 +79,14 @@ void Foam::functionObjects::nearWallFields::calcAddressing()
|
||||
|
||||
forAll(patch, patchFacei)
|
||||
{
|
||||
const point& start = patch.Cf()[patchFacei];
|
||||
const point end = start - distance_*nf[patchFacei];
|
||||
|
||||
cloud.addParticle
|
||||
(
|
||||
new findCellParticle
|
||||
(
|
||||
mesh_,
|
||||
start,
|
||||
patch.Cf()[patchFacei],
|
||||
patch.faceCells()[patchFacei],
|
||||
end,
|
||||
- distance_*nf[patchFacei],
|
||||
globalWalls.toGlobal(nPatchFaces) // passive data
|
||||
)
|
||||
);
|
||||
@ -112,8 +109,8 @@ void Foam::functionObjects::nearWallFields::calcAddressing()
|
||||
|
||||
forAllConstIter(Cloud<findCellParticle>, cloud, iter)
|
||||
{
|
||||
const findCellParticle& tp = iter();
|
||||
str.write(linePointRef(tp.position(), tp.end()));
|
||||
const vector p = iter().position();
|
||||
str.write(linePointRef(p, p + iter().displacement()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user