From cb48cefe70c07037d089221f2d67b7f34b19ef4f Mon Sep 17 00:00:00 2001 From: graham Date: Thu, 30 Jun 2011 09:44:01 +0100 Subject: [PATCH] Revert "ENH: rolling back WIP on face filtering." This reverts commit bd87fc30a45d2669057d608df279fe933e364c14. --- .../conformalVoronoiMesh.H | 4 +- .../conformalVoronoiMeshCalcDualMesh.C | 297 ++++++++++-------- .../conformalVoronoiMeshIO.C | 8 +- 3 files changed, 178 insertions(+), 131 deletions(-) diff --git a/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H b/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H index e7005d864c..7531b4cb17 100644 --- a/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H +++ b/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H @@ -67,6 +67,7 @@ SourceFiles #include "wallPolyPatch.H" #include "processorPolyPatch.H" #include "zeroGradientFvPatchFields.H" +#include "globalIndex.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -782,7 +783,8 @@ private: void indexDualVertices ( pointField& pts, - PackedBoolList& boundaryPts + PackedBoolList& boundaryPts, + const globalIndex& globalParallelPointIndices ); //- Re-index all of the the Delaunay cells diff --git a/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C b/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C index 091b096136..24637656d1 100644 --- a/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C +++ b/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C @@ -58,73 +58,90 @@ void Foam::conformalVoronoiMesh::calcDualMesh ++cit ) { - if - ( - !cit->vertex(0)->real() - || !cit->vertex(1)->real() - || !cit->vertex(2)->real() - || !cit->vertex(3)->real() - ) - { - cit->filterCount() = 100; - } - else - { cit->filterCount() = 0; - } } - for - ( - Delaunay::Finite_vertices_iterator vit = finite_vertices_begin(); - vit != finite_vertices_end(); - vit++ - ) - { - std::list cells; - incident_cells(vit, std::back_inserter(cells)); + // for + // ( + // Delaunay::Finite_cells_iterator cit = finite_cells_begin(); + // cit != finite_cells_end(); + // ++cit + // ) + // { + // if + // ( + // !cit->vertex(0)->real() + // || !cit->vertex(1)->real() + // || !cit->vertex(2)->real() + // || !cit->vertex(3)->real() + // ) + // { + // cit->filterCount() = 100; + // } + // else + // { + // cit->filterCount() = 0; + // } + // } - bool hasProcPt = false; + // for + // ( + // Delaunay::Finite_vertices_iterator vit = finite_vertices_begin(); + // vit != finite_vertices_end(); + // vit++ + // ) + // { + // std::list cells; + // incident_cells(vit, std::back_inserter(cells)); - for - ( - std::list::iterator cit=cells.begin(); - cit != cells.end(); - ++cit - ) - { - if - ( - !(*cit)->vertex(0)->real() - || !(*cit)->vertex(1)->real() - || !(*cit)->vertex(2)->real() - || !(*cit)->vertex(3)->real() - ) - { - hasProcPt = true; + // bool hasProcPt = false; - break; - } - } + // for + // ( + // std::list::iterator cit=cells.begin(); + // cit != cells.end(); + // ++cit + // ) + // { + // if + // ( + // !(*cit)->vertex(0)->real() + // || !(*cit)->vertex(1)->real() + // || !(*cit)->vertex(2)->real() + // || !(*cit)->vertex(3)->real() + // ) + // { + // hasProcPt = true; - if (hasProcPt) - { - for - ( - std::list::iterator cit=cells.begin(); - cit != cells.end(); - ++cit - ) - { - (*cit)->filterCount() = 100; - } - } - } + // break; + // } + // } + + // if (hasProcPt) + // { + // for + // ( + // std::list::iterator cit=cells.begin(); + // cit != cells.end(); + // ++cit + // ) + // { + // (*cit)->filterCount() = 100; + // } + // } + // } PackedBoolList boundaryPts(number_of_cells(), false); - indexDualVertices(points, boundaryPts); + globalIndex globalParallelPointIndices(number_of_cells()); + + indexDualVertices + ( + points, + boundaryPts, + globalParallelPointIndices + ); { // Ideally requires a no-risk face filtering to get rid of zero area @@ -182,7 +199,12 @@ void Foam::conformalVoronoiMesh::calcDualMesh // Reindexing the Delaunay cells and regenerating the // points resets the mesh to the starting condition. - indexDualVertices(points, boundaryPts); + indexDualVertices + ( + points, + boundaryPts, + globalParallelPointIndices + ); { Info<< nl << "Merging close points" << endl; @@ -1529,65 +1551,65 @@ Foam::labelHashSet Foam::conformalVoronoiMesh::checkPolyMeshQuality List patches(patchStarts.size()); - label nValidPatches = 0; - - forAll(patches, p) - { - if (patchTypes[p] == processorPolyPatch::typeName) - { - // Do not create empty processor patches - - if (patchSizes[p] > 0) - { - patches[nValidPatches] = new processorPolyPatch - ( - patchNames[p], - patchSizes[p], - patchStarts[p], - nValidPatches, - pMesh.boundaryMesh(), - Pstream::myProcNo(), - procNeighbours[p] - ); - - nValidPatches++; - } - } - else - { - patches[nValidPatches] = polyPatch::New - ( - patchTypes[p], - patchNames[p], - patchSizes[p], - patchStarts[p], - nValidPatches, - pMesh.boundaryMesh() - ).ptr(); - - nValidPatches++; - } - } - - patches.setSize(nValidPatches); - - pMesh.addPatches(patches); - - // Info<< "ADDPATCHES NOT IN PARALLEL" << endl; + // label nValidPatches = 0; // forAll(patches, p) // { - // patches[p] = new polyPatch - // ( - // patchNames[p], - // patchSizes[p], - // patchStarts[p], - // p, - // pMesh.boundaryMesh() - // ); + // if (patchTypes[p] == processorPolyPatch::typeName) + // { + // // Do not create empty processor patches + + // if (patchSizes[p] > 0) + // { + // patches[nValidPatches] = new processorPolyPatch + // ( + // patchNames[p], + // patchSizes[p], + // patchStarts[p], + // nValidPatches, + // pMesh.boundaryMesh(), + // Pstream::myProcNo(), + // procNeighbours[p] + // ); + + // nValidPatches++; + // } + // } + // else + // { + // patches[nValidPatches] = polyPatch::New + // ( + // patchTypes[p], + // patchNames[p], + // patchSizes[p], + // patchStarts[p], + // nValidPatches, + // pMesh.boundaryMesh() + // ).ptr(); + + // nValidPatches++; + // } // } - // pMesh.addPatches(patches, false); + // patches.setSize(nValidPatches); + + // pMesh.addPatches(patches); + + Info<< "ADDPATCHES NOT IN PARALLEL" << endl; + + forAll(patches, p) + { + patches[p] = new polyPatch + ( + patchNames[p], + patchSizes[p], + patchStarts[p], + p, + pMesh.boundaryMesh() + ); + } + + pMesh.addPatches(patches, false); // pMesh.overrideCellCentres(cellCentres); @@ -1785,7 +1807,8 @@ Foam::labelHashSet Foam::conformalVoronoiMesh::checkPolyMeshQuality void Foam::conformalVoronoiMesh::indexDualVertices ( pointField& pts, - PackedBoolList& boundaryPts + PackedBoolList& boundaryPts, + const globalIndex& globalParallelPointIndices ) { // Indexing Delaunay cells, which are the dual vertices @@ -1798,6 +1821,16 @@ void Foam::conformalVoronoiMesh::indexDualVertices boundaryPts = false; + OFstream tetStr + ( + runTime_.path() + /"processor_" + + name(Pstream::myProcNo()) + + "_parallelTets.obj" + ); + + label pTetI = 0; + for ( Delaunay::Finite_cells_iterator cit = finite_cells_begin(); @@ -1807,23 +1840,35 @@ void Foam::conformalVoronoiMesh::indexDualVertices { if (cit->internalOrBoundaryDualVertex()) { - cit->cellIndex() = dualVertI; + if (cit->parallelDualVertex()) + { + cit->cellIndex() = globalParallelPointIndices.toGlobal + ( + dualVertI + ); + + drawDelaunayCell(tetStr, cit, pTetI++); + } + else + { + cit->cellIndex() = dualVertI; + + if + ( + !cit->vertex(0)->internalOrBoundaryPoint() + || !cit->vertex(1)->internalOrBoundaryPoint() + || !cit->vertex(2)->internalOrBoundaryPoint() + || !cit->vertex(3)->internalOrBoundaryPoint() + ) + { + // This is a boundary dual vertex + + boundaryPts[dualVertI] = true; + } + } pts[dualVertI] = topoint(dual(cit)); - if - ( - !cit->vertex(0)->internalOrBoundaryPoint() - || !cit->vertex(1)->internalOrBoundaryPoint() - || !cit->vertex(2)->internalOrBoundaryPoint() - || !cit->vertex(3)->internalOrBoundaryPoint() - ) - { - // This is a boundary dual vertex - - boundaryPts[dualVertI] = true; - } - dualVertI++; } else diff --git a/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshIO.C b/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshIO.C index b93d0f8f9f..ab4d58975e 100644 --- a/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshIO.C +++ b/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshIO.C @@ -423,10 +423,10 @@ void Foam::conformalVoronoiMesh::writeMesh patches.setSize(nValidPatches); - mesh.addFvPatches(patches); + // mesh.addFvPatches(patches); - // Info<< "ADDPATCHES NOT IN PARALLEL" << endl; - // mesh.addFvPatches(patches, false); + Info<< "ADDPATCHES NOT IN PARALLEL" << endl; + mesh.addFvPatches(patches, false); if (!mesh.write()) { @@ -456,7 +456,7 @@ void Foam::conformalVoronoiMesh::writeMesh // cellCs.write(); - writeCellSizes(mesh); + // writeCellSizes(mesh); findRemainingProtrusionSet(mesh); }