mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-25 05:20:34 +05:00
skip deleted elements when creating tables
-> no need to call Compress() everytime the mesh changes
This commit is contained in:
parent
b2af4c1069
commit
9b5aa90d38
@ -1,15 +1,42 @@
|
|||||||
#ifndef FILE_IMPROVE2
|
#ifndef FILE_IMPROVE2
|
||||||
#define FILE_IMPROVE2
|
#define FILE_IMPROVE2
|
||||||
|
|
||||||
|
inline void AppendEdges( const Element2d & elem, PointIndex pi, Array<std::tuple<PointIndex,PointIndex>> & edges )
|
||||||
|
{
|
||||||
|
for (int j = 0; j < 3; j++)
|
||||||
|
{
|
||||||
|
PointIndex pi0 = elem[j];
|
||||||
|
PointIndex pi1 = elem[(j+1)%3];
|
||||||
|
if (pi1 < pi0) Swap(pi0, pi1);
|
||||||
|
if(pi0==pi)
|
||||||
|
edges.Append(std::make_tuple(pi0, pi1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void AppendEdges( const Element & elem, PointIndex pi, Array<std::tuple<PointIndex,PointIndex>> & edges )
|
||||||
|
{
|
||||||
|
static constexpr int tetedges[6][2] =
|
||||||
|
{ { 0, 1 }, { 0, 2 }, { 0, 3 },
|
||||||
|
{ 1, 2 }, { 1, 3 }, { 2, 3 } };
|
||||||
|
|
||||||
|
if(elem.flags.fixed)
|
||||||
|
return;
|
||||||
|
for (int j = 0; j < 6; j++)
|
||||||
|
{
|
||||||
|
PointIndex pi0 = elem[tetedges[j][0]];
|
||||||
|
PointIndex pi1 = elem[tetedges[j][1]];
|
||||||
|
if (pi1 < pi0) Swap(pi0, pi1);
|
||||||
|
if(pi0==pi)
|
||||||
|
edges.Append(std::make_tuple(pi0, pi1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
template<typename TINDEX>
|
template<typename TINDEX>
|
||||||
void BuildEdgeList( const Mesh & mesh, const Table<TINDEX, PointIndex> & elementsonnode, Array<std::tuple<PointIndex, PointIndex>> & edges )
|
void BuildEdgeList( const Mesh & mesh, const Table<TINDEX, PointIndex> & elementsonnode, Array<std::tuple<PointIndex, PointIndex>> & edges )
|
||||||
{
|
{
|
||||||
|
static_assert(is_same_v<TINDEX, ElementIndex>||is_same_v<TINDEX,SurfaceElementIndex>, "Invalid type for TINDEX");
|
||||||
static Timer tbuild_edges("Build edges"); RegionTimer reg(tbuild_edges);
|
static Timer tbuild_edges("Build edges"); RegionTimer reg(tbuild_edges);
|
||||||
|
|
||||||
static constexpr int tetedges[6][2] =
|
|
||||||
{ { 0, 1 }, { 0, 2 }, { 0, 3 },
|
|
||||||
{ 1, 2 }, { 1, 3 }, { 2, 3 } };
|
|
||||||
|
|
||||||
int ntasks = 4*ngcore::TaskManager::GetMaxThreads();
|
int ntasks = 4*ngcore::TaskManager::GetMaxThreads();
|
||||||
Array<Array<std::tuple<PointIndex,PointIndex>>> task_edges(ntasks);
|
Array<Array<std::tuple<PointIndex,PointIndex>>> task_edges(ntasks);
|
||||||
|
|
||||||
@ -26,29 +53,7 @@ void BuildEdgeList( const Mesh & mesh, const Table<TINDEX, PointIndex> & element
|
|||||||
const auto & elem = mesh[ei];
|
const auto & elem = mesh[ei];
|
||||||
if (elem.IsDeleted()) continue;
|
if (elem.IsDeleted()) continue;
|
||||||
|
|
||||||
static_assert(is_same_v<TINDEX, ElementIndex>||is_same_v<TINDEX,SurfaceElementIndex>, "Invalid type for TINDEX");
|
AppendEdges(elem, pi, local_edges);
|
||||||
if constexpr(is_same_v<TINDEX, SurfaceElementIndex>)
|
|
||||||
{
|
|
||||||
for (int j = 0; j < 3; j++)
|
|
||||||
{
|
|
||||||
PointIndex pi0 = elem[j];
|
|
||||||
PointIndex pi1 = elem[(j+1)%3];
|
|
||||||
if (pi1 < pi0) Swap(pi0, pi1);
|
|
||||||
if(pi0==pi)
|
|
||||||
local_edges.Append(std::make_tuple(pi0, pi1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if constexpr(is_same_v<TINDEX, ElementIndex>)
|
|
||||||
{
|
|
||||||
for (int j = 0; j < 6; j++)
|
|
||||||
{
|
|
||||||
PointIndex pi0 = elem[tetedges[j][0]];
|
|
||||||
PointIndex pi1 = elem[tetedges[j][1]];
|
|
||||||
if (pi1 < pi0) Swap(pi0, pi1);
|
|
||||||
if(pi0==pi)
|
|
||||||
local_edges.Append(std::make_tuple(pi0, pi1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
QuickSort(local_edges);
|
QuickSort(local_edges);
|
||||||
|
|
||||||
|
@ -2139,6 +2139,8 @@ namespace netgen
|
|||||||
[&](auto & table, ElementIndex ei)
|
[&](auto & table, ElementIndex ei)
|
||||||
{
|
{
|
||||||
const Element & el = (*this)[ei];
|
const Element & el = (*this)[ei];
|
||||||
|
if(el.IsDeleted())
|
||||||
|
return;
|
||||||
if (dom == 0 || dom == el.GetIndex())
|
if (dom == 0 || dom == el.GetIndex())
|
||||||
{
|
{
|
||||||
if (el.GetNP() == 4)
|
if (el.GetNP() == 4)
|
||||||
@ -6574,6 +6576,8 @@ namespace netgen
|
|||||||
[&](auto & table, ElementIndex ei)
|
[&](auto & table, ElementIndex ei)
|
||||||
{
|
{
|
||||||
const auto & el = (*this)[ei];
|
const auto & el = (*this)[ei];
|
||||||
|
if(el.IsDeleted())
|
||||||
|
return;
|
||||||
|
|
||||||
for (PointIndex pi : el.PNums())
|
for (PointIndex pi : el.PNums())
|
||||||
if(free_points[pi])
|
if(free_points[pi])
|
||||||
@ -6585,6 +6589,8 @@ namespace netgen
|
|||||||
[&](auto & table, ElementIndex ei)
|
[&](auto & table, ElementIndex ei)
|
||||||
{
|
{
|
||||||
const auto & el = (*this)[ei];
|
const auto & el = (*this)[ei];
|
||||||
|
if(el.IsDeleted())
|
||||||
|
return;
|
||||||
|
|
||||||
for (PointIndex pi : el.PNums())
|
for (PointIndex pi : el.PNums())
|
||||||
table.Add (pi, ei);
|
table.Add (pi, ei);
|
||||||
|
Loading…
Reference in New Issue
Block a user