diff --git a/src/mesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C b/src/mesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C index 89fa350131b6796da6af197dc4504855ad2fdbd3..ed340fd7209febe3d87db3aeb6f808ffd7408221 100644 --- a/src/mesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C +++ b/src/mesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C @@ -397,8 +397,8 @@ void Foam::backgroundMeshDecomposition::initialRefinement() if (debug) { - const_cast<Time&>(mesh_.time())++; - Info<< "Time " << mesh_.time().timeName() << endl; + // const_cast<Time&>(mesh_.time())++; + // Info<< "Time " << mesh_.time().timeName() << endl; meshCutter_.write(); mesh_.write(); cellWeights.write(); @@ -424,8 +424,8 @@ void Foam::backgroundMeshDecomposition::initialRefinement() { printMeshData(mesh_); - const_cast<Time&>(mesh_.time())++; - Info<< "Time " << mesh_.time().timeName() << endl; + // const_cast<Time&>(mesh_.time())++; + // Info<< "Time " << mesh_.time().timeName() << endl; meshCutter_.write(); mesh_.write(); cellWeights.write(); @@ -435,8 +435,8 @@ void Foam::backgroundMeshDecomposition::initialRefinement() if (debug) { - const_cast<Time&>(mesh_.time())++; - Info<< "Time " << mesh_.time().timeName() << endl; + // const_cast<Time&>(mesh_.time())++; + // Info<< "Time " << mesh_.time().timeName() << endl; cellWeights.write(); mesh_.write(); } @@ -868,8 +868,8 @@ Foam::backgroundMeshDecomposition::distribute { if (debug) { - const_cast<Time&>(mesh_.time())++; - Info<< "Time " << mesh_.time().timeName() << endl; + // const_cast<Time&>(mesh_.time())++; + // Info<< "Time " << mesh_.time().timeName() << endl; cellWeights.write(); mesh_.write(); } @@ -878,10 +878,27 @@ Foam::backgroundMeshDecomposition::distribute { // Refine large cells if necessary - scalar cellWeightLimit = + label nOccupiedCells = 0; + + forAll(cellWeights.internalField(), cI) + { + if (cellWeights.internalField()[cI] > 1 - SMALL) + { + nOccupiedCells++; + } + } + + // Only look at occupied cells, as there is a possibility of runaway + // refinement if the number of cells grows too fast. Also, clip the + // minimum cellWeightLimit at maxCellWeightCoeff_ + + scalar cellWeightLimit = max + ( maxCellWeightCoeff_ *sum(cellWeights).value() - /mesh_.globalData().nTotalCells(); + /returnReduce(nOccupiedCells, sumOp<label>()), + maxCellWeightCoeff_ + ); if (debug) { @@ -997,7 +1014,7 @@ Foam::backgroundMeshDecomposition::distribute newCellI = cellSearch.findNearestCell(v); - Pout<< newCellI << endl; + // Pout<< newCellI << endl; } newCellVertices[newCellI].append(v); @@ -1049,8 +1066,8 @@ Foam::backgroundMeshDecomposition::distribute << " to " << mesh_.globalData().nTotalCells() << " cells." << endl; - const_cast<Time&>(mesh_.time())++; - Info<< "Time " << mesh_.time().timeName() << endl; + // const_cast<Time&>(mesh_.time())++; + // Info<< "Time " << mesh_.time().timeName() << endl; cellWeights.write(); mesh_.write(); } @@ -1092,8 +1109,8 @@ Foam::backgroundMeshDecomposition::distribute << max(cellWeights.internalField()) << endl; - const_cast<Time&>(mesh_.time())++; - Info<< "Time " << mesh_.time().timeName() << endl; + // const_cast<Time&>(mesh_.time())++; + // Info<< "Time " << mesh_.time().timeName() << endl; mesh_.write(); cellWeights.write(); } diff --git a/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C b/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C index 0a0477f7a4f9a8d9f984e65de05f7ec4473c64e8..626d42397fe94d14e603dc7edb6fc4fcb1c13db9 100644 --- a/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C +++ b/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C @@ -88,7 +88,7 @@ Foam::tensor Foam::conformalVoronoiMesh::requiredAlignment scalar spanMag = geometryToConformTo_.globalBounds().mag(); - for(label i = 0; i < s; i++) + for (label i = 0; i < s; i++) { vector spoke ( @@ -439,7 +439,7 @@ void Foam::conformalVoronoiMesh::insertSurfacePointPairs insertPoints(pts, indices, types, true); - if(cvMeshControls().objOutput() && fName != fileName::null) + if (cvMeshControls().objOutput() && fName != fileName::null) { writePoints(fName, pts); } @@ -478,7 +478,7 @@ void Foam::conformalVoronoiMesh::insertEdgePointGroups insertPoints(pts, indices, types, true); - if(cvMeshControls().objOutput() && fName != fileName::null) + if (cvMeshControls().objOutput() && fName != fileName::null) { writePoints(fName, pts); } @@ -768,7 +768,7 @@ void Foam::conformalVoronoiMesh::insertFeaturePoints() // Insert the created points, distributing to the appropriate processor insertPoints(pts, indices, types, true); - if(cvMeshControls().objOutput()) + if (cvMeshControls().objOutput()) { writePoints("featureVertices.obj", pts); } @@ -1009,7 +1009,7 @@ void Foam::conformalVoronoiMesh::createMixedFeaturePoints } } - if(skipEdge) + if (skipEdge) { Info<< "Skipping point " << ptI << nl << endl; @@ -1225,7 +1225,7 @@ void Foam::conformalVoronoiMesh::insertInitialPoints() // which processor each point should be on, so give distribute = false insertPoints(initPts, false); - if(cvMeshControls().objOutput()) + if (cvMeshControls().objOutput()) { writePoints("initialPoints.obj", true); } @@ -1358,7 +1358,7 @@ bool Foam::conformalVoronoiMesh::distributeBackground() cellWeights.internalField()[cI] = max ( cellVertices[cI].size(), - 1e-2 + 1e-3 ); } @@ -1422,7 +1422,7 @@ bool Foam::conformalVoronoiMesh::distributeBackground() // Pout<< " Real vertices after distribution " // << label(number_of_vertices() - 8) << endl; - if(cvMeshControls().objOutput()) + if (cvMeshControls().objOutput()) { writePoints("distributedPoints.obj", true); } @@ -1927,7 +1927,7 @@ Foam::conformalVoronoiMesh::conformalVoronoiMesh // domain the processor they are on. // reportProcessorOccupancy(); - if(cvMeshControls().objOutput()) + if (cvMeshControls().objOutput()) { writePoints("allInitialPoints.obj", false); } diff --git a/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C b/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C index b9e531fb994e0f5ed5258a2a2f6241e354104a87..404a30eb0a716bcdce3b9359b98cbb06294cf0b2 100644 --- a/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C +++ b/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C @@ -472,7 +472,7 @@ Foam::label Foam::conformalVoronoiMesh::mergeCloseDualVertices continue; } - if(c1I != -1 && c2I != -1 && (c1I != c2I)) + if (c1I != -1 && c2I != -1 && (c1I != c2I)) { if ( diff --git a/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C b/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C index 8b09494fe87eba52a12b643b2b7b40b8d9359207..e111155888d02a205a95eda1d605c4248e7f3b47 100644 --- a/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C +++ b/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C @@ -1724,7 +1724,7 @@ void Foam::conformalVoronoiMesh::addSurfaceAndEdgeHits if (edHit.hit()) { - if(!positionOnThisProc(edHit.hitPoint())) + if (!positionOnThisProc(edHit.hitPoint())) { continue; } diff --git a/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshIO.C b/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshIO.C index 31ee3dc4ba2f1a6776ca5f49cf4e4ef31ee47fbf..daed639ee7dbdabcc4bdef9ec0f9325570ac3322 100644 --- a/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshIO.C +++ b/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshIO.C @@ -340,7 +340,7 @@ void Foam::conformalVoronoiMesh::writeMesh const pointField& cellCentres ) const { - if(cvMeshControls().objOutput()) + if (cvMeshControls().objOutput()) { writeObjMesh(points, faces, word(meshName + ".obj")); } diff --git a/src/mesh/conformalVoronoiMesh/initialPointsMethod/initialPointsMethod/initialPointsMethod.C b/src/mesh/conformalVoronoiMesh/initialPointsMethod/initialPointsMethod/initialPointsMethod.C index 056173afc477cb81f5f9594b69bca99c30a79a90..944d4f8c9bee43156b76ff21ce1d9effab3f6249 100644 --- a/src/mesh/conformalVoronoiMesh/initialPointsMethod/initialPointsMethod/initialPointsMethod.C +++ b/src/mesh/conformalVoronoiMesh/initialPointsMethod/initialPointsMethod/initialPointsMethod.C @@ -48,7 +48,7 @@ initialPointsMethod::initialPointsMethod : dictionary(initialPointsDict), cvMesh_(cvMesh), - detailsDict_(subDict(type + "Details")), + detailsDict_(subDict(type + "Coeffs")), minimumSurfaceDistanceCoeffSqr_ ( sqr diff --git a/src/mesh/conformalVoronoiMesh/initialPointsMethod/pointFile/pointFile.C b/src/mesh/conformalVoronoiMesh/initialPointsMethod/pointFile/pointFile.C index 81d001618a5b2392077e10c5024b3ec26befd864..fe56a5aa14d2aed473f1bd058db153490059c659 100644 --- a/src/mesh/conformalVoronoiMesh/initialPointsMethod/pointFile/pointFile.C +++ b/src/mesh/conformalVoronoiMesh/initialPointsMethod/pointFile/pointFile.C @@ -74,42 +74,55 @@ std::list<Vb::Point> pointFile::initialPoints() const << exit(FatalError) << endl; } - // Filter the points to be only those on this processor - boolList procPt(cvMesh_.positionOnThisProc(points)); - if (Pstream::parRun()) { - List<boolList> allProcPt(Pstream::nProcs()); + if (points.path().find("processor") != string::npos) + { + // Testing filePath to see if the file originated in a processor + // directory, if so, assume that the points in each processor file + // are unique. They are unlikely to belong on the current + // processor as the background mesh is unlikely to be the same. - allProcPt[Pstream::myProcNo()] = procPt; + cvMesh_.decomposition().distributePoints(points); + } + else + { + // Otherwise, this is assumed to be points covering the whole + // domain, so filter the points to be only those on this processor + boolList procPt(cvMesh_.positionOnThisProc(points)); - Pstream::gatherList(allProcPt); + List<boolList> allProcPt(Pstream::nProcs()); - Pstream::scatterList(allProcPt); + allProcPt[Pstream::myProcNo()] = procPt; - forAll(procPt, ptI) - { - bool foundAlready = false; + Pstream::gatherList(allProcPt); + + Pstream::scatterList(allProcPt); - forAll(allProcPt, procI) + forAll(procPt, ptI) { - // If a processor with a lower index has found this point to - // insert already, defer to it and don't insert. - if (foundAlready) - { - allProcPt[procI][ptI] = false; - } - else if (allProcPt[procI][ptI]) + bool foundAlready = false; + + forAll(allProcPt, procI) { - foundAlready = true; + // If a processor with a lower index has found this point + // to insert already, defer to it and don't insert. + if (foundAlready) + { + allProcPt[procI][ptI] = false; + } + else if (allProcPt[procI][ptI]) + { + foundAlready = true; + } } } - } - procPt = allProcPt[Pstream::myProcNo()]; - } + procPt = allProcPt[Pstream::myProcNo()]; - inplaceSubset(procPt, points); + inplaceSubset(procPt, points); + } + } std::list<Vb::Point> initialPoints; diff --git a/tutorials/mesh/cvMesh/flange/system/cvMeshDict-generatePoints b/tutorials/mesh/cvMesh/flange/system/cvMeshDict-generatePoints index 84ef6fb7601735fd0465c56494445e97678ae79f..2b89c0f82a985667c4808db9ed564ee987d5ed0f 100644 --- a/tutorials/mesh/cvMesh/flange/system/cvMeshDict-generatePoints +++ b/tutorials/mesh/cvMesh/flange/system/cvMeshDict-generatePoints @@ -114,7 +114,7 @@ initialPoints // initialPointsMethod bodyCentredCubic; // initialPointsMethod pointFile; - autoDensityDetails + autoDensityCoeffs { minLevels 1; maxSizeRatio 2.0; @@ -122,21 +122,21 @@ initialPoints surfaceSampleResolution 5; } - uniformGridDetails + uniformGridCoeffs { initialCellSize 0.0015; randomiseInitialGrid yes; randomPerturbationCoeff 0.02; } - bodyCentredCubicDetails + bodyCentredCubicCoeffs { initialCellSize 0.0015; randomiseInitialGrid no; randomPerturbationCoeff 0.1; } - pointFileDetails + pointFileCoeffs { pointFile "constant/internalDelaunayVertices"; } diff --git a/tutorials/mesh/cvMesh/flange/system/cvMeshDict-usePoints b/tutorials/mesh/cvMesh/flange/system/cvMeshDict-usePoints index 8fa7cb3f5f842dbcb6154b3ec870ed4d6eb35b95..f18afac7013ae19fc91f5141fa601b8e3aecd08d 100644 --- a/tutorials/mesh/cvMesh/flange/system/cvMeshDict-usePoints +++ b/tutorials/mesh/cvMesh/flange/system/cvMeshDict-usePoints @@ -111,7 +111,7 @@ initialPoints initialPointsMethod pointFile; - pointFileDetails + pointFileCoeffs { pointFile "constant/internalDelaunayVertices"; } diff --git a/tutorials/mesh/cvMesh/simpleShapes/system/cvMeshDict b/tutorials/mesh/cvMesh/simpleShapes/system/cvMeshDict index 7e75ea51d342a519deba705e8c1f535f0a74445a..c8055a4d341a125b794c29e132d9a5e2b0a7c8e1 100644 --- a/tutorials/mesh/cvMesh/simpleShapes/system/cvMeshDict +++ b/tutorials/mesh/cvMesh/simpleShapes/system/cvMeshDict @@ -209,10 +209,9 @@ initialPoints // initialPointsMethod bodyCentredCubic; // initialPointsMethod pointFile; - - // Take boundbox of all geometry. Sample with this box. If too much - // samples in box (due to target cell size) split box. - autoDensityDetails + // Take boundbox of all geometry. Samples with this box. If too much + // samples (due to target cell size) in box split box. + autoDensityCoeffs { // Initial number of refinement levels. Needs to be enough to pick // up features due to size ratio. If not enough it will take longer @@ -226,7 +225,7 @@ initialPoints surfaceSampleResolution 3; } - uniformGridDetails + uniformGridCoeffs { // Absolute cell size. initialCellSize 0.0015; @@ -234,14 +233,14 @@ initialPoints randomPerturbationCoeff 0.02; } - bodyCentredCubicDetails + bodyCentredCubicCoeffs { initialCellSize 0.0015; randomiseInitialGrid no; randomPerturbationCoeff 0.1; } - pointFileDetails + pointFileCoeffs { // Reads points from file. Still rejects points that are too // close to the surface (minimumSurfaceDistanceCoeff) or on the