BUG: extrudeToRegionMesh: extruding cyclics

This commit is contained in:
mattijs 2012-03-15 15:41:05 +00:00
parent a70398ae2c
commit 7b5fec3361
3 changed files with 145 additions and 44 deletions

View File

@ -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);
}

View File

@ -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

View File

@ -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);
}