diff --git a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementRefine.C b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementRefine.C index 07152200b9..ff1465dd0b 100644 --- a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementRefine.C +++ b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementRefine.C @@ -39,6 +39,7 @@ License //#include "globalIndex.H" #include "OBJstream.H" #include "cellSet.H" +#include "treeDataCell.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -353,7 +354,14 @@ void Foam::meshRefinement::markFeatureCellLevel label tetFaceI = -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) { @@ -402,7 +410,8 @@ void Foam::meshRefinement::markFeatureCellLevel featureMesh.points()[pointI], // endpos featureLevel, // level featI, // featureMesh - pointI // end point + pointI, // end point + -1 // feature edge ) ); @@ -446,7 +455,8 @@ void Foam::meshRefinement::markFeatureCellLevel featureMesh.points()[pointI], // endpos featureLevel, // level 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 maxFeatureLevel = labelList(mesh_.nCells(), -1); + // Whether edge has been visited. + List featureEdgeVisited(features_.size()); + + forAll(features_, featI) + { + featureEdgeVisited[featI].setSize(features_[featI].edges().size()); + featureEdgeVisited[featI] = 0u; + } + // 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) @@ -477,15 +501,10 @@ void Foam::meshRefinement::markFeatureCellLevel startPointCloud.move(td, maxTrackLen); - // Reset level + // Reset levels maxFeatureLevel = -1; - - // Whether edge has been visited. - List featureEdgeVisited(features_.size()); - forAll(features_, featI) { - featureEdgeVisited[featI].setSize(features_[featI].edges().size()); featureEdgeVisited[featI] = 0u; } @@ -528,6 +547,7 @@ void Foam::meshRefinement::markFeatureCellLevel trackedParticle* tp(new trackedParticle(startTp)); tp->end() = featureMesh.points()[otherPointI]; tp->j() = otherPointI; + tp->k() = edgeI; if (debug&meshRefinement::FEATURESEEDS) { @@ -587,6 +607,7 @@ void Foam::meshRefinement::markFeatureCellLevel tp.end() = featureMesh.points()[otherPointI]; tp.j() = otherPointI; + tp.k() = edgeI; keepParticle = true; break; } diff --git a/src/mesh/autoMesh/autoHexMesh/trackedParticle/trackedParticle.C b/src/mesh/autoMesh/autoHexMesh/trackedParticle/trackedParticle.C index ce713217cd..6142485218 100644 --- a/src/mesh/autoMesh/autoHexMesh/trackedParticle/trackedParticle.C +++ b/src/mesh/autoMesh/autoHexMesh/trackedParticle/trackedParticle.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -25,6 +25,7 @@ License #include "trackedParticle.H" + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::trackedParticle::trackedParticle @@ -37,14 +38,16 @@ Foam::trackedParticle::trackedParticle const point& end, const label level, const label i, - const label j + const label j, + const label k ) : particle(mesh, position, cellI, tetFaceI, tetPtI), end_(end), level_(level), i_(i), - j_(j) + j_(j), + k_(k) {} @@ -65,13 +68,15 @@ Foam::trackedParticle::trackedParticle level_ = readLabel(is); i_ = readLabel(is); j_ = readLabel(is); + k_ = readLabel(is); } else { is.read ( reinterpret_cast(&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); // 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); @@ -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 * * * * * * * * * * * * // 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.level_ << token::SPACE << p.i_ - << token::SPACE << p.j_; + << token::SPACE << p.j_ + << token::SPACE << p.k_; } else { @@ -235,7 +261,8 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const trackedParticle& p) os.write ( reinterpret_cast(&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_) ); } diff --git a/src/mesh/autoMesh/autoHexMesh/trackedParticle/trackedParticle.H b/src/mesh/autoMesh/autoHexMesh/trackedParticle/trackedParticle.H index 4500cab11d..c98a53929a 100644 --- a/src/mesh/autoMesh/autoHexMesh/trackedParticle/trackedParticle.H +++ b/src/mesh/autoMesh/autoHexMesh/trackedParticle/trackedParticle.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -62,12 +62,15 @@ class trackedParticle //- level of this particle label level_; - //- passive label + //- passive label (used to store feature edge mesh) label i_; - //- passive label + //- passive label (used to store feature edge point) label j_; + //- passive label (used to store feature edge label) + label k_; + public: @@ -78,26 +81,27 @@ public: : public particle::TrackingData > { + public: + labelList& maxLevel_; - public: + List& featureEdgeVisited_; // Constructors - trackingData(Cloud& cloud, labelList& maxLevel) + trackingData + ( + Cloud& cloud, + labelList& maxLevel, + List& featureEdgeVisited + ) : particle::TrackingData >(cloud), - maxLevel_(maxLevel) + maxLevel_(maxLevel), + featureEdgeVisited_(featureEdgeVisited) {} - - // Member functions - - labelList& maxLevel() - { - return maxLevel_; - } }; @@ -115,7 +119,8 @@ public: const point& end, const label level, const label i, - const label j + const label j, + const label k ); //- Construct from Istream @@ -187,6 +192,18 @@ public: return j_; } + //- transported label + label k() const + { + return k_; + } + + //- transported label + label& k() + { + return k_; + } + // Tracking @@ -259,6 +276,10 @@ public: 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