diff --git a/libsrc/include/nginterface_v2.hpp b/libsrc/include/nginterface_v2.hpp index 962f061c..936a053e 100644 --- a/libsrc/include/nginterface_v2.hpp +++ b/libsrc/include/nginterface_v2.hpp @@ -342,6 +342,8 @@ namespace netgen void (*taskmanager)(function) = &DummyTaskManager2, void (*tracer)(string, bool) = &DummyTracer2); + int GetHPElementLevel (int ei, int dir) 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 80843705..9be47b57 100644 --- a/libsrc/interface/nginterface_v2.cpp +++ b/libsrc/interface/nginterface_v2.cpp @@ -680,6 +680,37 @@ namespace netgen } + int Ngx_Mesh :: GetHPElementLevel (int ei, int dir) const + { + ei++; + int level = -1; + + if (mesh->hpelements) + { + int hpelnr = -1; + if (mesh->GetDimension() == 2) + hpelnr = mesh->SurfaceElement(ei).hp_elnr; + else + hpelnr = mesh->VolumeElement(ei).hp_elnr; + + if (hpelnr < 0) + throw NgException("Ngx_Mesh::GetHPElementLevel: Wrong hp-element number!"); + + if (dir == 1) + level = (*mesh->hpelements)[hpelnr].levelx; + else if (dir == 2) + level = (*mesh->hpelements)[hpelnr].levely; + else if (dir == 3) + level = (*mesh->hpelements)[hpelnr].levelz; + else + throw NgException("Ngx_Mesh::GetHPElementLevel: dir has to be 1, 2 or 3!"); + } + //else + // throw NgException("Ngx_Mesh::GetHPElementLevel only for HPRefinement implemented!"); + + return level; + } + int Ngx_Mesh :: GetParentElement (int ei) const { ei++; diff --git a/libsrc/meshing/hprefinement.cpp b/libsrc/meshing/hprefinement.cpp index a26945e6..d2752ba8 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) { @@ -829,18 +806,27 @@ namespace netgen 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; + if (newel.type == HP_SEGM || + newel.type == HP_TRIG || + newel.type == HP_QUAD || + newel.type == HP_TET || + newel.type == HP_PRISM || + newel.type == HP_HEX || + newel.type == HP_PYRAMID) + newel.levelx = newel.levely = newel.levelz = newlevel; + else + newel.levelx = newel.levely = newel.levelz = newlevel+1; + 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_HEX: newel.np=8; break; - case HP_PRISM: newel.np=6; break; - case HP_TET: newel.np=4; break; + case HP_SEGM: newel.np=2; break; + case HP_QUAD: newel.np=4; break; + case HP_TRIG: newel.np=3; break; + case HP_HEX: newel.np=8; break; + case HP_PRISM: newel.np=6; break; + case HP_TET: newel.np=4; break; case HP_PYRAMID: newel.np=5; break; default: throw NgException (string("hprefinement.cpp: illegal type")); @@ -868,7 +854,7 @@ namespace netgen if (j == 0) elements[i] = newel; // overwrite old element - else + else elements.Append (newel); j++; } @@ -1337,7 +1323,7 @@ namespace netgen Array & hpelements = *mesh.hpelements; InitHPElements(mesh,hpelements); - + Array nplevel; nplevel.Append (mesh.GetNP());