From ca834a93c8fb11ef48745f482ff1d66f86f6fdc9 Mon Sep 17 00:00:00 2001 From: mattijs Date: Mon, 14 Dec 2015 09:36:52 +0000 Subject: [PATCH] BUG: triSurfaceMesh: operate non-parallel so not do a reduction of points Also redistributePar: - recognise going from undecomposed to many - read on master only --- .../surfaceRedistributePar.C | 116 +++++++----------- .../searchableSurface/triSurfaceMesh.C | 8 +- .../distributedTriSurfaceMesh.C | 4 +- 3 files changed, 48 insertions(+), 80 deletions(-) diff --git a/applications/utilities/surface/surfaceRedistributePar/surfaceRedistributePar.C b/applications/utilities/surface/surfaceRedistributePar/surfaceRedistributePar.C index 87deafe8ac..5a9674cf1a 100644 --- a/applications/utilities/surface/surfaceRedistributePar/surfaceRedistributePar.C +++ b/applications/utilities/surface/surfaceRedistributePar/surfaceRedistributePar.C @@ -74,13 +74,16 @@ void writeProcStats forAll(surfBb, procI) { - const List& bbs = meshBb[procI]; + Info<< "processor" << procI << nl; - Info<< "processor" << procI << nl - << "\tMesh bounds : " << bbs[0] << nl; - for (label i = 1; i < bbs.size(); i++) + const List& bbs = meshBb[procI]; + if (bbs.size()) { - Info<< "\t " << bbs[i]<< nl; + Info<< "\tMesh bounds : " << bbs[0] << nl; + for (label i = 1; i < bbs.size(); i++) + { + Info<< "\t " << bbs[i]<< nl; + } } Info<< "\tSurface bounding box : " << surfBb[procI] << nl << "\tTriangles : " << nFaces[procI] << nl @@ -112,12 +115,13 @@ int main(int argc, char *argv[]) runTime.functionObjects().off(); const fileName surfFileName = args[1]; - const word distType = args[2]; + const word distTypeName = args[2]; + const label distType = + distributedTriSurfaceMesh::distributionTypeNames_[distTypeName]; Info<< "Reading surface from " << surfFileName << nl << nl << "Using distribution method " - << distributedTriSurfaceMesh::distributionTypeNames_[distType] - << " " << distType << nl << endl; + << distTypeName << nl << endl; const bool keepNonMapped = args.options().found("keepNonMapped"); @@ -141,13 +145,14 @@ int main(int argc, char *argv[]) } - #include "createPolyMesh.H" - Random rndGen(653213); // Determine mesh bounding boxes: List > meshBb(Pstream::nProcs()); + if (distType == distributedTriSurfaceMesh::FOLLOW) { + #include "createPolyMesh.H" + meshBb[Pstream::myProcNo()] = List ( 1, @@ -192,83 +197,48 @@ int main(int argc, char *argv[]) fileName localPath(actualPath); localPath.replace(runTime.rootPath() + '/', ""); + + autoPtr surfMeshPtr; + if (actualPath == io.objectPath()) { Info<< "Loading local (decomposed) surface " << localPath << nl < bbs; + if (Pstream::master()) + { + // Actually load the surface + triSurfaceMesh surf(io); + s = surf; + bbs = List(1, treeBoundBox(boundBox::greatBox)); + } + else + { + bbs = List(1, treeBoundBox(boundBox::invertedBox)); + } - // Create dummy dictionary for bounding boxes if does not exist. - if (!isFile(actualPath / "Dict")) - { dictionary dict; - dict.add("bounds", meshBb[Pstream::myProcNo()]); - dict.add("distributionType", distType); + dict.add("distributionType", distTypeName); dict.add("mergeDistance", SMALL); + dict.add("bounds", bbs); - IOdictionary ioDict - ( - IOobject - ( - io.name() + "Dict", - io.instance(), - io.local(), - io.db(), - IOobject::NO_READ, - IOobject::NO_WRITE, - false - ), - dict - ); + // Scatter patch information + Pstream::scatter(s.patches()); - Info<< "Writing dummy bounds dictionary to " << ioDict.name() - << nl << endl; - - // Force writing in ascii - ioDict.regIOobject::writeObject - ( - IOstream::ASCII, - IOstream::currentVersion, - ioDict.time().writeCompression() - ); + // Construct distributedTrisurfaceMesh from components + IOobject notReadIO(io); + notReadIO.readOpt() = IOobject::NO_READ; + surfMeshPtr.reset(new distributedTriSurfaceMesh(notReadIO, s, dict)); } - - // Load surface - distributedTriSurfaceMesh surfMesh(io); - Info<< "Loaded surface" << nl << endl; - - - // Generate a test field - { - const triSurface& s = static_cast(surfMesh); - - autoPtr fcPtr - ( - new triSurfaceVectorField - ( - IOobject - ( - "faceCentres", // name - surfMesh.searchableSurface::time().timeName(), // instance - surfMesh.searchableSurface::local(), // local - surfMesh, - IOobject::NO_READ, - IOobject::AUTO_WRITE - ), - surfMesh, - dimLength, - s.faceCentres() - ) - ); - - // Steal pointer and store object on surfMesh - fcPtr.ptr()->store(); - } + distributedTriSurfaceMesh& surfMesh = surfMeshPtr(); // Write per-processor stats diff --git a/src/meshTools/searchableSurface/triSurfaceMesh.C b/src/meshTools/searchableSurface/triSurfaceMesh.C index 02718f34af..093edeb03b 100644 --- a/src/meshTools/searchableSurface/triSurfaceMesh.C +++ b/src/meshTools/searchableSurface/triSurfaceMesh.C @@ -243,7 +243,7 @@ Foam::triSurfaceMesh::triSurfaceMesh(const IOobject& io, const triSurface& s) { const pointField& pts = triSurface::points(); - bounds() = boundBox(pts); + bounds() = boundBox(pts, false); } @@ -292,7 +292,7 @@ Foam::triSurfaceMesh::triSurfaceMesh(const IOobject& io) { const pointField& pts = triSurface::points(); - bounds() = boundBox(pts); + bounds() = boundBox(pts, false); } @@ -355,7 +355,7 @@ Foam::triSurfaceMesh::triSurfaceMesh const pointField& pts = triSurface::points(); - bounds() = boundBox(pts); + bounds() = boundBox(pts, false); // Have optional minimum quality for normal calculation if (dict.readIfPresent("minQuality", minQuality_) && minQuality_ > 0) @@ -463,7 +463,7 @@ void Foam::triSurfaceMesh::movePoints(const pointField& newPoints) edgeTree_.clear(); triSurface::movePoints(newPoints); - bounds() = boundBox(triSurface::points()); + bounds() = boundBox(triSurface::points(), false); } diff --git a/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C b/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C index 88e1d30b19..ddc60dce48 100644 --- a/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C +++ b/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C @@ -2376,10 +2376,8 @@ void Foam::distributedTriSurfaceMesh::distribute clearOut(); // Set the bounds() value to the boundBox of the undecomposed surface - triSurfaceMesh::bounds() = boundBox(points()); + bounds() = boundBox(points(), true); - reduce(bounds().min(), minOp()); - reduce(bounds().max(), maxOp()); // Regions stays same // Volume type stays same.