extrudeToRegionMesh: Fixed issues associated with extruding from baffles

This commit is contained in:
Will Bainbridge
2022-10-18 16:13:35 +01:00
parent 4c6a469a5a
commit cd7405e30a

View File

@ -531,115 +531,6 @@ label findUncoveredCyclicPatchFace
} }
// Calculate per extruded edge the zoneID. Set a dummy value if the edge is in
// multiple zones. Also check that no edge is extruded between an internal face
// zone and a boundary face zone.
labelList calcExtrudeEdgeZoneID
(
const fvMesh& mesh,
const primitiveFacePatch& extrudePatch,
const labelList& extrudeFaces,
const labelList& extrudeFaceZoneIDs,
const labelList& extrudeEdgeMeshEdges,
const distributionMap& extrudeEdgeFacesMap,
const labelListList& extrudeEdgeGlobalFaces
)
{
static label noZoneID = labelMin;
static label multipleZoneID = labelMax;
// Get zoneIDs and isInternal in extrudeEdgeGlobalFaces order
labelList mappedZoneID(extrudeFaceZoneIDs);
extrudeEdgeFacesMap.distribute(mappedZoneID);
boolList mappedIsInternalFace(extrudePatch.size());
forAll(extrudeFaces, facei)
{
mappedIsInternalFace[facei] = mesh.isInternalFace(extrudeFaces[facei]);
}
extrudeEdgeFacesMap.distribute(mappedIsInternalFace);
// Zone ID and connectivity per edge
labelList extrudeEdgeZoneID
(
extrudeEdgeGlobalFaces.size(),
noZoneID
);
List<connectivity> extrudeEdgeConnectivity
(
extrudeEdgeGlobalFaces.size(),
connectivity::unset
);
// Set operator. Set the zone if the same or unset. Set the multiple zone
// ID if the edge already has a different zone.
auto eqOp = [](label& x, const label y)
{
x = x == y || x == noZoneID ? y : multipleZoneID;
};
forAll(extrudeEdgeGlobalFaces, edgei)
{
const labelList& eFaces = extrudeEdgeGlobalFaces[edgei];
if (eFaces.size())
{
forAll(eFaces, i)
{
eqOp(extrudeEdgeZoneID[edgei], mappedZoneID[eFaces[i]]);
isInternalEqOp()
(
extrudeEdgeConnectivity[edgei],
mappedIsInternalFace[eFaces[i]]
? connectivity::internal
: connectivity::boundary
);
}
}
}
syncTools::syncEdgeList
(
mesh,
extrudeEdgeMeshEdges,
extrudeEdgeZoneID,
eqOp,
noZoneID
);
syncTools::syncEdgeList
(
mesh,
extrudeEdgeMeshEdges,
extrudeEdgeConnectivity,
isInternalEqOp(),
connectivity::unset,
[]
(
const transformer& vt,
const bool forward,
List<connectivity>& fld
)
{}
);
forAll(extrudeEdgeConnectivity, edgei)
{
if (extrudeEdgeConnectivity[edgei] == connectivity::error)
{
FatalErrorInFunction
<< "Extruded edge "
<< extrudePatch.edges()[edgei].line(extrudePatch.localPoints())
<< " is connected to both internal and boundary faces."
<< " This is not allowed."
<< exit(FatalError);
}
}
return extrudeEdgeZoneID;
}
// Add coupled patches into the mesh // Add coupled patches into the mesh
void addCouplingPatches void addCouplingPatches
( (
@ -764,9 +655,9 @@ labelList countExtrudePatches
const label nZones, const label nZones,
const primitiveFacePatch& extrudePatch, const primitiveFacePatch& extrudePatch,
const labelList& extrudeFaces, const labelList& extrudeFaces,
const labelList& extrudeFaceZoneIDs,
const labelList& extrudeEdgeMeshEdges, const labelList& extrudeEdgeMeshEdges,
const labelListList& extrudeEdgeGlobalFaces, const labelListList& extrudeEdgeGlobalFaces
const labelList& extrudeEdgeZoneID
) )
{ {
labelList zoneSideNFaces(nZones, 0); labelList zoneSideNFaces(nZones, 0);
@ -801,7 +692,11 @@ labelList countExtrudePatches
if (facei == -1) if (facei == -1)
{ {
zoneSideNFaces[extrudeEdgeZoneID[edgeI]]++; forAll(extrudePatch.edgeFaces()[edgeI], i)
{
const label facei = extrudePatch.edgeFaces()[edgeI][i];
zoneSideNFaces[extrudeFaceZoneIDs[facei]] ++;
}
} }
} }
} }
@ -1410,21 +1305,6 @@ int main(int argc, char *argv[])
compactMap compactMap
); );
// Determine zone for each extruded edge
const labelList extrudeEdgeZoneID
(
calcExtrudeEdgeZoneID
(
mesh,
extrudePatch,
extrudeFaces,
extrudeFaceZoneIDs,
extrudeEdgeMeshEdges,
extrudeEdgeFacesMap,
extrudeEdgeGlobalFaces
)
);
// Copy all non-local patches since these are used on boundary edges of // Copy all non-local patches since these are used on boundary edges of
// the extrusion // the extrusion
@ -1546,9 +1426,9 @@ int main(int argc, char *argv[])
zoneNames.size(), zoneNames.size(),
extrudePatch, // patch extrudePatch, // patch
extrudeFaces, // mesh face per patch face extrudeFaces, // mesh face per patch face
extrudeFaceZoneIDs, // ...
extrudeEdgeMeshEdges, // mesh edge per patch edge extrudeEdgeMeshEdges, // mesh edge per patch edge
extrudeEdgeGlobalFaces, // global indexing per patch edge extrudeEdgeGlobalFaces // global indexing per patch edge
extrudeEdgeZoneID // zone per patch edge
) )
); );
@ -1666,6 +1546,7 @@ int main(int argc, char *argv[])
zoneSidePatches[extrudeFaceZoneIDs[eFaces[i]]]; zoneSidePatches[extrudeFaceZoneIDs[eFaces[i]]];
} }
} }
nonManifoldEdge[edgeI] = true; nonManifoldEdge[edgeI] = true;
} }
} }
@ -1713,8 +1594,21 @@ int main(int argc, char *argv[])
const face& pRegions = pointLocalRegions[facei]; const face& pRegions = pointLocalRegions[facei];
forAll(pRegions, fp) forAll(pRegions, fp)
{ {
label localRegionI = pRegions[fp]; const label localRegionI = pRegions[fp];
localSum[localRegionI] += extrudePatch.faceNormals()[facei];
// Add a small amount of the face-centre-to-point vector in
// order to stabilise the computation of normals on the edges
// of baffles
localSum[localRegionI] +=
rootSmall
*(
extrudePatch.points()[extrudePatch[facei][fp]]
- extrudePatch.faceCentres()[facei]
)
+ (1 - rootSmall)
*(
extrudePatch.faceNormals()[facei]
);
} }
} }
@ -1735,7 +1629,7 @@ int main(int argc, char *argv[])
label globalRegionI = localToGlobalRegion[localRegionI]; label globalRegionI = localToGlobalRegion[localRegionI];
localRegionNormals[localRegionI] = globalSum[globalRegionI]; localRegionNormals[localRegionI] = globalSum[globalRegionI];
} }
localRegionNormals /= mag(localRegionNormals); localRegionNormals /= mag(localRegionNormals) ;
} }