mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: collapseEdges: parallel operation of mergeEdges
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) 2012 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -50,6 +50,7 @@ Description
|
|||||||
#include "PointEdgeWave.H"
|
#include "PointEdgeWave.H"
|
||||||
#include "pointEdgeCollapse.H"
|
#include "pointEdgeCollapse.H"
|
||||||
#include "motionSmoother.H"
|
#include "motionSmoother.H"
|
||||||
|
#include "removePoints.H"
|
||||||
|
|
||||||
using namespace Foam;
|
using namespace Foam;
|
||||||
|
|
||||||
@ -788,51 +789,61 @@ label mergeEdges
|
|||||||
labelList& collapseEdge
|
labelList& collapseEdge
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const pointField& points = mesh.points();
|
|
||||||
const edgeList& edges = mesh.edges();
|
const edgeList& edges = mesh.edges();
|
||||||
const labelListList& pointEdges = mesh.pointEdges();
|
const labelListList& pointEdges = mesh.pointEdges();
|
||||||
|
|
||||||
|
// Point removal engine
|
||||||
|
removePoints pointRemover(mesh, false);
|
||||||
|
|
||||||
|
// Find out points that can be deleted
|
||||||
|
boolList pointCanBeDeleted;
|
||||||
|
label nTotRemove = pointRemover.countPointUsage(maxCos, pointCanBeDeleted);
|
||||||
|
|
||||||
|
|
||||||
|
// Rework point-to-remove into edge-to-collapse.
|
||||||
|
|
||||||
label nCollapsed = 0;
|
label nCollapsed = 0;
|
||||||
|
|
||||||
forAll(pointEdges, pointI)
|
if (nTotRemove > 0)
|
||||||
{
|
{
|
||||||
const labelList& pEdges = pointEdges[pointI];
|
forAll(pointEdges, pointI)
|
||||||
|
|
||||||
if (pEdges.size() == 2 && boundaryPoint[pointI] <= 0)
|
|
||||||
{
|
{
|
||||||
// Collapse only if none of the points part of merge network and
|
if (pointCanBeDeleted[pointI])
|
||||||
// none protected (minEdgeLen < 0)
|
|
||||||
label e0 = pEdges[0];
|
|
||||||
label e1 = pEdges[1];
|
|
||||||
|
|
||||||
if
|
|
||||||
(
|
|
||||||
collapseEdge[e0] == -1
|
|
||||||
&& minEdgeLen[e0] >= 0
|
|
||||||
&& collapseEdge[e1] == -1
|
|
||||||
&& minEdgeLen[e1] >= 0
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
const edge& leftE = edges[e0];
|
const labelList& pEdges = pointEdges[pointI];
|
||||||
const edge& rightE = edges[e1];
|
|
||||||
|
|
||||||
// Get the two vertices on both sides of the point
|
if (pEdges.size() == 2)
|
||||||
label leftV = leftE.otherVertex(pointI);
|
|
||||||
label rightV = rightE.otherVertex(pointI);
|
|
||||||
|
|
||||||
// Check if the two edge are in line
|
|
||||||
vector leftVec = points[pointI] - points[leftV];
|
|
||||||
leftVec /= mag(leftVec) + VSMALL;
|
|
||||||
|
|
||||||
vector rightVec = points[rightV] - points[pointI];
|
|
||||||
rightVec /= mag(rightVec) + VSMALL;
|
|
||||||
|
|
||||||
if ((leftVec & rightVec) > maxCos)
|
|
||||||
{
|
{
|
||||||
// Collapse one (left) side of the edge. Make pointI
|
// Always the case?
|
||||||
// the master.
|
|
||||||
collapseEdge[e0] = findIndex(leftE, pointI);
|
label e0 = pEdges[0];
|
||||||
nCollapsed++;
|
label e1 = pEdges[1];
|
||||||
|
|
||||||
|
if
|
||||||
|
(
|
||||||
|
collapseEdge[e0] == -1
|
||||||
|
&& minEdgeLen[e0] >= 0
|
||||||
|
&& collapseEdge[e1] == -1
|
||||||
|
&& minEdgeLen[e1] >= 0
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// Get the two vertices on both sides of the point
|
||||||
|
label leftV = edges[e0].otherVertex(pointI);
|
||||||
|
label rightV = edges[e1].otherVertex(pointI);
|
||||||
|
|
||||||
|
// Can collapse pointI onto either leftV or rightV.
|
||||||
|
// Preferentially choose an internal point to hopefully
|
||||||
|
// give less distortion
|
||||||
|
|
||||||
|
if (boundaryPoint[leftV] == -1)
|
||||||
|
{
|
||||||
|
collapseEdge[e0] = findIndex(edges[e0], leftV);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
collapseEdge[e1] = findIndex(edges[e1], rightV);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user