diff --git a/libsrc/include/nginterface_v2.hpp b/libsrc/include/nginterface_v2.hpp index 580a340a..61714700 100644 --- a/libsrc/include/nginterface_v2.hpp +++ b/libsrc/include/nginterface_v2.hpp @@ -296,6 +296,8 @@ namespace netgen void (*taskmanager)(function) = &DummyTaskManager2, void (*tracer)(string, bool) = &DummyTracer2); + int GetElementLevel (int ei) const; + void GetParentNodes (int ni, int * parents) const; int GetParentElement (int ei) const; int GetParentSElement (int ei) const; diff --git a/libsrc/interface/nginterface_v2.cpp b/libsrc/interface/nginterface_v2.cpp index 5e2bbd34..f2b5032b 100644 --- a/libsrc/interface/nginterface_v2.cpp +++ b/libsrc/interface/nginterface_v2.cpp @@ -675,6 +675,26 @@ namespace netgen } + int Ngx_Mesh :: GetElementLevel (int ei) const + { + ei++; + + if (mesh->hpelements) + { + int hpelnr = -1; + if (mesh->GetDimension() == 2) + hpelnr = mesh->SurfaceElement(ei).hp_elnr; + else + hpelnr = mesh->VolumeElement(ei).hp_elnr; + + return (*mesh->hpelements)[hpelnr].levelx; + } + //else + // throw NgException("Ngx_Mesh::GetElementLevel only for HPRefinement implemented!"); + + return -1; + } + int Ngx_Mesh :: GetParentElement (int ei) const { ei++; diff --git a/libsrc/meshing/hprefinement.cpp b/libsrc/meshing/hprefinement.cpp index a26945e6..0216a711 100644 --- a/libsrc/meshing/hprefinement.cpp +++ b/libsrc/meshing/hprefinement.cpp @@ -22,8 +22,9 @@ namespace netgen { pnums[i] = -1; param[i][0] = param[i][1] = param[i][2] = 0; - domin=-1; domout=-1; // he: } + domin=-1; domout=-1; // he: + levelx = 0; levely = 0; levelz = 0; } HPRefElement :: HPRefElement () @@ -31,46 +32,40 @@ namespace netgen Reset(); } - HPRefElement :: HPRefElement(Element & el) + HPRefElement :: HPRefElement(Element & el) : + np(el.GetNV()), index(el.GetIndex()), levelx(0), levely(0), levelz(0), type(HP_NONE), domin(-1), domout(-1) //domin,out for segements { //Reset(); - np = el.GetNV(); for (int i=0; igeom) { @@ -823,21 +800,33 @@ namespace netgen *testout << endl; */ + bool last = false; while (hprs->neweltypes[j]) { + if (!hprs->neweltypes[j+1] || !hprs->neweltypes[j+2]) + last = true; + HPRef_Struct * hprsnew = Get_HPRef_Struct (hprs->neweltypes[j]); HPRefElement newel(el); newel.type = hprs->neweltypes[j]; - // newel.index = elements[i].index; // newel.coarse_elnr = elements[i].coarse_elnr; newel.levelx = newel.levely = newel.levelz = newlevel; + switch(hprsnew->geom) { case HP_SEGM: newel.np=2; break; - case HP_QUAD: newel.np=4; break; - case HP_TRIG: newel.np=3; break; + case HP_QUAD: + newel.np=4; + if (last) + newlevel--; + break; + case HP_TRIG: + newel.np=3; + if (last) + newlevel--; + break; case HP_HEX: newel.np=8; break; case HP_PRISM: newel.np=6; break; case HP_TET: newel.np=4; break; @@ -868,7 +857,7 @@ namespace netgen if (j == 0) elements[i] = newel; // overwrite old element - else + else elements.Append (newel); j++; } @@ -1337,7 +1326,7 @@ namespace netgen Array & hpelements = *mesh.hpelements; InitHPElements(mesh,hpelements); - + Array nplevel; nplevel.Append (mesh.GetNP());