surfelement - indextype

This commit is contained in:
Joachim Schöberl 2019-08-18 13:10:58 +02:00
parent e89550ec9c
commit 7f6f846eb1
5 changed files with 35 additions and 27 deletions

View File

@ -235,7 +235,7 @@ namespace ngcore
NETGEN_INLINE bool operator != (ArrayIterator d2) { return ind != d2.ind; }
NETGEN_INLINE bool operator == (ArrayIterator d2) { return ind == d2.ind; }
};
template <typename TSIZE>
@ -356,14 +356,14 @@ namespace ngcore
}
template <typename T, typename INDEX_ARRAY>
class IndirectArray : public BaseArrayObject<IndirectArray<T, INDEX_ARRAY> >
template <typename T, typename TI, typename INDEX_ARRAY>
class IndirectArray : public BaseArrayObject<IndirectArray<T, TI, INDEX_ARRAY> >
{
FlatArray<T> ba;
FlatArray<T,TI> ba;
const INDEX_ARRAY & ia;
public:
NETGEN_INLINE IndirectArray (FlatArray<T> aba,
NETGEN_INLINE IndirectArray (FlatArray<T,TI> aba,
const INDEX_ARRAY & aia)
: ba(aba), ia(aia) { ; }
@ -552,10 +552,9 @@ namespace ngcore
}
template <typename TI1>
IndirectArray<T, BaseArrayObject<TI1> >
operator[] (const BaseArrayObject<TI1> & ind_array) const
auto operator[] (const BaseArrayObject<TI1> & ind_array) const
{
return IndirectArray<T, BaseArrayObject<TI1> > (*this, ind_array);
return IndirectArray<T, IndexType, BaseArrayObject<TI1> > (*this, ind_array);
}
/// first position of element elem, returns -1 if element not contained in array

View File

@ -3,11 +3,6 @@
#include "meshing.hpp"
#include <opti.hpp>
#ifndef SMALLLIB
//#ifndef NOTCL
//#include <visual.hpp>
//#endif
#endif
namespace netgen
{
@ -33,11 +28,11 @@ namespace netgen
class trionedge
{
public:
int tnr;
SurfaceElementIndex tnr;
int sidenr;
trionedge () { tnr = 0; sidenr = 0; }
trionedge (int atnr, int asidenr)
trionedge (SurfaceElementIndex atnr, int asidenr)
{ tnr = atnr; sidenr = asidenr; }
};
@ -95,7 +90,7 @@ namespace netgen
int surfnr = mesh.GetFaceDescriptor (faceindex).SurfNr();
Array<Neighbour> neighbors(mesh.GetNSE());
INDEX_2_HASHTABLE<trionedge> other(seia.Size() + 2);
INDEX_2_HASHTABLE<trionedge> other(2*seia.Size() + 2);
Array<bool> swapped(mesh.GetNSE());
@ -190,10 +185,16 @@ namespace netgen
}
*/
/*
for (int i = 0; i < seia.Size(); i++)
{
const Element2d & sel = mesh[seia[i]];
*/
for (SurfaceElementIndex sei : seia)
{
const Element2d & sel = mesh[sei];
for (int j = 0; j < 3; j++)
{
PointIndex pi1 = sel.PNumMod(j+2);
@ -201,8 +202,8 @@ namespace netgen
// double loch = mesh.GetH(mesh[pi1]);
INDEX_2 edge(pi1, pi2);
edge.Sort();
// INDEX_2 edge(pi1, pi2);
// edge.Sort();
if (mesh.IsSegment (pi1, pi2))
continue;
@ -216,18 +217,23 @@ namespace netgen
{
// INDEX_2 i2s(ii2);
// i2s.Sort();
/*
int i2 = other.Get(ii2).tnr;
int j2 = other.Get(ii2).sidenr;
neighbors[seia[i]].SetNr (j, i2);
neighbors[seia[i]].SetOrientation (j, j2);
neighbors[i2].SetNr (j2, seia[i]);
*/
auto othertrig = other.Get(ii2);
SurfaceElementIndex i2 = othertrig.tnr;
int j2 = othertrig.sidenr;
neighbors[sei].SetNr (j, i2);
neighbors[sei].SetOrientation (j, j2);
neighbors[i2].SetNr (j2, sei);
neighbors[i2].SetOrientation (j2, j);
}
else
{
other.Set (INDEX_2 (pi2, pi1), trionedge (seia[i], j));
other.Set (INDEX_2 (pi2, pi1), trionedge (sei, j));
}
}
}

View File

@ -40,7 +40,7 @@ namespace netgen
/// line-segments at edges
Array<Segment> segments;
/// surface elements, 2d-inner elements
Array<Element2d> surfelements;
Array<Element2d, SurfaceElementIndex> surfelements;
/// volume elements
Array<Element> volelements;
/// points will be fixed forever
@ -788,8 +788,12 @@ namespace netgen
void ReCalc ()
{
area = 0;
/*
for (SurfaceElementIndex sei = 0; sei < mesh.GetNSE(); sei++)
Add (mesh[sei]);
*/
for (const Element2d & el : mesh.SurfaceElements())
Add (el);
valid = true;
}

View File

@ -268,7 +268,6 @@ namespace netgen
SurfaceElementIndex & operator++ () { ++i; return *this; }
SurfaceElementIndex & operator-- () { --i; return *this; }
SurfaceElementIndex & operator+= (int inc) { i+=inc; return *this; }
void DoArchive (Archive & ar) { ar & i; }
};

View File

@ -723,7 +723,7 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m)
py::return_value_policy::reference)
.def("Elements2D",
static_cast<Array<Element2d>&(Mesh::*)()> (&Mesh::SurfaceElements),
static_cast<Array<Element2d,SurfaceElementIndex>&(Mesh::*)()> (&Mesh::SurfaceElements),
py::return_value_policy::reference)
.def("Elements1D",