diff --git a/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/createShellMesh/createShellMesh.C b/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/createShellMesh/createShellMesh.C index 13aefeac1060812e0264e8b87e2c7606bf254e96..7da1a844b7ff94e7cb859879bf93406d59409ab0 100644 --- a/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/createShellMesh/createShellMesh.C +++ b/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/createShellMesh/createShellMesh.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -67,6 +67,7 @@ void Foam::createShellMesh::syncEdges const labelList& patchEdges, const labelList& coupledEdges, const PackedBoolList& sameEdgeOrientation, + const bool syncNonCollocated, PackedBoolList& isChangedEdge, DynamicList<label>& changedEdges, @@ -111,7 +112,11 @@ void Foam::createShellMesh::syncEdges ( cppEdgeData, globalData.globalEdgeSlaves(), - globalData.globalEdgeTransformedSlaves(), + ( + syncNonCollocated + ? globalData.globalEdgeTransformedSlaves() // transformed elems + : labelListList(globalData.globalEdgeSlaves().size()) //no transformed + ), map, minEqOp<labelPair>() ); @@ -150,6 +155,7 @@ void Foam::createShellMesh::calcPointRegions const globalMeshData& globalData, const primitiveFacePatch& patch, const PackedBoolList& nonManifoldEdge, + const bool syncNonCollocated, faceList& pointGlobalRegions, faceList& pointLocalRegions, @@ -243,6 +249,7 @@ void Foam::createShellMesh::calcPointRegions patchEdges, coupledEdges, sameEdgeOrientation, + syncNonCollocated, isChangedEdge, changedEdges, @@ -356,6 +363,7 @@ void Foam::createShellMesh::calcPointRegions patchEdges, coupledEdges, sameEdgeOrientation, + syncNonCollocated, isChangedEdge, changedEdges, @@ -509,6 +517,7 @@ void Foam::createShellMesh::setRefinement } } + // Introduce original points // ~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -525,12 +534,13 @@ void Foam::createShellMesh::setRefinement ); pointToPointMap.append(pointI); -// Pout<< "Added bottom point " << pointToPointMap[pointI] -// << " at " << patch_.localPoints()[pointI] -// << " from point " << pointI -// << endl; + //Pout<< "Added bottom point " << addedPointI + // << " at " << patch_.localPoints()[pointI] + // << " from point " << pointI + // << endl; } + // Introduce new points (one for every region) // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -541,7 +551,6 @@ void Foam::createShellMesh::setRefinement point pt = patch_.localPoints()[pointI]; point disp = firstLayerDisp[regionI]; - for (label layerI = 0; layerI < nLayers; layerI++) { pt += disp; @@ -675,7 +684,7 @@ void Foam::createShellMesh::setRefinement { FatalErrorIn("createShellMesh::setRefinement(..)") << "external/feature edge:" << edgeI - << " has " << eFaces.size() << " connected extruded faces" + << " has " << eFaces.size() << " connected extruded faces " << " but only " << ePatches.size() << " boundary faces defined." << exit(FatalError); } diff --git a/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/createShellMesh/createShellMesh.H b/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/createShellMesh/createShellMesh.H index 7517a956df1dc16d241bb26cdc221a8c0281371f..df1e000be8c90a46ee3391b4a601d669215ef5dc 100644 --- a/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/createShellMesh/createShellMesh.H +++ b/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/createShellMesh/createShellMesh.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -88,6 +88,8 @@ class createShellMesh const labelList&, const labelList&, const PackedBoolList& sameEdgeOrientation, + const bool syncNonCollocated, + PackedBoolList& isChangedEdge, DynamicList<label>& changedEdges, labelPairList& allEdgeData @@ -160,6 +162,8 @@ public: // same on all faces connected to a point if they can be // reached through a face-edge-face walk without crossing // the nonManifoldEdge. + // syncNonCollocated = true: edges connected through cyclic become + // single region. false: kept separate. // pointGlobalRegions : non-compact. Guaranteed to be the same // across processors. // pointLocalRegions : compact. @@ -169,6 +173,7 @@ public: const globalMeshData& globalData, const primitiveFacePatch& patch, const PackedBoolList& nonManifoldEdge, + const bool syncNonCollocated, faceList& pointGlobalRegions, faceList& pointLocalRegions, labelList& localToGlobalRegion diff --git a/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/extrudeToRegionMesh.C b/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/extrudeToRegionMesh.C index b32c249e7c201c96e633d75e0163ef32b905e3d9..ff4780b65b68dc76ae6b10382bb352938bd1564b 100644 --- a/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/extrudeToRegionMesh.C +++ b/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/extrudeToRegionMesh.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -102,6 +102,13 @@ becomes BBB=mapped between original mesh and new extrusion CCC=polypatch + +Notes: + - when extruding cyclics with only one cell inbetween it does not + detect this as a cyclic since the face is the same face. It will + only work if the coupled edge extrudes a different face so if there + are more than 1 cell inbetween. + \*---------------------------------------------------------------------------*/ #include "argList.H" @@ -1032,6 +1039,42 @@ label findUncoveredPatchFace } +// Same as findUncoveredPatchFace, except explicitly checks for cyclic faces +label findUncoveredCyclicPatchFace +( + const fvMesh& mesh, + const UIndirectList<label>& extrudeMeshFaces,// mesh faces that are extruded + const label meshEdgeI // mesh edge +) +{ + // Make set of extruded faces. + labelHashSet extrudeFaceSet(extrudeMeshFaces.size()); + forAll(extrudeMeshFaces, i) + { + extrudeFaceSet.insert(extrudeMeshFaces[i]); + } + + const polyBoundaryMesh& pbm = mesh.boundaryMesh(); + const labelList& eFaces = mesh.edgeFaces()[meshEdgeI]; + forAll(eFaces, i) + { + label faceI = eFaces[i]; + label patchI = pbm.whichPatch(faceI); + + if + ( + patchI != -1 + && isA<cyclicPolyPatch>(pbm[patchI]) + && !extrudeFaceSet.found(faceI) + ) + { + return faceI; + } + } + return -1; +} + + // Calculate per edge min and max zone void calcEdgeMinMaxZone ( @@ -1288,12 +1331,13 @@ void addCouplingPatches } -// Sets sidePatch[edgeI] to interprocessor patch. Adds any -// interprocessor patches if necessary. -void addProcPatches +// Sets sidePatch[edgeI] to interprocessor or cyclic patch. Adds any +// coupled patches if necessary. +void addCoupledPatches ( const fvMesh& mesh, const primitiveFacePatch& extrudePatch, + const labelList& extrudeMeshFaces, const labelList& extrudeMeshEdges, const mapDistribute& extrudeEdgeFacesMap, const labelListList& extrudeEdgeGlobalFaces, @@ -1342,7 +1386,7 @@ void addProcPatches labelMin // null value ); - Pout<< "Adding inter-processor patches:" << nl << nl + Pout<< "Adding processor or cyclic patches:" << nl << nl << "patchID\tpatch" << nl << "-------\t-----" << endl; @@ -1367,35 +1411,84 @@ void addProcPatches nbrProcI = maxProcID[edgeI]; } - word name = - "procBoundary" - + Foam::name(Pstream::myProcNo()) - + "to" - + Foam::name(nbrProcI); - - sidePatchID[edgeI] = findPatchID(newPatches, name); - if (sidePatchID[edgeI] == -1) + if (nbrProcI == Pstream::myProcNo()) { - dictionary patchDict; - patchDict.add("myProcNo", Pstream::myProcNo()); - patchDict.add("neighbProcNo", nbrProcI); + // Cyclic patch since both procs the same. This cyclic should + // already exist in newPatches so no adding necessary. - sidePatchID[edgeI] = addPatch<processorPolyPatch> + label faceI = findUncoveredCyclicPatchFace ( - mesh.boundaryMesh(), - name, - patchDict, - newPatches + mesh, + UIndirectList<label>(extrudeMeshFaces, eFaces), + extrudeMeshEdges[edgeI] ); - Pout<< sidePatchID[edgeI] << '\t' << name - << nl; + if (faceI != -1) + { + const polyBoundaryMesh& patches = mesh.boundaryMesh(); + + label newPatchI = findPatchID + ( + newPatches, + patches[patches.whichPatch(faceI)].name() + ); + + sidePatchID[edgeI] = newPatchI; + } + else + { + FatalErrorIn + ( + "void addCoupledPatches" + "(" + "const fvMesh&, " + "const primitiveFacePatch&, " + "const labelList&, " + "const labelList&, " + "const mapDistribute&, " + "const labelListList&, " + "labelList&, " + "DynamicList<polyPatch*>&" + ")" + ) << "Unable to determine coupled patch addressing" + << abort(FatalError); + } + } + else + { + // Rrocessor patch + + word name = + "procBoundary" + + Foam::name(Pstream::myProcNo()) + + "to" + + Foam::name(nbrProcI); + + sidePatchID[edgeI] = findPatchID(newPatches, name); + + if (sidePatchID[edgeI] == -1) + { + dictionary patchDict; + patchDict.add("myProcNo", Pstream::myProcNo()); + patchDict.add("neighbProcNo", nbrProcI); + + sidePatchID[edgeI] = addPatch<processorPolyPatch> + ( + mesh.boundaryMesh(), + name, + patchDict, + newPatches + ); + + Pout<< sidePatchID[edgeI] << '\t' << name + << nl; + } } } } Pout<< "Added " << newPatches.size()-nOldPatches - << " inter-processor patches." << nl + << " coupled patches." << nl << endl; } @@ -2251,12 +2344,13 @@ int main(int argc, char *argv[]) // Sets sidePatchID[edgeI] to interprocessor patch. Adds any - // interprocessor patches if necessary. + // interprocessor or cyclic patches if necessary. labelList sidePatchID; - addProcPatches + addCoupledPatches ( mesh, extrudePatch, + extrudeMeshFaces, extrudeMeshEdges, extrudeEdgeFacesMap, extrudeEdgeGlobalFaces, @@ -2409,6 +2503,7 @@ int main(int argc, char *argv[]) mesh.globalData(), extrudePatch, nonManifoldEdge, + false, // keep cyclic separated regions apart pointGlobalRegions, pointLocalRegions, @@ -2431,7 +2526,6 @@ int main(int argc, char *argv[]) pointField localRegionNormals(localToGlobalRegion.size()); { pointField localSum(localToGlobalRegion.size(), vector::zero); - labelList localNum(localToGlobalRegion.size(), 0); forAll(pointLocalRegions, faceI) { @@ -2440,32 +2534,25 @@ int main(int argc, char *argv[]) { label localRegionI = pRegions[fp]; localSum[localRegionI] += extrudePatch.faceNormals()[faceI]; - localNum[localRegionI]++; } } Map<point> globalSum(2*localToGlobalRegion.size()); - Map<label> globalNum(2*localToGlobalRegion.size()); forAll(localSum, localRegionI) { label globalRegionI = localToGlobalRegion[localRegionI]; globalSum.insert(globalRegionI, localSum[localRegionI]); - globalNum.insert(globalRegionI, localNum[localRegionI]); } // Reduce Pstream::mapCombineGather(globalSum, plusEqOp<point>()); Pstream::mapCombineScatter(globalSum); - Pstream::mapCombineGather(globalNum, plusEqOp<label>()); - Pstream::mapCombineScatter(globalNum); forAll(localToGlobalRegion, localRegionI) { label globalRegionI = localToGlobalRegion[localRegionI]; - localRegionNormals[localRegionI] = - globalSum[globalRegionI] - / globalNum[globalRegionI]; + localRegionNormals[localRegionI] = globalSum[globalRegionI]; } localRegionNormals /= mag(localRegionNormals); }