mirror of
https://github.com/NGSolve/netgen.git
synced 2025-01-27 13:20:34 +05:00
EdgeSwapping() - all faces at once
This commit is contained in:
parent
f24a749fb2
commit
288bd2c3d8
@ -27,7 +27,6 @@ namespace netgen
|
|||||||
Array<Neighbour> &neighbors,
|
Array<Neighbour> &neighbors,
|
||||||
Array<bool> &swapped,
|
Array<bool> &swapped,
|
||||||
const SurfaceElementIndex t1, const int o1,
|
const SurfaceElementIndex t1, const int o1,
|
||||||
const int surfnr,
|
|
||||||
const int t,
|
const int t,
|
||||||
NgArray<int,PointIndex::BASE> &pdef,
|
NgArray<int,PointIndex::BASE> &pdef,
|
||||||
const bool check_only)
|
const bool check_only)
|
||||||
@ -41,6 +40,8 @@ namespace netgen
|
|||||||
if (t2 == -1) return false;
|
if (t2 == -1) return false;
|
||||||
if (swapped[t1] || swapped[t2]) return false;
|
if (swapped[t1] || swapped[t2]) return false;
|
||||||
|
|
||||||
|
const int faceindex = mesh[t1].GetIndex();
|
||||||
|
const int surfnr = mesh.GetFaceDescriptor (faceindex).SurfNr();
|
||||||
|
|
||||||
PointIndex pi1 = mesh[t1].PNumMod(o1+1+1);
|
PointIndex pi1 = mesh[t1].PNumMod(o1+1+1);
|
||||||
PointIndex pi2 = mesh[t1].PNumMod(o1+1+2);
|
PointIndex pi2 = mesh[t1].PNumMod(o1+1+2);
|
||||||
@ -174,51 +175,41 @@ namespace netgen
|
|||||||
void MeshOptimize2d :: EdgeSwapping (Mesh & mesh, int usemetric)
|
void MeshOptimize2d :: EdgeSwapping (Mesh & mesh, int usemetric)
|
||||||
{
|
{
|
||||||
static Timer timer("EdgeSwapping (2D)"); RegionTimer reg(timer);
|
static Timer timer("EdgeSwapping (2D)"); RegionTimer reg(timer);
|
||||||
if (!faceindex)
|
if (usemetric)
|
||||||
{
|
PrintMessage (3, "Edgeswapping, metric");
|
||||||
if (usemetric)
|
else
|
||||||
PrintMessage (3, "Edgeswapping, metric");
|
PrintMessage (3, "Edgeswapping, topological");
|
||||||
else
|
|
||||||
PrintMessage (3, "Edgeswapping, topological");
|
|
||||||
|
|
||||||
for (faceindex = 1; faceindex <= mesh.GetNFD(); faceindex++)
|
|
||||||
{
|
|
||||||
EdgeSwapping (mesh, usemetric);
|
|
||||||
|
|
||||||
if (multithread.terminate)
|
|
||||||
throw NgException ("Meshing stopped");
|
|
||||||
}
|
|
||||||
|
|
||||||
faceindex = 0;
|
|
||||||
mesh.CalcSurfacesOfNode();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static int timerstart = NgProfiler::CreateTimer ("EdgeSwapping 2D start");
|
static int timerstart = NgProfiler::CreateTimer ("EdgeSwapping 2D start");
|
||||||
NgProfiler::StartTimer (timerstart);
|
NgProfiler::StartTimer (timerstart);
|
||||||
|
|
||||||
|
|
||||||
Array<SurfaceElementIndex> seia;
|
Array<SurfaceElementIndex> seia;
|
||||||
mesh.GetSurfaceElementsOfFace (faceindex, seia);
|
bool mixed = false;
|
||||||
|
if(faceindex==0)
|
||||||
|
{
|
||||||
|
seia.SetSize(mesh.GetNSE());
|
||||||
|
ParallelForRange( Range(seia), [&] (auto myrange)
|
||||||
|
{
|
||||||
|
for (auto i : myrange)
|
||||||
|
{
|
||||||
|
SurfaceElementIndex sei(i);
|
||||||
|
seia[i] = sei;
|
||||||
|
if (mesh[sei].GetNP() != 3)
|
||||||
|
mixed = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mesh.GetSurfaceElementsOfFace (faceindex, seia);
|
||||||
|
for (SurfaceElementIndex sei : seia)
|
||||||
|
if (mesh[sei].GetNP() != 3)
|
||||||
|
mixed = true;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
if(mixed)
|
||||||
for (int i = 0; i < seia.Size(); i++)
|
return GenericImprove(mesh);
|
||||||
if (mesh[seia[i]].GetNP() != 3)
|
|
||||||
{
|
|
||||||
GenericImprove (mesh);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
for (SurfaceElementIndex sei : seia)
|
|
||||||
if (mesh[sei].GetNP() != 3)
|
|
||||||
{
|
|
||||||
GenericImprove (mesh);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int surfnr = mesh.GetFaceDescriptor (faceindex).SurfNr();
|
|
||||||
|
|
||||||
Array<Neighbour> neighbors(mesh.GetNSE());
|
Array<Neighbour> neighbors(mesh.GetNSE());
|
||||||
INDEX_2_HASHTABLE<trionedge> other(2*seia.Size() + 2);
|
INDEX_2_HASHTABLE<trionedge> other(2*seia.Size() + 2);
|
||||||
|
|
||||||
@ -399,7 +390,7 @@ namespace netgen
|
|||||||
throw NgException ("Meshing stopped");
|
throw NgException ("Meshing stopped");
|
||||||
|
|
||||||
for (int o1 = 0; o1 < 3; o1++)
|
for (int o1 = 0; o1 < 3; o1++)
|
||||||
if(EdgeSwapping(mesh, usemetric, neighbors, swapped, t1, o1, surfnr, t, pdef, true))
|
if(EdgeSwapping(mesh, usemetric, neighbors, swapped, t1, o1, t, pdef, true))
|
||||||
improvement_candidates[cnt++]= std::make_pair(t1,o1);
|
improvement_candidates[cnt++]= std::make_pair(t1,o1);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -408,11 +399,12 @@ namespace netgen
|
|||||||
QuickSort(elements_with_improvement);
|
QuickSort(elements_with_improvement);
|
||||||
|
|
||||||
for (auto [t1,o1] : elements_with_improvement)
|
for (auto [t1,o1] : elements_with_improvement)
|
||||||
done |= EdgeSwapping(mesh, usemetric, neighbors, swapped, t1, o1, surfnr, t, pdef, false);
|
done |= EdgeSwapping(mesh, usemetric, neighbors, swapped, t1, o1, t, pdef, false);
|
||||||
t--;
|
t--;
|
||||||
}
|
}
|
||||||
|
|
||||||
mesh.SetNextTimeStamp();
|
mesh.SetNextTimeStamp();
|
||||||
|
mesh.CalcSurfacesOfNode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ public:
|
|||||||
const NgArray<Point<3>* > & from, NgArray<Point<3>* > & dest);
|
const NgArray<Point<3>* > & from, NgArray<Point<3>* > & dest);
|
||||||
|
|
||||||
bool EdgeSwapping (Mesh & mesh, const int usemetric, Array<Neighbour> &neighbors, Array<bool> &swapped,
|
bool EdgeSwapping (Mesh & mesh, const int usemetric, Array<Neighbour> &neighbors, Array<bool> &swapped,
|
||||||
const SurfaceElementIndex t1, const int edge, const int surfnr, const int t, NgArray<int,PointIndex::BASE> &pdef, const bool check_only=false);
|
const SurfaceElementIndex t1, const int edge, const int t, NgArray<int,PointIndex::BASE> &pdef, const bool check_only=false);
|
||||||
void EdgeSwapping (Mesh & mesh, int usemetric);
|
void EdgeSwapping (Mesh & mesh, int usemetric);
|
||||||
void CombineImprove (Mesh & mesh);
|
void CombineImprove (Mesh & mesh);
|
||||||
void SplitImprove (Mesh & mesh);
|
void SplitImprove (Mesh & mesh);
|
||||||
|
@ -21,6 +21,7 @@ namespace netgen
|
|||||||
|
|
||||||
void MeshOptimize2d :: GenericImprove (Mesh & mesh)
|
void MeshOptimize2d :: GenericImprove (Mesh & mesh)
|
||||||
{
|
{
|
||||||
|
static Timer timer("MeshOptimize2d::GenericImprove"); RegionTimer reg(timer);
|
||||||
if (!faceindex)
|
if (!faceindex)
|
||||||
{
|
{
|
||||||
if (writestatus)
|
if (writestatus)
|
||||||
|
Loading…
Reference in New Issue
Block a user