diff --git a/libsrc/include/nginterface_v2.hpp b/libsrc/include/nginterface_v2.hpp index 82074cfc..de18cf05 100644 --- a/libsrc/include/nginterface_v2.hpp +++ b/libsrc/include/nginterface_v2.hpp @@ -345,6 +345,8 @@ namespace netgen void Curve (int order); int GetCurveOrder (); + void EnableTable (string name, bool set); + void Refine (NG_REFINEMENT_TYPE reftype, void (*taskmanager)(function) = &DummyTaskManager2, void (*tracer)(string, bool) = &DummyTracer2); diff --git a/libsrc/interface/nginterface_v2.cpp b/libsrc/interface/nginterface_v2.cpp index cca8b3a4..0f3f48a9 100644 --- a/libsrc/interface/nginterface_v2.cpp +++ b/libsrc/interface/nginterface_v2.cpp @@ -1137,6 +1137,13 @@ namespace netgen return mesh->GetCurvedElements().GetOrder(); } + void Ngx_Mesh :: EnableTable (string name, bool set) + { + mesh->GetTopology().EnableTable (name, set); + } + + + template <> DLL_HEADER void Ngx_Mesh :: SetRefinementFlag<2> (size_t elnr, bool flag) { diff --git a/libsrc/meshing/python_mesh.cpp b/libsrc/meshing/python_mesh.cpp index 5c92d3dd..fd88061c 100644 --- a/libsrc/meshing/python_mesh.cpp +++ b/libsrc/meshing/python_mesh.cpp @@ -1129,15 +1129,20 @@ project_boundaries : Optional[str] = None .def ("EnableTable", [] (Mesh & self, string name, bool set) { + const_cast(self.GetTopology()).EnableTable(name, set); + /* if (name == "edges") const_cast(self.GetTopology()).SetBuildEdges(set); else if (name == "faces") const_cast(self.GetTopology()).SetBuildFaces(set); else if (name == "parentedges") - const_cast(self.GetTopology()).SetBuildHierarchy(set); + const_cast(self.GetTopology()).SetBuildParentEdges(set); + else if (name == "parentfaces") + const_cast(self.GetTopology()).SetBuildParentFaces(set); else throw Exception ("noting known about table "+name +"\n" - "knwon are 'edges', 'faces', 'parentedges'"); + "knwon are 'edges', 'faces', 'parentedges', 'parentfaces'"); + */ }, py::arg("name"), py::arg("set")=true) diff --git a/libsrc/meshing/topology.cpp b/libsrc/meshing/topology.cpp index fa81a64f..49a4747c 100644 --- a/libsrc/meshing/topology.cpp +++ b/libsrc/meshing/topology.cpp @@ -55,6 +55,24 @@ namespace netgen bool MeshTopology :: NeedsUpdate() const { return (timestamp <= mesh->GetTimeStamp()); } + + void MeshTopology :: EnableTable (string name, bool set) + { + if (name == "edges") + SetBuildEdges(set); + else if (name == "faces") + SetBuildFaces(set); + else if (name == "parentedges") + SetBuildParentEdges(set); + else if (name == "parentfaces") + SetBuildParentFaces(set); + else + throw Exception ("noting known about table "+name +"\n" + "knwon are 'edges', 'faces', 'parentedges', 'parentfaces'"); + } + + + template void LoopOverEdges (const Mesh & mesh, MeshTopology & top, PointIndex v, FUNC func) @@ -679,7 +697,7 @@ namespace netgen } ); - if (build_hierarchy) + if (build_parent_edges) { static Timer t("build_hierarchy"); RegionTimer reg(t); cnt = 0; @@ -1438,10 +1456,12 @@ namespace netgen // NgProfiler::StopTimer (timer2c); - if (build_hierarchy) + if (build_parent_faces) { // tets only - + cout << "build face hierarchy:" << endl; + cout << "f2v = " << face2vert << endl; + ngcore::ClosedHashTable, int> v2f(nv); for (auto i : Range(face2vert)) { @@ -1459,38 +1479,49 @@ namespace netgen for (auto i : Range(nfa)) { INT<3,PointIndex> f3(face2vert[i][0], face2vert[i][1], face2vert[i][2]); - PointIndex vmax = Max(f3); - if (vmax >= mesh->mlbetweennodes.Size()+PointIndex::BASE) - continue; - - auto parents = mesh->mlbetweennodes[vmax]; - // is face part of one parent face (boundary-face) ? - for (int j = 0; j < 2; j++) + // find a vertex, such that one of its parent is a trig vertex + + for (int k = 0; k < 3; k++) { - if (f3.Contains(parents[j])) + PointIndex v3 = f3[k]; + + if (v3 >= mesh->mlbetweennodes.Size()+PointIndex::BASE) + continue; + auto parents = mesh->mlbetweennodes[v3]; + + // is face part of one parent face (boundary-face) ? + for (int j = 0; j < 2; j++) { - PointIndex v0 = parents[j]; - PointIndex v1 = parents[1-j]; - - // the third one, on the tip - PointIndex v2 = f3[0]+f3[1]+f3[2] - v0 - v1; - - int classnr = 0; - if (v0 > v1) { Swap (v0, v1); classnr += 1; } - if (v1 > v2) { Swap (v1, v2); classnr += 2; } - if (v0 > v1) { Swap (v0, v1); classnr += 4; } - - INT<3> parentverts(v0, v1, v2); - int pafacenr = v2f[parentverts]; - cout << "parent-face = " << pafacenr << endl; - parent_faces[i] = { classnr, { pafacenr, -1, -1, -1 } }; + if (f3.Contains(parents[j])) + { + PointIndex v0 = parents[j]; + PointIndex v1 = parents[1-j]; + + // the third one, on the tip + PointIndex v2 = f3[0]+f3[1]+f3[2] - v0 - v3; + + INT<3> parentverts(v0, v1, v2); + parentverts.Sort(); + + + int classnr = 0; + if (v2 > v3) { Swap (v2, v3); classnr += 1; } + if (v0 > v1) { Swap (v0, v1); classnr += 2; } + if (v1 > v2) { Swap (v1, v2); classnr += 4; } + if (v0 > v1) { Swap (v0, v1); classnr += 8; } + + if (v2f.Used(parentverts)) + { + int pafacenr = v2f[parentverts]; + cout << "parent-face = " << pafacenr << endl; + parent_faces[i] = { classnr, { pafacenr, -1, -1, -1 } }; + } + } } } } - } - } diff --git a/libsrc/meshing/topology.hpp b/libsrc/meshing/topology.hpp index 2a9c3c9b..57205600 100644 --- a/libsrc/meshing/topology.hpp +++ b/libsrc/meshing/topology.hpp @@ -45,7 +45,8 @@ class MeshTopology const Mesh * mesh; bool buildedges; bool buildfaces; - bool build_hierarchy = false; // may be changed to default = false + bool build_parent_edges = false; // may be changed to default = false + bool build_parent_faces = false; // may be changed to default = false NgArray edge2vert; NgArray face2vert; @@ -80,14 +81,14 @@ public: { buildedges = be; } void SetBuildFaces (bool bf) { buildfaces = bf; } - void SetBuildHierarchy (bool bh) { build_hierarchy = bh; } + void SetBuildParentEdges (bool bh) { build_parent_edges = bh; } + void SetBuildParentFaces (bool bh) { build_parent_faces = bh; } - bool HasEdges () const - { return buildedges; } - bool HasFaces () const - { return buildfaces; } - bool HasParentEdges () const - { return build_hierarchy; } + void EnableTable (string name, bool set); + + bool HasEdges () const { return buildedges; } + bool HasFaces () const { return buildfaces; } + bool HasParentEdges () const { return build_parent_edges; } void Update(NgTaskManager tm = &DummyTaskManager, NgTracer tracer = &DummyTracer); bool NeedsUpdate() const;