GetPeriodicVertices in new interface

This commit is contained in:
Joachim Schöberl 2018-06-08 16:28:51 +02:00
parent 9d0ffac0eb
commit 7e8f8dbeb0
3 changed files with 31 additions and 0 deletions

View File

@ -394,6 +394,12 @@ namespace netgen
Swap (ownmem, a2.ownmem); Swap (ownmem, a2.ownmem);
return *this; return *this;
} }
T * Release()
{
ownmem = false;
return data;
}
private: private:

View File

@ -30,6 +30,21 @@ namespace netgen
int nr; // 0-based int nr; // 0-based
}; };
template <typename T>
class Ng_Buffer
{
size_t s;
T * data;
public:
Ng_Buffer (size_t as, T * adata)
: s(as), data(adata) { ; }
Ng_Buffer (Ng_Buffer && buffer)
: s(buffer.Size()), data(buffer.Release()) { ; }
~Ng_Buffer () { delete [] data; }
size_t Size() const { return s; }
T * Release() { T * hd = data; data = nullptr; return hd; }
};
class Ng_Element class Ng_Element
{ {
@ -285,6 +300,7 @@ namespace netgen
int GetParentElement (int ei) const; int GetParentElement (int ei) const;
int GetParentSElement (int ei) const; int GetParentSElement (int ei) const;
Ng_Buffer<int[2]> GetPeriodicVertices(int idnr) const;
// Find element of point, returns local coordinates // Find element of point, returns local coordinates
template <int DIM> template <int DIM>

View File

@ -297,5 +297,14 @@ template <> NGX_INLINE DLL_HEADER const Ng_Node<2> Ngx_Mesh :: GetNode<2> (int n
} }
NGX_INLINE DLL_HEADER Ng_Buffer<int[2]> Ngx_Mesh :: GetPeriodicVertices(int idnr) const
{
Array<INDEX_2> apairs;
mesh->GetIdentifications().GetPairs (idnr, apairs);
typedef int ti2[2];
return { apairs.Size(), (ti2*)(void*)apairs.Release() };
}
inline auto Ngx_Mesh :: GetTimeStamp() const { return mesh->GetTimeStamp(); } inline auto Ngx_Mesh :: GetTimeStamp() const { return mesh->GetTimeStamp(); }