ENH: regionSplit: make MeshObject

This commit is contained in:
mattijs
2012-10-05 11:11:54 +01:00
parent 7f8b070c6b
commit 8cba140e17
2 changed files with 30 additions and 29 deletions

View File

@ -69,7 +69,7 @@ void Foam::regionSplit::transferCoupledFaceRegion
"regionSplit::transferCoupledFaceRegion" "regionSplit::transferCoupledFaceRegion"
"(const label, const label, labelList&, labelList&) const" "(const label, const label, labelList&, labelList&) const"
) << "Problem : coupled face " << faceI ) << "Problem : coupled face " << faceI
<< " on patch " << mesh_.boundaryMesh().whichPatch(faceI) << " on patch " << mesh().boundaryMesh().whichPatch(faceI)
<< " has region " << faceRegion[faceI] << " has region " << faceRegion[faceI]
<< " but coupled face " << otherFaceI << " but coupled face " << otherFaceI
<< " has region " << faceRegion[otherFaceI] << " has region " << faceRegion[otherFaceI]
@ -109,7 +109,7 @@ void Foam::regionSplit::fillSeedMask
// Collect faces on seed cell // Collect faces on seed cell
const cell& cFaces = mesh_.cells()[seedCellID]; const cell& cFaces = mesh().cells()[seedCellID];
label nFaces = 0; label nFaces = 0;
@ -144,7 +144,7 @@ void Foam::regionSplit::fillSeedMask
{ {
label faceI = changedFaces[i]; label faceI = changedFaces[i];
label own = mesh_.faceOwner()[faceI]; label own = mesh().faceOwner()[faceI];
if (cellRegion[own] == -1) if (cellRegion[own] == -1)
{ {
@ -152,9 +152,9 @@ void Foam::regionSplit::fillSeedMask
changedCells.append(own); changedCells.append(own);
} }
if (mesh_.isInternalFace(faceI)) if (mesh().isInternalFace(faceI))
{ {
label nei = mesh_.faceNeighbour()[faceI]; label nei = mesh().faceNeighbour()[faceI];
if (cellRegion[nei] == -1) if (cellRegion[nei] == -1)
{ {
@ -178,7 +178,7 @@ void Foam::regionSplit::fillSeedMask
{ {
label cellI = changedCells[i]; label cellI = changedCells[i];
const cell& cFaces = mesh_.cells()[cellI]; const cell& cFaces = mesh().cells()[cellI];
forAll(cFaces, cFaceI) forAll(cFaces, cFaceI)
{ {
@ -203,7 +203,7 @@ void Foam::regionSplit::fillSeedMask
// Check for changes to any locally coupled face. // Check for changes to any locally coupled face.
// Global connections are done later. // Global connections are done later.
const polyBoundaryMesh& patches = mesh_.boundaryMesh(); const polyBoundaryMesh& patches = mesh().boundaryMesh();
forAll(patches, patchI) forAll(patches, patchI)
{ {
@ -274,7 +274,7 @@ Foam::label Foam::regionSplit::calcLocalRegionSplit
{ {
// Check that blockedFace is synced. // Check that blockedFace is synced.
boolList syncBlockedFace(blockedFace); boolList syncBlockedFace(blockedFace);
syncTools::swapFaceList(mesh_, syncBlockedFace); syncTools::swapFaceList(mesh(), syncBlockedFace);
forAll(syncBlockedFace, faceI) forAll(syncBlockedFace, faceI)
{ {
@ -295,7 +295,7 @@ Foam::label Foam::regionSplit::calcLocalRegionSplit
// Region per face. // Region per face.
// -1 unassigned // -1 unassigned
// -2 blocked // -2 blocked
labelList faceRegion(mesh_.nFaces(), -1); labelList faceRegion(mesh().nFaces(), -1);
if (blockedFace.size()) if (blockedFace.size())
{ {
@ -321,7 +321,7 @@ Foam::label Foam::regionSplit::calcLocalRegionSplit
{ {
// Find first unset cell // Find first unset cell
for (; unsetCellI < mesh_.nCells(); unsetCellI++) for (; unsetCellI < mesh().nCells(); unsetCellI++)
{ {
if (cellRegion[unsetCellI] == -1) if (cellRegion[unsetCellI] == -1)
{ {
@ -329,7 +329,7 @@ Foam::label Foam::regionSplit::calcLocalRegionSplit
} }
} }
if (unsetCellI >= mesh_.nCells()) if (unsetCellI >= mesh().nCells())
{ {
break; break;
} }
@ -430,9 +430,9 @@ Foam::autoPtr<Foam::globalIndex> Foam::regionSplit::calcRegionSplit
} }
const polyBoundaryMesh& patches = mesh_.boundaryMesh(); const polyBoundaryMesh& patches = mesh().boundaryMesh();
labelList nbrRegion(mesh_.nFaces()-mesh_.nInternalFaces(), -1); labelList nbrRegion(mesh().nFaces()-mesh().nInternalFaces(), -1);
forAll(patches, patchI) forAll(patches, patchI)
{ {
const polyPatch& pp = patches[patchI]; const polyPatch& pp = patches[patchI];
@ -444,7 +444,7 @@ Foam::autoPtr<Foam::globalIndex> Foam::regionSplit::calcRegionSplit
( (
nbrRegion, nbrRegion,
pp.size(), pp.size(),
pp.start()-mesh_.nInternalFaces() pp.start()-mesh().nInternalFaces()
); );
forAll(patchCells, i) forAll(patchCells, i)
@ -457,9 +457,9 @@ Foam::autoPtr<Foam::globalIndex> Foam::regionSplit::calcRegionSplit
} }
} }
} }
syncTools::swapBoundaryFaceList(mesh_, nbrRegion); syncTools::swapBoundaryFaceList(mesh(), nbrRegion);
Map<label> globalToMerged(mesh_.nFaces()-mesh_.nInternalFaces()); Map<label> globalToMerged(mesh().nFaces()-mesh().nInternalFaces());
forAll(patches, patchI) forAll(patches, patchI)
{ {
@ -472,7 +472,7 @@ Foam::autoPtr<Foam::globalIndex> Foam::regionSplit::calcRegionSplit
( (
nbrRegion, nbrRegion,
pp.size(), pp.size(),
pp.start()-mesh_.nInternalFaces() pp.start()-mesh().nInternalFaces()
); );
forAll(patchCells, i) forAll(patchCells, i)
@ -486,7 +486,7 @@ Foam::autoPtr<Foam::globalIndex> Foam::regionSplit::calcRegionSplit
//Pout<< "on patch:" << pp.name() //Pout<< "on patch:" << pp.name()
// << " cell:" << patchCells[i] // << " cell:" << patchCells[i]
// << " at:" // << " at:"
// << mesh_.cellCentres()[patchCells[i]] // << mesh().cellCentres()[patchCells[i]]
// << " was:" << cellRegion[patchCells[i]] // << " was:" << cellRegion[patchCells[i]]
// << " nbr:" << patchNbrRegion[i] // << " nbr:" << patchNbrRegion[i]
// << endl; // << endl;
@ -534,7 +534,7 @@ Foam::autoPtr<Foam::globalIndex> Foam::regionSplit::calcRegionSplit
// 4a: count. Use a labelHashSet to count regions only once. // 4a: count. Use a labelHashSet to count regions only once.
label nCompact = 0; label nCompact = 0;
{ {
labelHashSet localRegion(mesh_.nFaces()-mesh_.nInternalFaces()); labelHashSet localRegion(mesh().nFaces()-mesh().nInternalFaces());
forAll(cellRegion, cellI) forAll(cellRegion, cellI)
{ {
if if
@ -692,8 +692,8 @@ Foam::autoPtr<Foam::globalIndex> Foam::regionSplit::calcRegionSplit
Foam::regionSplit::regionSplit(const polyMesh& mesh) Foam::regionSplit::regionSplit(const polyMesh& mesh)
: :
labelList(mesh.nCells(), -1), MeshObject<polyMesh, regionSplit>(mesh),
mesh_(mesh) labelList(mesh.nCells(), -1)
{ {
globalNumberingPtr_ = calcRegionSplit globalNumberingPtr_ = calcRegionSplit
( (
@ -710,8 +710,8 @@ Foam::regionSplit::regionSplit
const boolList& blockedFace const boolList& blockedFace
) )
: :
labelList(mesh.nCells(), -1), MeshObject<polyMesh, regionSplit>(mesh),
mesh_(mesh) labelList(mesh.nCells(), -1)
{ {
globalNumberingPtr_ = calcRegionSplit globalNumberingPtr_ = calcRegionSplit
( (
@ -729,8 +729,8 @@ Foam::regionSplit::regionSplit
const List<labelPair>& explicitConnections const List<labelPair>& explicitConnections
) )
: :
labelList(mesh.nCells(), -1), MeshObject<polyMesh, regionSplit>(mesh),
mesh_(mesh) labelList(mesh.nCells(), -1)
{ {
globalNumberingPtr_ = calcRegionSplit globalNumberingPtr_ = calcRegionSplit
( (

View File

@ -98,6 +98,7 @@ SourceFiles
#include "globalIndex.H" #include "globalIndex.H"
#include "labelPair.H" #include "labelPair.H"
#include "boolList.H" #include "boolList.H"
#include "MeshObject.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -112,13 +113,11 @@ class polyMesh;
class regionSplit class regionSplit
: :
public MeshObject<polyMesh, regionSplit>,
public labelList public labelList
{ {
// Private data // Private data
//- Reference to mesh
const polyMesh& mesh_;
mutable autoPtr<globalIndex> globalNumberingPtr_; mutable autoPtr<globalIndex> globalNumberingPtr_;
@ -161,11 +160,13 @@ class regionSplit
labelList& cellRegion labelList& cellRegion
) const; ) const;
public: public:
//- Runtime type information //- Runtime type information
ClassName("regionSplit"); ClassName("regionSplit");
// Constructors // Constructors
//- Construct from mesh //- Construct from mesh
@ -185,6 +186,7 @@ public:
const List<labelPair>& const List<labelPair>&
); );
// Member Functions // Member Functions
//- Return global region numbering //- Return global region numbering
@ -198,7 +200,6 @@ public:
{ {
return globalNumbering().size(); return globalNumbering().size();
} }
}; };