diff --git a/src/mesh/snappyHexMesh/shellSurfaces/shellSurfaces.C b/src/mesh/snappyHexMesh/shellSurfaces/shellSurfaces.C index 2c9210fe1a..8a0f7aad9d 100644 --- a/src/mesh/snappyHexMesh/shellSurfaces/shellSurfaces.C +++ b/src/mesh/snappyHexMesh/shellSurfaces/shellSurfaces.C @@ -35,6 +35,7 @@ License #include "orientedSurface.H" #include "pointIndexHit.H" #include "volumeType.H" +#include "distributedTriSurfaceMesh.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -167,7 +168,12 @@ void Foam::shellSurfaces::orient() { const searchableSurface& s = allGeometry_[shells_[shellI]]; - if (modes_[shellI] != DISTANCE && isA(s)) + if + ( + modes_[shellI] != DISTANCE + && isA(s) + && !isA(s) + ) { hasSurface = true; @@ -190,7 +196,12 @@ void Foam::shellSurfaces::orient() { const searchableSurface& s = allGeometry_[shells_[shellI]]; - if (modes_[shellI] != DISTANCE && isA(s)) + if + ( + modes_[shellI] != DISTANCE + && isA(s) + && !isA(s) + ) { triSurfaceMesh& shell = const_cast ( diff --git a/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C b/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C index b7285cc19a..3bc4dd90ff 100644 --- a/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C +++ b/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C @@ -110,6 +110,73 @@ namespace Foam }; + //typedef Tuple2, volumeType> NearType; + // + ////- Combine operator for volume types + //struct NearTypeCombineOp + //{ + // //const auto& this_; + // + // void operator()(NearType& nearX, const NearType& nearY) const + // { + // const volumeType& x = nearX.second(); + // const volumeType& y = nearY.second(); + // + // if (x == volumeType::MIXED || y == volumeType::MIXED) + // { + // FatalErrorInFunction << "Illegal volume type " + // << volumeType::names[x] + // << "," << volumeType::names[y] + // << " nearX:" << nearX << " nearY:" << nearY + // << exit(FatalError); + // } + // else + // { + // switch (x) + // { + // case volumeType::UNKNOWN: + // { + // if (y == volumeType::INSIDE + // || y == volumeType::OUTSIDE) + // { + // nearX = nearY; + // } + // } + // break; + // case volumeType::INSIDE: + // { + // if (y == volumeType::OUTSIDE) + // { + // FatalErrorInFunction + // << "Conflicting volume types " + // << volumeType::names[x] << "," + // << volumeType::names[y] + // << " nearX:" << nearX << " nearY:" << nearY + // << exit(FatalError); + // } + // } + // break; + // case volumeType::OUTSIDE: + // { + // if (y == volumeType::INSIDE) + // { + // FatalErrorInFunction + // << "Conflicting volume types " + // << volumeType::names[x] << "," + // << volumeType::names[y] + // << " nearX:" << nearX << " nearY:" << nearY + // << exit(FatalError); + // } + // } + // break; + // case volumeType::MIXED: + // break; + // } + // } + // } + //}; + + //- Combine operator for nearest typedef Tuple2 nearestAndDist; @@ -569,7 +636,8 @@ void Foam::distributedTriSurfaceMesh::findLine if (debug) { Pout<< "distributedTriSurfaceMesh::findLine :" - << " intersecting with " + << " intersecting surface " << searchableSurface::name() + << " with " << start.size() << " rays" << endl; } addProfiling(findLine, "distributedTriSurfaceMesh::findLine"); @@ -1177,6 +1245,7 @@ void Foam::distributedTriSurfaceMesh::surfaceSide if (debug) { Pout<< "distributedTriSurfaceMesh::surfaceSide :" + << " on surface " << searchableSurface::name() << " finding surface side given points on surface for " << samples.size() << " samples" << endl; } @@ -1399,10 +1468,46 @@ void Foam::distributedTriSurfaceMesh::surfaceSide map.comm() ); + //// Pack sample, nearest and volType so we get nicer error messages + ////typedef Tuple2, volumeType>> NearType; + //List nearTypes(volType.size()); + //forAll(localSamples, i) + //{ + // const point& sample = localSamples[i]; + // const point& near = nearest[i]; + // nearTypes[i] = NearType(Pair(sample, near), volType[i]); + //} + // + // + //const NearType zero(Pair(Zero, Zero), volumeType::UNKNOWN); + //mapDistributeBase::distribute + //( + // Pstream::commsTypes::nonBlocking, + // List(0), + // nearestInfo.size(), + // map.constructMap(), + // map.constructHasFlip(), + // map.subMap(), + // map.subHasFlip(), + // nearTypes, + // zero, + // NearTypeCombineOp(), + // noOp(), // no flipping + // UPstream::msgType(), + // map.comm() + //); + //volType.setSize(nearTypes.size()); + //forAll(nearTypes, i) + //{ + // volType[i] = nearTypes[i].second(); + //} + if (debug) { Pout<< "distributedTriSurfaceMesh::surfaceSide :" - << " finished finding surface side given points on surface for " + << " finished finding surface" << searchableSurface::name() + << " given points on surface " + << searchableSurface::name() << " for " << samples.size() << " samples" << endl; } } @@ -1706,7 +1811,8 @@ Foam::distributedTriSurfaceMesh::independentlyDistributedBbs if (debug) { Pout<< "distributedTriSurfaceMesh::independentlyDistributedBbs :" - << " determining processor bounding boxes" << endl; + << " determining processor bounding boxes for surface" + << searchableSurface::name() << endl; } // Find bounding box for all triangles on new distribution. @@ -1739,7 +1845,8 @@ Foam::distributedTriSurfaceMesh::independentlyDistributedBbs { Pout<< "distributedTriSurfaceMesh::independentlyDistributedBbs :" << " determining decomposition for " << s.size() - << " centroids" << endl; + << " centroids of surface " << searchableSurface::name() + << endl; } // Triangle centres @@ -1976,7 +2083,8 @@ Foam::distributedTriSurfaceMesh::independentlyDistributedBbs if (debug) { Pout<< "distributedTriSurfaceMesh::independentlyDistributedBbs :" - << " collecting all centroids" << endl; + << " collecting all centroids for surface " + << searchableSurface::name() << endl; } // Collect all triangle centres @@ -2013,6 +2121,7 @@ Foam::distributedTriSurfaceMesh::independentlyDistributedBbs { Pout<< "distributedTriSurfaceMesh::" << "independentlyDistributedBbs :" + << " surface:" << searchableSurface::name() << " merged " << allCentres.size() << " centroids down to " << nMerged << endl; } @@ -2470,7 +2579,9 @@ Foam::distributedTriSurfaceMesh::distributedTriSurfaceMesh if (debug) { - InfoInFunction << "Constructed from triSurface:" << endl; + InfoInFunction << "Constructed from triSurface " + << searchableSurface::name() + << endl; writeStats(Info); labelList nTris @@ -3021,6 +3132,7 @@ void Foam::distributedTriSurfaceMesh::findNearest if (debug) { Pout<< "distributedTriSurfaceMesh::findNearest :" + << " surface " << searchableSurface::name() << " trying to find nearest for " << samples.size() << " samples with max sphere " << (samples.size() ? Foam::sqrt(max(nearestDistSqr)) : Zero) @@ -3114,7 +3226,7 @@ void Foam::distributedTriSurfaceMesh::findNearest if (debug) { - Pout<< "Pass1:" + Pout<< searchableSurface::name() << " Pass1:" << " of " << samples.size() << " samples sending to" << endl; label nSend = 0; forAll(map1.subMap(), proci) @@ -3179,6 +3291,7 @@ void Foam::distributedTriSurfaceMesh::findNearest if (debug) { Pout<< "distributedTriSurfaceMesh::findNearest :" + << " surface " << searchableSurface::name() << " searched locally for " << localPoints.size() << " samples with max sphere " << (localDistSqr.size() ? Foam::sqrt(max(localDistSqr)) : Zero) @@ -3282,7 +3395,7 @@ void Foam::distributedTriSurfaceMesh::findNearest if (debug) { - Pout<< "Pass2:" + Pout << searchableSurface::name() << " Pass2:" << " of " << samples.size() << " samples sending to" << endl; label nSend = 0; forAll(map2.subMap(), proci) @@ -3344,6 +3457,7 @@ void Foam::distributedTriSurfaceMesh::findNearest if (debug) { Pout<< "distributedTriSurfaceMesh::findNearest :" + << " surface " << searchableSurface::name() << " searched locally for " << localSamples.size() << " samples with max sphere " << (localDistSqr.size() ? Foam::sqrt(max(localDistSqr)) : Zero) @@ -3410,6 +3524,7 @@ void Foam::distributedTriSurfaceMesh::findNearest if (debug) { Pout<< "distributedTriSurfaceMesh::findNearest :" + << " surface " << searchableSurface::name() << " trying to find nearest and region for " << samples.size() << " samples with max sphere " << (samples.size() ? Foam::sqrt(max(nearestDistSqr)) : Zero) @@ -3592,6 +3707,7 @@ void Foam::distributedTriSurfaceMesh::findLineAll if (debug) { Pout<< "distributedTriSurfaceMesh::findLineAll :" + << " surface " << searchableSurface::name() << " intersecting with " << start.size() << " rays" << endl; } @@ -3731,6 +3847,7 @@ void Foam::distributedTriSurfaceMesh::findLineAll if (debug) { Pout<< "distributedTriSurfaceMesh::findLineAll :" + << " surface " << searchableSurface::name() << " finished intersecting with " << start.size() << " rays" << endl; } @@ -3746,6 +3863,7 @@ void Foam::distributedTriSurfaceMesh::getRegion if (debug) { Pout<< "distributedTriSurfaceMesh::getRegion :" + << " surface " << searchableSurface::name() << " getting region for " << info.size() << " triangles" << endl; } @@ -3770,6 +3888,7 @@ void Foam::distributedTriSurfaceMesh::getRegion if (debug) { Pout<< "distributedTriSurfaceMesh::getRegion :" + << " surface " << searchableSurface::name() << " finished getting region for " << info.size() << " triangles" << endl; } @@ -3814,6 +3933,7 @@ void Foam::distributedTriSurfaceMesh::getRegion if (debug) { Pout<< "distributedTriSurfaceMesh::getRegion :" + << " surface " << searchableSurface::name() << " finished getting region for " << info.size() << " triangles" << endl; } @@ -3835,6 +3955,7 @@ void Foam::distributedTriSurfaceMesh::getNormal if (debug) { Pout<< "distributedTriSurfaceMesh::getNormal :" + << " surface " << searchableSurface::name() << " getting normal for " << info.size() << " triangles" << endl; } @@ -3879,6 +4000,7 @@ void Foam::distributedTriSurfaceMesh::getNormal if (debug) { Pout<< "distributedTriSurfaceMesh::getNormal :" + << " surface " << searchableSurface::name() << " finished getting normal for " << info.size() << " triangles" << endl; } @@ -3990,6 +4112,7 @@ void Foam::distributedTriSurfaceMesh::getVolumeType if (debug) { Pout<< "distributedTriSurfaceMesh::getVolumeType :" + << " surface " << searchableSurface::name() << " triggering outsidePoint" << outsidePt << " orientation" << endl; } @@ -4005,11 +4128,22 @@ void Foam::distributedTriSurfaceMesh::getVolumeType List outsideVolTypes; surfaceSide(outsidePts, nearestInfo, outsideVolTypes); - outsideVolType_ = outsideVolTypes[0]; + + // All processors (that have enough surface) will return the same + // status, all others will return UNKNOWN. Make INSIDE/OUTSIDE win. + outsideVolType_ = volumeType + ( + returnReduce + ( + label(outsideVolTypes[0]), + maxOp