BUG: trackedParticle: avoid walking back to processor interface

This commit is contained in:
mattijs
2014-04-22 12:08:20 +01:00
committed by Andrew Heather
parent b5d50b94e7
commit d4ab5953ca
3 changed files with 100 additions and 31 deletions

View File

@ -39,6 +39,7 @@ License
//#include "globalIndex.H" //#include "globalIndex.H"
#include "OBJstream.H" #include "OBJstream.H"
#include "cellSet.H" #include "cellSet.H"
#include "treeDataCell.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -353,7 +354,14 @@ void Foam::meshRefinement::markFeatureCellLevel
label tetFaceI = -1; label tetFaceI = -1;
label tetPtI = -1; label tetPtI = -1;
mesh_.findCellFacePt(keepPoint, cellI, tetFaceI, tetPtI);
// Force construction of search tree even if processor holds no
// cells
(void)mesh_.cellTree();
if (mesh_.nCells())
{
mesh_.findCellFacePt(keepPoint, cellI, tetFaceI, tetPtI);
}
if (cellI != -1) if (cellI != -1)
{ {
@ -402,7 +410,8 @@ void Foam::meshRefinement::markFeatureCellLevel
featureMesh.points()[pointI], // endpos featureMesh.points()[pointI], // endpos
featureLevel, // level featureLevel, // level
featI, // featureMesh featI, // featureMesh
pointI // end point pointI, // end point
-1 // feature edge
) )
); );
@ -446,7 +455,8 @@ void Foam::meshRefinement::markFeatureCellLevel
featureMesh.points()[pointI], // endpos featureMesh.points()[pointI], // endpos
featureLevel, // level featureLevel, // level
featI, // featureMesh featI, // featureMesh
pointI // end point pointI, // end point
-1 // feature edge
) )
); );
} }
@ -459,8 +469,22 @@ void Foam::meshRefinement::markFeatureCellLevel
// Largest refinement level of any feature passed through // Largest refinement level of any feature passed through
maxFeatureLevel = labelList(mesh_.nCells(), -1); maxFeatureLevel = labelList(mesh_.nCells(), -1);
// Whether edge has been visited.
List<PackedBoolList> featureEdgeVisited(features_.size());
forAll(features_, featI)
{
featureEdgeVisited[featI].setSize(features_[featI].edges().size());
featureEdgeVisited[featI] = 0u;
}
// Database to pass into trackedParticle::move // Database to pass into trackedParticle::move
trackedParticle::trackingData td(startPointCloud, maxFeatureLevel); trackedParticle::trackingData td
(
startPointCloud,
maxFeatureLevel,
featureEdgeVisited
);
// Track all particles to their end position (= starting feature point) // Track all particles to their end position (= starting feature point)
@ -477,15 +501,10 @@ void Foam::meshRefinement::markFeatureCellLevel
startPointCloud.move(td, maxTrackLen); startPointCloud.move(td, maxTrackLen);
// Reset level // Reset levels
maxFeatureLevel = -1; maxFeatureLevel = -1;
// Whether edge has been visited.
List<PackedBoolList> featureEdgeVisited(features_.size());
forAll(features_, featI) forAll(features_, featI)
{ {
featureEdgeVisited[featI].setSize(features_[featI].edges().size());
featureEdgeVisited[featI] = 0u; featureEdgeVisited[featI] = 0u;
} }
@ -528,6 +547,7 @@ void Foam::meshRefinement::markFeatureCellLevel
trackedParticle* tp(new trackedParticle(startTp)); trackedParticle* tp(new trackedParticle(startTp));
tp->end() = featureMesh.points()[otherPointI]; tp->end() = featureMesh.points()[otherPointI];
tp->j() = otherPointI; tp->j() = otherPointI;
tp->k() = edgeI;
if (debug&meshRefinement::FEATURESEEDS) if (debug&meshRefinement::FEATURESEEDS)
{ {
@ -587,6 +607,7 @@ void Foam::meshRefinement::markFeatureCellLevel
tp.end() = featureMesh.points()[otherPointI]; tp.end() = featureMesh.points()[otherPointI];
tp.j() = otherPointI; tp.j() = otherPointI;
tp.k() = edgeI;
keepParticle = true; keepParticle = true;
break; break;
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -25,6 +25,7 @@ License
#include "trackedParticle.H" #include "trackedParticle.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::trackedParticle::trackedParticle Foam::trackedParticle::trackedParticle
@ -37,14 +38,16 @@ Foam::trackedParticle::trackedParticle
const point& end, const point& end,
const label level, const label level,
const label i, const label i,
const label j const label j,
const label k
) )
: :
particle(mesh, position, cellI, tetFaceI, tetPtI), particle(mesh, position, cellI, tetFaceI, tetPtI),
end_(end), end_(end),
level_(level), level_(level),
i_(i), i_(i),
j_(j) j_(j),
k_(k)
{} {}
@ -65,13 +68,15 @@ Foam::trackedParticle::trackedParticle
level_ = readLabel(is); level_ = readLabel(is);
i_ = readLabel(is); i_ = readLabel(is);
j_ = readLabel(is); j_ = readLabel(is);
k_ = readLabel(is);
} }
else else
{ {
is.read is.read
( (
reinterpret_cast<char*>(&end_), reinterpret_cast<char*>(&end_),
sizeof(end_) + sizeof(level_) + sizeof(i_) + sizeof(j_) sizeof(end_) + sizeof(level_)
+ sizeof(i_) + sizeof(j_) + sizeof(k_)
); );
} }
} }
@ -113,7 +118,7 @@ bool Foam::trackedParticle::move
scalar dt = min(dtMax, tEnd); scalar dt = min(dtMax, tEnd);
// mark visited cell with max level. // mark visited cell with max level.
td.maxLevel()[cell()] = max(td.maxLevel()[cell()], level_); td.maxLevel_[cell()] = max(td.maxLevel_[cell()], level_);
dt *= trackToFace(end_, td); dt *= trackToFace(end_, td);
@ -217,6 +222,26 @@ void Foam::trackedParticle::hitPatch
} }
void Foam::trackedParticle::correctAfterParallelTransfer
(
const label patchI,
trackingData& td
)
{
particle::correctAfterParallelTransfer(patchI, td);
label edgeI = k();
if (edgeI != -1)
{
label featI = i();
// Mark edge we're currently on (was set on sending processor but not
// receiving sender)
td.featureEdgeVisited_[featI].set(edgeI, 1u);
}
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
Foam::Ostream& Foam::operator<<(Ostream& os, const trackedParticle& p) Foam::Ostream& Foam::operator<<(Ostream& os, const trackedParticle& p)
@ -227,7 +252,8 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const trackedParticle& p)
<< token::SPACE << p.end_ << token::SPACE << p.end_
<< token::SPACE << p.level_ << token::SPACE << p.level_
<< token::SPACE << p.i_ << token::SPACE << p.i_
<< token::SPACE << p.j_; << token::SPACE << p.j_
<< token::SPACE << p.k_;
} }
else else
{ {
@ -235,7 +261,8 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const trackedParticle& p)
os.write os.write
( (
reinterpret_cast<const char*>(&p.end_), reinterpret_cast<const char*>(&p.end_),
sizeof(p.end_) + sizeof(p.level_) + sizeof(p.i_) + sizeof(p.j_) sizeof(p.end_) + sizeof(p.level_)
+ sizeof(p.i_) + sizeof(p.j_) + sizeof(p.k_)
); );
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -62,12 +62,15 @@ class trackedParticle
//- level of this particle //- level of this particle
label level_; label level_;
//- passive label //- passive label (used to store feature edge mesh)
label i_; label i_;
//- passive label //- passive label (used to store feature edge point)
label j_; label j_;
//- passive label (used to store feature edge label)
label k_;
public: public:
@ -78,26 +81,27 @@ public:
: :
public particle::TrackingData<Cloud<trackedParticle> > public particle::TrackingData<Cloud<trackedParticle> >
{ {
public:
labelList& maxLevel_; labelList& maxLevel_;
public: List<PackedBoolList>& featureEdgeVisited_;
// Constructors // Constructors
trackingData(Cloud<trackedParticle>& cloud, labelList& maxLevel) trackingData
(
Cloud<trackedParticle>& cloud,
labelList& maxLevel,
List<PackedBoolList>& featureEdgeVisited
)
: :
particle::TrackingData<Cloud<trackedParticle> >(cloud), particle::TrackingData<Cloud<trackedParticle> >(cloud),
maxLevel_(maxLevel) maxLevel_(maxLevel),
featureEdgeVisited_(featureEdgeVisited)
{} {}
// Member functions
labelList& maxLevel()
{
return maxLevel_;
}
}; };
@ -115,7 +119,8 @@ public:
const point& end, const point& end,
const label level, const label level,
const label i, const label i,
const label j const label j,
const label k
); );
//- Construct from Istream //- Construct from Istream
@ -187,6 +192,18 @@ public:
return j_; return j_;
} }
//- transported label
label k() const
{
return k_;
}
//- transported label
label& k()
{
return k_;
}
// Tracking // Tracking
@ -259,6 +276,10 @@ public:
trackingData& td trackingData& td
); );
//- Convert processor patch addressing to the global equivalents
// and set the cellI to the face-neighbour
void correctAfterParallelTransfer(const label, trackingData&);
// Ostream Operator // Ostream Operator