mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
BUG: extrudeToRegionMesh: extruding cyclics
This commit is contained in:
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -67,6 +67,7 @@ void Foam::createShellMesh::syncEdges
|
|||||||
const labelList& patchEdges,
|
const labelList& patchEdges,
|
||||||
const labelList& coupledEdges,
|
const labelList& coupledEdges,
|
||||||
const PackedBoolList& sameEdgeOrientation,
|
const PackedBoolList& sameEdgeOrientation,
|
||||||
|
const bool syncNonCollocated,
|
||||||
|
|
||||||
PackedBoolList& isChangedEdge,
|
PackedBoolList& isChangedEdge,
|
||||||
DynamicList<label>& changedEdges,
|
DynamicList<label>& changedEdges,
|
||||||
@ -111,7 +112,11 @@ void Foam::createShellMesh::syncEdges
|
|||||||
(
|
(
|
||||||
cppEdgeData,
|
cppEdgeData,
|
||||||
globalData.globalEdgeSlaves(),
|
globalData.globalEdgeSlaves(),
|
||||||
globalData.globalEdgeTransformedSlaves(),
|
(
|
||||||
|
syncNonCollocated
|
||||||
|
? globalData.globalEdgeTransformedSlaves() // transformed elems
|
||||||
|
: labelListList(globalData.globalEdgeSlaves().size()) //no transformed
|
||||||
|
),
|
||||||
map,
|
map,
|
||||||
minEqOp<labelPair>()
|
minEqOp<labelPair>()
|
||||||
);
|
);
|
||||||
@ -150,6 +155,7 @@ void Foam::createShellMesh::calcPointRegions
|
|||||||
const globalMeshData& globalData,
|
const globalMeshData& globalData,
|
||||||
const primitiveFacePatch& patch,
|
const primitiveFacePatch& patch,
|
||||||
const PackedBoolList& nonManifoldEdge,
|
const PackedBoolList& nonManifoldEdge,
|
||||||
|
const bool syncNonCollocated,
|
||||||
|
|
||||||
faceList& pointGlobalRegions,
|
faceList& pointGlobalRegions,
|
||||||
faceList& pointLocalRegions,
|
faceList& pointLocalRegions,
|
||||||
@ -243,6 +249,7 @@ void Foam::createShellMesh::calcPointRegions
|
|||||||
patchEdges,
|
patchEdges,
|
||||||
coupledEdges,
|
coupledEdges,
|
||||||
sameEdgeOrientation,
|
sameEdgeOrientation,
|
||||||
|
syncNonCollocated,
|
||||||
|
|
||||||
isChangedEdge,
|
isChangedEdge,
|
||||||
changedEdges,
|
changedEdges,
|
||||||
@ -356,6 +363,7 @@ void Foam::createShellMesh::calcPointRegions
|
|||||||
patchEdges,
|
patchEdges,
|
||||||
coupledEdges,
|
coupledEdges,
|
||||||
sameEdgeOrientation,
|
sameEdgeOrientation,
|
||||||
|
syncNonCollocated,
|
||||||
|
|
||||||
isChangedEdge,
|
isChangedEdge,
|
||||||
changedEdges,
|
changedEdges,
|
||||||
@ -509,6 +517,7 @@ void Foam::createShellMesh::setRefinement
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Introduce original points
|
// Introduce original points
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
@ -525,12 +534,13 @@ void Foam::createShellMesh::setRefinement
|
|||||||
);
|
);
|
||||||
pointToPointMap.append(pointI);
|
pointToPointMap.append(pointI);
|
||||||
|
|
||||||
// Pout<< "Added bottom point " << pointToPointMap[pointI]
|
//Pout<< "Added bottom point " << addedPointI
|
||||||
// << " at " << patch_.localPoints()[pointI]
|
// << " at " << patch_.localPoints()[pointI]
|
||||||
// << " from point " << pointI
|
// << " from point " << pointI
|
||||||
// << endl;
|
// << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Introduce new points (one for every region)
|
// Introduce new points (one for every region)
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
@ -541,7 +551,6 @@ void Foam::createShellMesh::setRefinement
|
|||||||
|
|
||||||
point pt = patch_.localPoints()[pointI];
|
point pt = patch_.localPoints()[pointI];
|
||||||
point disp = firstLayerDisp[regionI];
|
point disp = firstLayerDisp[regionI];
|
||||||
|
|
||||||
for (label layerI = 0; layerI < nLayers; layerI++)
|
for (label layerI = 0; layerI < nLayers; layerI++)
|
||||||
{
|
{
|
||||||
pt += disp;
|
pt += disp;
|
||||||
@ -675,7 +684,7 @@ void Foam::createShellMesh::setRefinement
|
|||||||
{
|
{
|
||||||
FatalErrorIn("createShellMesh::setRefinement(..)")
|
FatalErrorIn("createShellMesh::setRefinement(..)")
|
||||||
<< "external/feature edge:" << edgeI
|
<< "external/feature edge:" << edgeI
|
||||||
<< " has " << eFaces.size() << " connected extruded faces"
|
<< " has " << eFaces.size() << " connected extruded faces "
|
||||||
<< " but only " << ePatches.size()
|
<< " but only " << ePatches.size()
|
||||||
<< " boundary faces defined." << exit(FatalError);
|
<< " boundary faces defined." << exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -88,6 +88,8 @@ class createShellMesh
|
|||||||
const labelList&,
|
const labelList&,
|
||||||
const labelList&,
|
const labelList&,
|
||||||
const PackedBoolList& sameEdgeOrientation,
|
const PackedBoolList& sameEdgeOrientation,
|
||||||
|
const bool syncNonCollocated,
|
||||||
|
|
||||||
PackedBoolList& isChangedEdge,
|
PackedBoolList& isChangedEdge,
|
||||||
DynamicList<label>& changedEdges,
|
DynamicList<label>& changedEdges,
|
||||||
labelPairList& allEdgeData
|
labelPairList& allEdgeData
|
||||||
@ -160,6 +162,8 @@ public:
|
|||||||
// same on all faces connected to a point if they can be
|
// same on all faces connected to a point if they can be
|
||||||
// reached through a face-edge-face walk without crossing
|
// reached through a face-edge-face walk without crossing
|
||||||
// the nonManifoldEdge.
|
// the nonManifoldEdge.
|
||||||
|
// syncNonCollocated = true: edges connected through cyclic become
|
||||||
|
// single region. false: kept separate.
|
||||||
// pointGlobalRegions : non-compact. Guaranteed to be the same
|
// pointGlobalRegions : non-compact. Guaranteed to be the same
|
||||||
// across processors.
|
// across processors.
|
||||||
// pointLocalRegions : compact.
|
// pointLocalRegions : compact.
|
||||||
@ -169,6 +173,7 @@ public:
|
|||||||
const globalMeshData& globalData,
|
const globalMeshData& globalData,
|
||||||
const primitiveFacePatch& patch,
|
const primitiveFacePatch& patch,
|
||||||
const PackedBoolList& nonManifoldEdge,
|
const PackedBoolList& nonManifoldEdge,
|
||||||
|
const bool syncNonCollocated,
|
||||||
faceList& pointGlobalRegions,
|
faceList& pointGlobalRegions,
|
||||||
faceList& pointLocalRegions,
|
faceList& pointLocalRegions,
|
||||||
labelList& localToGlobalRegion
|
labelList& localToGlobalRegion
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -102,6 +102,13 @@ becomes
|
|||||||
BBB=mapped between original mesh and new extrusion
|
BBB=mapped between original mesh and new extrusion
|
||||||
CCC=polypatch
|
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"
|
#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
|
// Calculate per edge min and max zone
|
||||||
void calcEdgeMinMaxZone
|
void calcEdgeMinMaxZone
|
||||||
(
|
(
|
||||||
@ -1288,12 +1331,13 @@ void addCouplingPatches
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Sets sidePatch[edgeI] to interprocessor patch. Adds any
|
// Sets sidePatch[edgeI] to interprocessor or cyclic patch. Adds any
|
||||||
// interprocessor patches if necessary.
|
// coupled patches if necessary.
|
||||||
void addProcPatches
|
void addCoupledPatches
|
||||||
(
|
(
|
||||||
const fvMesh& mesh,
|
const fvMesh& mesh,
|
||||||
const primitiveFacePatch& extrudePatch,
|
const primitiveFacePatch& extrudePatch,
|
||||||
|
const labelList& extrudeMeshFaces,
|
||||||
const labelList& extrudeMeshEdges,
|
const labelList& extrudeMeshEdges,
|
||||||
const mapDistribute& extrudeEdgeFacesMap,
|
const mapDistribute& extrudeEdgeFacesMap,
|
||||||
const labelListList& extrudeEdgeGlobalFaces,
|
const labelListList& extrudeEdgeGlobalFaces,
|
||||||
@ -1342,7 +1386,7 @@ void addProcPatches
|
|||||||
labelMin // null value
|
labelMin // null value
|
||||||
);
|
);
|
||||||
|
|
||||||
Pout<< "Adding inter-processor patches:" << nl << nl
|
Pout<< "Adding processor or cyclic patches:" << nl << nl
|
||||||
<< "patchID\tpatch" << nl
|
<< "patchID\tpatch" << nl
|
||||||
<< "-------\t-----"
|
<< "-------\t-----"
|
||||||
<< endl;
|
<< endl;
|
||||||
@ -1367,35 +1411,84 @@ void addProcPatches
|
|||||||
nbrProcI = maxProcID[edgeI];
|
nbrProcI = maxProcID[edgeI];
|
||||||
}
|
}
|
||||||
|
|
||||||
word name =
|
|
||||||
"procBoundary"
|
|
||||||
+ Foam::name(Pstream::myProcNo())
|
|
||||||
+ "to"
|
|
||||||
+ Foam::name(nbrProcI);
|
|
||||||
|
|
||||||
sidePatchID[edgeI] = findPatchID(newPatches, name);
|
if (nbrProcI == Pstream::myProcNo())
|
||||||
|
|
||||||
if (sidePatchID[edgeI] == -1)
|
|
||||||
{
|
{
|
||||||
dictionary patchDict;
|
// Cyclic patch since both procs the same. This cyclic should
|
||||||
patchDict.add("myProcNo", Pstream::myProcNo());
|
// already exist in newPatches so no adding necessary.
|
||||||
patchDict.add("neighbProcNo", nbrProcI);
|
|
||||||
|
|
||||||
sidePatchID[edgeI] = addPatch<processorPolyPatch>
|
label faceI = findUncoveredCyclicPatchFace
|
||||||
(
|
(
|
||||||
mesh.boundaryMesh(),
|
mesh,
|
||||||
name,
|
UIndirectList<label>(extrudeMeshFaces, eFaces),
|
||||||
patchDict,
|
extrudeMeshEdges[edgeI]
|
||||||
newPatches
|
|
||||||
);
|
);
|
||||||
|
|
||||||
Pout<< sidePatchID[edgeI] << '\t' << name
|
if (faceI != -1)
|
||||||
<< nl;
|
{
|
||||||
|
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
|
Pout<< "Added " << newPatches.size()-nOldPatches
|
||||||
<< " inter-processor patches." << nl
|
<< " coupled patches." << nl
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2251,12 +2344,13 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
|
|
||||||
// Sets sidePatchID[edgeI] to interprocessor patch. Adds any
|
// Sets sidePatchID[edgeI] to interprocessor patch. Adds any
|
||||||
// interprocessor patches if necessary.
|
// interprocessor or cyclic patches if necessary.
|
||||||
labelList sidePatchID;
|
labelList sidePatchID;
|
||||||
addProcPatches
|
addCoupledPatches
|
||||||
(
|
(
|
||||||
mesh,
|
mesh,
|
||||||
extrudePatch,
|
extrudePatch,
|
||||||
|
extrudeMeshFaces,
|
||||||
extrudeMeshEdges,
|
extrudeMeshEdges,
|
||||||
extrudeEdgeFacesMap,
|
extrudeEdgeFacesMap,
|
||||||
extrudeEdgeGlobalFaces,
|
extrudeEdgeGlobalFaces,
|
||||||
@ -2409,6 +2503,7 @@ int main(int argc, char *argv[])
|
|||||||
mesh.globalData(),
|
mesh.globalData(),
|
||||||
extrudePatch,
|
extrudePatch,
|
||||||
nonManifoldEdge,
|
nonManifoldEdge,
|
||||||
|
false, // keep cyclic separated regions apart
|
||||||
|
|
||||||
pointGlobalRegions,
|
pointGlobalRegions,
|
||||||
pointLocalRegions,
|
pointLocalRegions,
|
||||||
@ -2431,7 +2526,6 @@ int main(int argc, char *argv[])
|
|||||||
pointField localRegionNormals(localToGlobalRegion.size());
|
pointField localRegionNormals(localToGlobalRegion.size());
|
||||||
{
|
{
|
||||||
pointField localSum(localToGlobalRegion.size(), vector::zero);
|
pointField localSum(localToGlobalRegion.size(), vector::zero);
|
||||||
labelList localNum(localToGlobalRegion.size(), 0);
|
|
||||||
|
|
||||||
forAll(pointLocalRegions, faceI)
|
forAll(pointLocalRegions, faceI)
|
||||||
{
|
{
|
||||||
@ -2440,32 +2534,25 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
label localRegionI = pRegions[fp];
|
label localRegionI = pRegions[fp];
|
||||||
localSum[localRegionI] += extrudePatch.faceNormals()[faceI];
|
localSum[localRegionI] += extrudePatch.faceNormals()[faceI];
|
||||||
localNum[localRegionI]++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<point> globalSum(2*localToGlobalRegion.size());
|
Map<point> globalSum(2*localToGlobalRegion.size());
|
||||||
Map<label> globalNum(2*localToGlobalRegion.size());
|
|
||||||
|
|
||||||
forAll(localSum, localRegionI)
|
forAll(localSum, localRegionI)
|
||||||
{
|
{
|
||||||
label globalRegionI = localToGlobalRegion[localRegionI];
|
label globalRegionI = localToGlobalRegion[localRegionI];
|
||||||
globalSum.insert(globalRegionI, localSum[localRegionI]);
|
globalSum.insert(globalRegionI, localSum[localRegionI]);
|
||||||
globalNum.insert(globalRegionI, localNum[localRegionI]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reduce
|
// Reduce
|
||||||
Pstream::mapCombineGather(globalSum, plusEqOp<point>());
|
Pstream::mapCombineGather(globalSum, plusEqOp<point>());
|
||||||
Pstream::mapCombineScatter(globalSum);
|
Pstream::mapCombineScatter(globalSum);
|
||||||
Pstream::mapCombineGather(globalNum, plusEqOp<label>());
|
|
||||||
Pstream::mapCombineScatter(globalNum);
|
|
||||||
|
|
||||||
forAll(localToGlobalRegion, localRegionI)
|
forAll(localToGlobalRegion, localRegionI)
|
||||||
{
|
{
|
||||||
label globalRegionI = localToGlobalRegion[localRegionI];
|
label globalRegionI = localToGlobalRegion[localRegionI];
|
||||||
localRegionNormals[localRegionI] =
|
localRegionNormals[localRegionI] = globalSum[globalRegionI];
|
||||||
globalSum[globalRegionI]
|
|
||||||
/ globalNum[globalRegionI];
|
|
||||||
}
|
}
|
||||||
localRegionNormals /= mag(localRegionNormals);
|
localRegionNormals /= mag(localRegionNormals);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user