mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-26 05:50:32 +05:00
polishing improve2, IndirectArray iterator + element access
This commit is contained in:
parent
a51292bcf6
commit
e89550ec9c
@ -228,8 +228,10 @@ namespace ngcore
|
|||||||
{ return ArrayIterator(ar, ind++); }
|
{ return ArrayIterator(ar, ind++); }
|
||||||
NETGEN_INLINE ArrayIterator operator++ ()
|
NETGEN_INLINE ArrayIterator operator++ ()
|
||||||
{ return ArrayIterator(ar, ++ind); }
|
{ return ArrayIterator(ar, ++ind); }
|
||||||
NETGEN_INLINE TELEM operator*() const { return ar[ind]; }
|
// NETGEN_INLINE const TELEM & operator*() const { return ar[ind]; }
|
||||||
NETGEN_INLINE TELEM & operator*() { return ar[ind]; }
|
// NETGEN_INLINE TELEM & operator*() { return ar[ind]; }
|
||||||
|
NETGEN_INLINE auto operator*() const -> decltype(ar[ind]) { return ar[ind]; }
|
||||||
|
NETGEN_INLINE auto operator*() -> decltype(ar[ind]) { return ar[ind]; }
|
||||||
NETGEN_INLINE bool operator != (ArrayIterator d2) { return ind != d2.ind; }
|
NETGEN_INLINE bool operator != (ArrayIterator d2) { return ind != d2.ind; }
|
||||||
NETGEN_INLINE bool operator == (ArrayIterator d2) { return ind == d2.ind; }
|
NETGEN_INLINE bool operator == (ArrayIterator d2) { return ind == d2.ind; }
|
||||||
};
|
};
|
||||||
@ -366,8 +368,8 @@ namespace ngcore
|
|||||||
: ba(aba), ia(aia) { ; }
|
: ba(aba), ia(aia) { ; }
|
||||||
|
|
||||||
NETGEN_INLINE size_t Size() const { return ia.Size(); }
|
NETGEN_INLINE size_t Size() const { return ia.Size(); }
|
||||||
NETGEN_INLINE T operator[] (size_t i) const { return ba[ia[i]]; }
|
NETGEN_INLINE T & operator[] (size_t i) const { return ba[ia[i]]; }
|
||||||
NETGEN_INLINE T & operator[] (size_t i) { return ba[ia[i]]; }
|
// NETGEN_INLINE T & operator[] (size_t i) { return ba[ia[i]]; }
|
||||||
|
|
||||||
NETGEN_INLINE IndirectArray operator= (const T & val)
|
NETGEN_INLINE IndirectArray operator= (const T & val)
|
||||||
{
|
{
|
||||||
@ -384,6 +386,8 @@ namespace ngcore
|
|||||||
return IndirectArray (ba, ia);
|
return IndirectArray (ba, ia);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NETGEN_INLINE AOWrapperIterator<IndirectArray> begin() const { return { *this, 0 }; }
|
||||||
|
NETGEN_INLINE AOWrapperIterator<IndirectArray> end() const { return { *this, Size() }; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -94,11 +94,11 @@ namespace netgen
|
|||||||
|
|
||||||
int surfnr = mesh.GetFaceDescriptor (faceindex).SurfNr();
|
int surfnr = mesh.GetFaceDescriptor (faceindex).SurfNr();
|
||||||
|
|
||||||
NgArray<Neighbour> neighbors(mesh.GetNSE());
|
Array<Neighbour> neighbors(mesh.GetNSE());
|
||||||
INDEX_2_HASHTABLE<trionedge> other(seia.Size() + 2);
|
INDEX_2_HASHTABLE<trionedge> other(seia.Size() + 2);
|
||||||
|
|
||||||
|
|
||||||
NgArray<bool> swapped(mesh.GetNSE());
|
Array<bool> swapped(mesh.GetNSE());
|
||||||
NgArray<int,PointIndex::BASE> pdef(mesh.GetNP());
|
NgArray<int,PointIndex::BASE> pdef(mesh.GetNP());
|
||||||
NgArray<double,PointIndex::BASE> pangle(mesh.GetNP());
|
NgArray<double,PointIndex::BASE> pangle(mesh.GetNP());
|
||||||
|
|
||||||
@ -153,21 +153,25 @@ namespace netgen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
for (int i = 0; i < seia.Size(); i++)
|
for (int i = 0; i < seia.Size(); i++)
|
||||||
{
|
{
|
||||||
const Element2d & sel = mesh[seia[i]];
|
const Element2d & sel = mesh[seia[i]];
|
||||||
for (int j = 0; j < 3; j++)
|
for (int j = 0; j < 3; j++)
|
||||||
pdef[sel[j]]++;
|
pdef[sel[j]]++;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
for (int i = 0; i < seia.Size(); i++)
|
for (SurfaceElementIndex sei : seia)
|
||||||
{
|
for (PointIndex pi : mesh[sei].PNums<3>())
|
||||||
for (int j = 0; j < 3; j++)
|
pdef[pi]++;
|
||||||
{
|
|
||||||
neighbors[seia[i]].SetNr (j, -1);
|
// for (int i = 0; i < seia.Size(); i++)
|
||||||
neighbors[seia[i]].SetOrientation (j, 0);
|
for (SurfaceElementIndex sei : seia)
|
||||||
}
|
for (int j = 0; j < 3; j++)
|
||||||
}
|
{
|
||||||
|
neighbors[sei].SetNr (j, -1);
|
||||||
|
neighbors[sei].SetOrientation (j, 0);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
NgArray<Vec3d> normals(mesh.GetNP());
|
NgArray<Vec3d> normals(mesh.GetNP());
|
||||||
@ -228,9 +232,9 @@ namespace netgen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < seia.Size(); i++)
|
for (SurfaceElementIndex sei : seia)
|
||||||
swapped[seia[i]] = false;
|
swapped[sei] = false;
|
||||||
|
|
||||||
NgProfiler::StopTimer (timerstart);
|
NgProfiler::StopTimer (timerstart);
|
||||||
|
|
||||||
|
|
||||||
@ -466,16 +470,11 @@ namespace netgen
|
|||||||
int np = mesh.GetNP();
|
int np = mesh.GetNP();
|
||||||
|
|
||||||
TABLE<SurfaceElementIndex,PointIndex::BASE> elementsonnode(np);
|
TABLE<SurfaceElementIndex,PointIndex::BASE> elementsonnode(np);
|
||||||
NgArray<SurfaceElementIndex> hasonepi, hasbothpi;
|
Array<SurfaceElementIndex> hasonepi, hasbothpi;
|
||||||
|
|
||||||
for (SurfaceElementIndex sei : seia)
|
for (SurfaceElementIndex sei : seia)
|
||||||
{
|
for (PointIndex pi : mesh[sei].PNums<3>())
|
||||||
// Element2d & el = mesh[sei];
|
elementsonnode.Add (pi, sei);
|
||||||
// for (int j = 0; j < el.GetNP(); j++)
|
|
||||||
// elementsonnode.Add (el[j], sei);
|
|
||||||
for (PointIndex pi : mesh[sei].PNums())
|
|
||||||
elementsonnode.Add (pi, sei);
|
|
||||||
}
|
|
||||||
|
|
||||||
Array<bool,PointIndex> fixed(np);
|
Array<bool,PointIndex> fixed(np);
|
||||||
fixed = false;
|
fixed = false;
|
||||||
@ -515,7 +514,7 @@ namespace netgen
|
|||||||
fixed[pi] = true;
|
fixed[pi] = true;
|
||||||
|
|
||||||
|
|
||||||
NgArray<Vec<3>,PointIndex::BASE> normals(np);
|
Array<Vec<3>,PointIndex> normals(np);
|
||||||
|
|
||||||
// for (PointIndex pi = mesh.Points().Begin(); pi < mesh.Points().End(); pi++)
|
// for (PointIndex pi = mesh.Points().Begin(); pi < mesh.Points().End(); pi++)
|
||||||
for (PointIndex pi : mesh.Points().Range())
|
for (PointIndex pi : mesh.Points().Range())
|
||||||
@ -596,21 +595,22 @@ namespace netgen
|
|||||||
hasonepi.SetSize(0);
|
hasonepi.SetSize(0);
|
||||||
hasbothpi.SetSize(0);
|
hasbothpi.SetSize(0);
|
||||||
|
|
||||||
for (int k = 0; k < elementsonnode[pi1].Size(); k++)
|
// for (int k = 0; k < elementsonnode[pi1].Size(); k++)
|
||||||
|
for (SurfaceElementIndex sei2 : elementsonnode[pi1])
|
||||||
{
|
{
|
||||||
const Element2d & el2 = mesh[elementsonnode[pi1][k]];
|
const Element2d & el2 = mesh[sei2];
|
||||||
|
|
||||||
if (el2.IsDeleted()) continue;
|
if (el2.IsDeleted()) continue;
|
||||||
|
|
||||||
if (el2[0] == pi2 || el2[1] == pi2 || el2[2] == pi2)
|
if (el2[0] == pi2 || el2[1] == pi2 || el2[2] == pi2)
|
||||||
{
|
{
|
||||||
hasbothpi.Append (elementsonnode[pi1][k]);
|
hasbothpi.Append (sei2);
|
||||||
nv = Cross (Vec3d (mesh[el2[0]], mesh[el2[1]]),
|
nv = Cross (Vec3d (mesh[el2[0]], mesh[el2[1]]),
|
||||||
Vec3d (mesh[el2[0]], mesh[el2[2]]));
|
Vec3d (mesh[el2[0]], mesh[el2[2]]));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
hasonepi.Append (elementsonnode[pi1][k]);
|
hasonepi.Append (sei2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -628,29 +628,32 @@ namespace netgen
|
|||||||
// nv = normals.Get(pi1);
|
// nv = normals.Get(pi1);
|
||||||
|
|
||||||
|
|
||||||
|
for (SurfaceElementIndex sei2 : elementsonnode[pi2])
|
||||||
for (int k = 0; k < elementsonnode[pi2].Size(); k++)
|
|
||||||
{
|
{
|
||||||
const Element2d & el2 = mesh[elementsonnode[pi2][k]];
|
const Element2d & el2 = mesh[sei2];
|
||||||
if (el2.IsDeleted()) continue;
|
if (el2.IsDeleted()) continue;
|
||||||
|
if (!el2.PNums<3>().Contains (pi1))
|
||||||
if (el2[0] == pi1 || el2[1] == pi1 || el2[2] == pi1)
|
hasonepi.Append (sei2);
|
||||||
;
|
|
||||||
else
|
|
||||||
hasonepi.Append (elementsonnode[pi2][k]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
double bad1 = 0;
|
double bad1 = 0;
|
||||||
int illegal1 = 0, illegal2 = 0;
|
int illegal1 = 0, illegal2 = 0;
|
||||||
|
/*
|
||||||
for (int k = 0; k < hasonepi.Size(); k++)
|
for (SurfaceElementIndex sei : hasonepi)
|
||||||
{
|
{
|
||||||
const Element2d & el = mesh[hasonepi[k]];
|
const Element2d & el = mesh[sei];
|
||||||
bad1 += CalcTriangleBadness (mesh[el[0]], mesh[el[1]], mesh[el[2]],
|
bad1 += CalcTriangleBadness (mesh[el[0]], mesh[el[1]], mesh[el[2]],
|
||||||
nv, -1, loch);
|
nv, -1, loch);
|
||||||
illegal1 += 1-mesh.LegalTrig(el);
|
illegal1 += 1-mesh.LegalTrig(el);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
for (const Element2d & el : mesh.SurfaceElements()[hasonepi])
|
||||||
|
{
|
||||||
|
bad1 += CalcTriangleBadness (mesh[el[0]], mesh[el[1]], mesh[el[2]],
|
||||||
|
nv, -1, loch);
|
||||||
|
illegal1 += 1-mesh.LegalTrig(el);
|
||||||
|
}
|
||||||
|
|
||||||
for (int k = 0; k < hasbothpi.Size(); k++)
|
for (int k = 0; k < hasbothpi.Size(); k++)
|
||||||
{
|
{
|
||||||
const Element2d & el = mesh[hasbothpi[k]];
|
const Element2d & el = mesh[hasbothpi[k]];
|
||||||
|
@ -504,6 +504,8 @@ namespace netgen
|
|||||||
|
|
||||||
auto PNums () const { return FlatArray<const PointIndex> (np, &pnum[0]); }
|
auto PNums () const { return FlatArray<const PointIndex> (np, &pnum[0]); }
|
||||||
auto PNums () { return FlatArray<PointIndex> (np, &pnum[0]); }
|
auto PNums () { return FlatArray<PointIndex> (np, &pnum[0]); }
|
||||||
|
template <int NP>
|
||||||
|
auto PNums() const { return FlatArray<const PointIndex> (NP, &pnum[0]); }
|
||||||
auto Vertices() const { return FlatArray<const PointIndex> (GetNV(), &pnum[0]); }
|
auto Vertices() const { return FlatArray<const PointIndex> (GetNV(), &pnum[0]); }
|
||||||
|
|
||||||
auto GeomInfo() const { return FlatArray<const PointGeomInfo> (np, &geominfo[0]); }
|
auto GeomInfo() const { return FlatArray<const PointGeomInfo> (np, &geominfo[0]); }
|
||||||
@ -796,6 +798,8 @@ namespace netgen
|
|||||||
|
|
||||||
auto PNums () const
|
auto PNums () const
|
||||||
{ return FlatArray<const PointIndex> (np, &pnum[0]); }
|
{ return FlatArray<const PointIndex> (np, &pnum[0]); }
|
||||||
|
template <int NP>
|
||||||
|
auto PNums() const { return FlatArray<const PointIndex> (NP, &pnum[0]); }
|
||||||
|
|
||||||
FlatArray<const PointIndex> Vertices() const { return { GetNV(), &pnum[0] }; }
|
FlatArray<const PointIndex> Vertices() const { return { GetNV(), &pnum[0] }; }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user