diff --git a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C index 4e97af7a7a7583dea1535bae83092571ea12bbb0..7ca688a113a88106a744bf3f75c67793cc80669f 100644 --- a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C +++ b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C @@ -240,9 +240,9 @@ void Foam::conformalVoronoiMesh::insertPoints { label preDistributionSize(points.size()); - DynamicList<Foam::point> transferPoints; + DynamicList<Foam::point> transferPoints(points.size()/2); - List<Point> pointsOnProcessor; + DynamicList<Point> pointsOnProcessor(points.size()/2); for ( @@ -393,6 +393,30 @@ void Foam::conformalVoronoiMesh::insertPoints // Info<< returnReduce(pts.size(), sumOp<label>()) // << " points in total" << endl; } +// +// forAll(pts, pI) +// { +// // creation of points and indices is done assuming that it will be +// // relative to the instantaneous number_of_vertices() at insertion. +// +// label type = types[pI]; +// +// if (type > Vb::vtFar) +// { +// // This is a member of a point pair, don't use the type directly +// // (note that this routine never gets called for referredPoints +// // so type will never be -procI) +// type += number_of_vertices(); +// } +// +// insertPoint +// ( +// pts[pI], +// indices[pI] + number_of_vertices(), +// type +// ); +// } + rangeInsertWithInfo ( @@ -402,6 +426,8 @@ void Foam::conformalVoronoiMesh::insertPoints indices, types ); + + Pout<< pts.size() << " " << indices.size() << " " << types.size() << endl; } diff --git a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H index 4ee0b2a42d6ab720f3a3b81d46fecf4119cb6140..6e395725fad785e4482de6c511dccad5e39b050e 100644 --- a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H +++ b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H @@ -970,8 +970,8 @@ private: labelList& owner, labelList& patchSizes, labelList& patchStarts, - List<DynamicList<face> >& patchFaces, - List<DynamicList<label> >& patchOwners + const List<DynamicList<face> >& patchFaces, + const List<DynamicList<label> >& patchOwners ) const; //- Remove points that are no longer used by any faces @@ -1165,6 +1165,11 @@ public: // protrude out of the surface beyond a tolerance. void findRemainingProtrusionSet(const fvMesh& mesh) const; + void writeProcessorInterface + ( + const fileName& fName, + const faceList& faces + ) const; //- Function inserting points into a triangulation and setting the // index and type data of the point in the correct order. This is @@ -1226,23 +1231,33 @@ public: c = T.locate(*(p->first), lt, li, lj, hint); + const size_t checkInsertion = T.number_of_vertices(); + typename Triangulation::Vertex_handle v = T.insert(*(p->first), lt, c, li, lj); - label oldIndex = p->second; - - label type = types[oldIndex]; - - if (type > Vb::vtFar) + if (checkInsertion != T.number_of_vertices() - 1) { - // This is a member of a point pair, don't use the type - // directly (note that this routine never gets called - // for referredPoints so type will never be -procI) - type += T.number_of_vertices() - 1; + Pout<< "Failed to insert point " + << topoint(*(p->first)) << endl; } + else + { + label oldIndex = p->second; + + label type = types[oldIndex]; - v->index() = indices[oldIndex] + T.number_of_vertices() - 1; - v->type() = type; + if (type > Vb::vtFar) + { + // This is a member of a point pair, don't use the type + // directly (note that this routine never gets called + // for referredPoints so type will never be -procI) + type += T.number_of_vertices() - 1; + } + + v->index() = indices[oldIndex] + T.number_of_vertices() - 1; + v->type() = type; + } } } }; diff --git a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C index 025d530db6610cbea221814a3020ac3dbeb6f9e5..4719d28f6eb055eef48538f34b1bbffcc4a06fef 100644 --- a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C +++ b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C @@ -82,56 +82,56 @@ void Foam::conformalVoronoiMesh::calcDualMesh // REMOVED BECAUSE THIS CODE STOPS ALL FACES NEAR ANY BOUNDARY (PROC OR REAL) // FROM BEING FILTERED. // -// for -// ( -// Delaunay::Finite_vertices_iterator vit = finite_vertices_begin(); -// vit != finite_vertices_end(); -// vit++ -// ) -// { -// std::list<Cell_handle> cells; -// incident_cells(vit, std::back_inserter(cells)); -// -// bool hasProcPt = false; -// -// for -// ( -// std::list<Cell_handle>::iterator cit = cells.begin(); -// cit != cells.end(); -// ++cit -// ) -// { -// // Allow filtering if any vertices are far points. Otherwise faces -// // with boundary points attached to a cell with a far point will -// // not be filtered. -// if -// ( -// (!(*cit)->vertex(0)->real() && !(*cit)->vertex(0)->farPoint()) -// || (!(*cit)->vertex(1)->real() && !(*cit)->vertex(1)->farPoint()) -// || (!(*cit)->vertex(2)->real() && !(*cit)->vertex(2)->farPoint()) -// || (!(*cit)->vertex(3)->real() && !(*cit)->vertex(3)->farPoint()) -// ) -// { -// hasProcPt = true; -// -// break; -// } -// } -// -// if (hasProcPt) -// { -// for -// ( -// std::list<Cell_handle>::iterator cit = cells.begin(); -// cit != cells.end(); -// ++cit -// ) -// { -// (*cit)->filterCount() = -// cvMeshControls().filterCountSkipThreshold() + 1; -// } -// } -// } + for + ( + Delaunay::Finite_vertices_iterator vit = finite_vertices_begin(); + vit != finite_vertices_end(); + vit++ + ) + { + std::list<Cell_handle> cells; + incident_cells(vit, std::back_inserter(cells)); + + bool hasProcPt = false; + + for + ( + std::list<Cell_handle>::iterator cit = cells.begin(); + cit != cells.end(); + ++cit + ) + { + // Allow filtering if any vertices are far points. Otherwise faces + // with boundary points attached to a cell with a far point will + // not be filtered. + if + ( + (!(*cit)->vertex(0)->real())// && !(*cit)->vertex(0)->farPoint()) + || (!(*cit)->vertex(1)->real())// && !(*cit)->vertex(1)->farPoint()) + || (!(*cit)->vertex(2)->real())// && !(*cit)->vertex(2)->farPoint()) + || (!(*cit)->vertex(3)->real())// && !(*cit)->vertex(3)->farPoint()) + ) + { + hasProcPt = true; + + break; + } + } + + if (hasProcPt) + { + for + ( + std::list<Cell_handle>::iterator cit = cells.begin(); + cit != cells.end(); + ++cit + ) + { + (*cit)->filterCount() = + cvMeshControls().filterCountSkipThreshold() + 1; + } + } + } PackedBoolList boundaryPts(number_of_cells(), false); @@ -2157,9 +2157,9 @@ void Foam::conformalVoronoiMesh::createFacesOwnerNeighbourAndPatches // Did not find a surface patch between // between Dv pair, finding nearest patch - // Pout<< "Did not find a surface patch between " - // << "for face, finding nearest patch to" - // << 0.5*(ptA + ptB) << endl; +// Pout<< "Did not find a surface patch between " +// << "for face, finding nearest patch to" +// << 0.5*(ptA + ptB) << endl; patchIndex = geometryToConformTo_.findPatch ( @@ -2240,6 +2240,37 @@ void Foam::conformalVoronoiMesh::createFacesOwnerNeighbourAndPatches { patchPointPairSlaves[patchI].transfer(patchPPSlaves[patchI]); } + + if (cvMeshControls().objOutput()) + { + forAll(procNeighbours, nbI) + { + if (patchFaces[nbI].size() > 0) + { + const label neighbour = procNeighbours[nbI]; + + if (neighbour != -1) + { + word fName = + "processor_" + + name(Pstream::myProcNo()) + + "_to_" + + name(neighbour) + + "_interface.obj"; + + writeProcessorInterface + ( + fName, + patchFaces[nbI] + ); + } + } + } + + Pout<< "Patch Names: " << patchNames << endl; + Pout<< "Patch Sizes: " << patchSizes << endl; + Pout<< "Proc Neighbours: " << procNeighbours << endl; + } } @@ -2527,8 +2558,8 @@ void Foam::conformalVoronoiMesh::addPatches labelList& owner, labelList& patchSizes, labelList& patchStarts, - List<DynamicList<face> >& patchFaces, - List<DynamicList<label> >& patchOwners + const List<DynamicList<face> >& patchFaces, + const List<DynamicList<label> >& patchOwners ) const { label nPatches = patchFaces.size(); diff --git a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshIO.C b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshIO.C index bc9d04dfb1e79ca32216f53185c7443267f9996d..fc860a3b59d975e9e22894a821b0356696c11218 100644 --- a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshIO.C +++ b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshIO.C @@ -220,6 +220,37 @@ void Foam::conformalVoronoiMesh::writePoints } +void Foam::conformalVoronoiMesh::writeProcessorInterface +( + const fileName& fName, + const faceList& faces +) const +{ + OFstream str(runTime_.path()/fName); + + Pout<< "Writing processor interface" << endl; + + pointField points(number_of_cells(), point::max); + + for + ( + Delaunay::Finite_cells_iterator cit = finite_cells_begin(); + cit != finite_cells_end(); + ++cit + ) + { + if (!cit->farCell()) + { + points[cit->cellIndex()] = topoint(dual(cit)); + } + } + + meshTools::writeOBJ(str, faces, points); + + Pout<< "Written processor interface" << endl; +} + + void Foam::conformalVoronoiMesh::writeInternalDelaunayVertices ( const fileName& instance