Skip to content
Snippets Groups Projects
Commit 10c2e2fa authored by laurence's avatar laurence
Browse files

BUG: extendedFeatureEdgeMesh: Replace slow algorithm for featurePointFeatureEdges

and prevent a divide by zero
parent f0784197
Branches
Tags
No related merge requests found
...@@ -2,7 +2,7 @@ ...@@ -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-2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
...@@ -59,14 +59,14 @@ void Foam::extendedFeatureEdgeMesh::sortPointsAndEdges ...@@ -59,14 +59,14 @@ void Foam::extendedFeatureEdgeMesh::sortPointsAndEdges
DynamicList<vector> norms; DynamicList<vector> norms;
vectorField edgeDirections(nFeatEds); vectorField edgeDirections(nFeatEds);
labelListList edgeNormals(nFeatEds); labelListList edgeNormals(nFeatEds);
labelListList normalDirections(nFeatEds);
DynamicList<label> regionEdges; DynamicList<label> regionEdges;
// Keep track of the ordered feature point feature edges // Keep track of the ordered feature point feature edges
labelListList featurePointFeatureEdges(nFeatPts); labelListList featurePointFeatureEdges(nFeatPts);
forAll(featurePointFeatureEdges, pI) forAll(featurePointFeatureEdges, pI)
{ {
featurePointFeatureEdges[pI] = featurePointFeatureEdges[pI] = pointEdges[featurePoints[pI]];
labelList(pointEdges[featurePoints[pI]].size(), -1);
} }
// Mapping between old and new indices, there is entry in the map for each // Mapping between old and new indices, there is entry in the map for each
...@@ -74,6 +74,10 @@ void Foam::extendedFeatureEdgeMesh::sortPointsAndEdges ...@@ -74,6 +74,10 @@ void Foam::extendedFeatureEdgeMesh::sortPointsAndEdges
// >= 0 corresponds to the index // >= 0 corresponds to the index
labelList pointMap(sFeatLocalPts.size(), -1); labelList pointMap(sFeatLocalPts.size(), -1);
// Mapping between surface edge index and its feature edge index. -1 if it
// is not a feature edge
labelList edgeMap(sFeatEds.size(), -1);
// Noting when the normal of a face has been used so not to duplicate // Noting when the normal of a face has been used so not to duplicate
labelList faceMap(surf.size(), -1); labelList faceMap(surf.size(), -1);
...@@ -98,7 +102,11 @@ void Foam::extendedFeatureEdgeMesh::sortPointsAndEdges ...@@ -98,7 +102,11 @@ void Foam::extendedFeatureEdgeMesh::sortPointsAndEdges
{ {
label sFEI = featureEdges[i]; label sFEI = featureEdges[i];
const edge& fE(sFeatEds[sFEI]); edgeMap[sFEI] = i;
const edge& fE = sFeatEds[sFEI];
edgeDirections[i] = fE.vec(sFeatLocalPts);
// Check to see if the points have been already used // Check to see if the points have been already used
if (pointMap[fE.start()] == -1) if (pointMap[fE.start()] == -1)
...@@ -150,51 +158,37 @@ void Foam::extendedFeatureEdgeMesh::sortPointsAndEdges ...@@ -150,51 +158,37 @@ void Foam::extendedFeatureEdgeMesh::sortPointsAndEdges
edStatus[i] = classifyEdge(norms, edgeNormals[i], fC0tofC1); edStatus[i] = classifyEdge(norms, edgeNormals[i], fC0tofC1);
edgeDirections[i] = fE.vec(sFeatLocalPts);
if (isRegionFeatureEdge[i]) if (isRegionFeatureEdge[i])
{ {
regionEdges.append(i); regionEdges.append(i);
} }
forAll(featurePointFeatureEdges, pI)
{
const labelList& fpfEdges = pointEdges[featurePoints[pI]];
labelList& fpfe = featurePointFeatureEdges[pI];
forAll(fpfEdges, eI)
{
if (sFEI == fpfEdges[eI])
{
fpfe[eI] = i;
}
}
}
} }
// Populate feature point feature edges
DynamicList<label> newFeatureEdges;
forAll(featurePointFeatureEdges, pI) forAll(featurePointFeatureEdges, pI)
{ {
const labelList& fpfe = featurePointFeatureEdges[pI]; const labelList& fpfe = featurePointFeatureEdges[pI];
DynamicList<label> newFeatureEdges(fpfe.size()); newFeatureEdges.setCapacity(fpfe.size());
forAll(fpfe, eI) forAll(fpfe, eI)
{ {
const label edgeIndex = fpfe[eI]; const label oldEdgeIndex = fpfe[eI];
const label newEdgeIndex = edgeMap[oldEdgeIndex];
if (edgeIndex != -1) if (newEdgeIndex != -1)
{ {
newFeatureEdges.append(edgeIndex); newFeatureEdges.append(newEdgeIndex);
} }
} }
featurePointFeatureEdges[pI] = newFeatureEdges; featurePointFeatureEdges[pI].transfer(newFeatureEdges);
} }
// Reorder the edges by classification // Reorder the edges by classification
List<DynamicList<label> > allEds(nEdgeTypes); List<DynamicList<label> > allEds(nEdgeTypes);
DynamicList<label>& externalEds(allEds[0]); DynamicList<label>& externalEds(allEds[0]);
...@@ -277,7 +271,8 @@ void Foam::extendedFeatureEdgeMesh::sortPointsAndEdges ...@@ -277,7 +271,8 @@ void Foam::extendedFeatureEdgeMesh::sortPointsAndEdges
edgeMesh::operator=(edgeMesh(pts, eds)); edgeMesh::operator=(edgeMesh(pts, eds));
// Initialise sorted edge related data // Initialise sorted edge related data
edgeDirections_ = edgeDirections/mag(edgeDirections); edgeDirections_ = edgeDirections/(mag(edgeDirections) + VSMALL);
edgeNormals_ = edgeNormals; edgeNormals_ = edgeNormals;
regionEdges_ = regionEdges; regionEdges_ = regionEdges;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment