From 890f59b8b4c483d4e3cc9988ac69bd43801604ad Mon Sep 17 00:00:00 2001 From: Umberto Zerbinati Date: Mon, 15 Jan 2024 11:42:00 +0000 Subject: [PATCH 1/3] Exposed Alfeld splits --- libsrc/meshing/python_mesh.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libsrc/meshing/python_mesh.cpp b/libsrc/meshing/python_mesh.cpp index 1a50a250..284b7997 100644 --- a/libsrc/meshing/python_mesh.cpp +++ b/libsrc/meshing/python_mesh.cpp @@ -1350,7 +1350,15 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m) }), py::arg("adaptive")=false, py::call_guard()) .def("ZRefine", &Mesh::ZRefine) - + .def("Split2Tets", &Mesh::Split2Tets) + .def ("SplitAlfeld", FunctionPointer + ([](Mesh & self) + { + NgLock meshlock (self.MajorMutex(), true); + Refinement & ref = const_cast (self.GetGeometry()->GetRefinement()); + ::netgen::HPRefinement (self, &ref, SPLIT_ALFELD, 1, 0.5, true, true); + } + ), py::call_guard()) .def ("SecondOrder", [](Mesh & self) { self.GetGeometry()->GetRefinement().MakeSecondOrder(self); From 00747fb947601cf1e8749b4808c34551dc45e552 Mon Sep 17 00:00:00 2001 From: Umberto Zerbinati Date: Mon, 15 Jan 2024 22:43:18 +0000 Subject: [PATCH 2/3] Powell Sabin splits --- libsrc/meshing/hpref_trig.hpp | 52 +++++++++++++++++++++++++-------- libsrc/meshing/hprefinement.cpp | 8 ++++- libsrc/meshing/hprefinement.hpp | 3 +- libsrc/meshing/python_mesh.cpp | 8 +++++ 4 files changed, 57 insertions(+), 14 deletions(-) diff --git a/libsrc/meshing/hpref_trig.hpp b/libsrc/meshing/hpref_trig.hpp index 52f3582e..8c527c48 100644 --- a/libsrc/meshing/hpref_trig.hpp +++ b/libsrc/meshing/hpref_trig.hpp @@ -775,18 +775,7 @@ HPRef_Struct reftrig_3singedges = reftrig_3singedges_newels }; - - - - - - - - - - - -// HP_TRIG_3SINGEDGES +// HP_TRIG_ALFELD int reftrig_Alfeld_splitedges[][3] = { { 0, 0, 0 } @@ -818,3 +807,42 @@ HPRef_Struct reftrig_Alfeld = reftrig_Alfeld_newels }; + +// HP_TRIG_POWELL +int reftrig_Powell_splitedges[][3] = +{ + { 1, 2, 4 }, + { 2, 3, 5 }, + { 3, 1, 6 }, + { 0, 0, 0 }, +}; +int reftrig_Powell_splitfaces[][4] = +{ + { 1, 2, 3, 7 }, + { 0, 0, 0, 0 } +}; + +HPREF_ELEMENT_TYPE reftrig_Powell_newelstypes[] = +{ + HP_TRIG, HP_TRIG, HP_TRIG, HP_TRIG, HP_TRIG, HP_TRIG, + HP_NONE, +}; +int reftrig_Powell_newels[][8] = +{ + { 1, 4, 7 }, + { 4, 2, 7 }, + { 2, 5, 7 }, + { 5, 3, 7 }, + { 3, 6, 7 }, + { 6, 1, 7 }, +}; +HPRef_Struct reftrig_Powell = +{ + HP_TRIG, + reftrig_Powell_splitedges, + reftrig_Powell_splitfaces, + 0, + reftrig_Powell_newelstypes, + reftrig_Powell_newels +}; + diff --git a/libsrc/meshing/hprefinement.cpp b/libsrc/meshing/hprefinement.cpp index 1fae823f..bb250aee 100644 --- a/libsrc/meshing/hprefinement.cpp +++ b/libsrc/meshing/hprefinement.cpp @@ -185,6 +185,8 @@ namespace netgen case HP_TRIG_ALFELD: hps = &reftrig_Alfeld; break; + case HP_TRIG_POWELL: + hps = &reftrig_Powell; break; case HP_QUAD: @@ -1906,6 +1908,8 @@ bool CheckSingularities(Mesh & mesh, INDEX_2_HASHTABLE & edges, INDEX_2_HAS if (act_ref == 1 && split == SPLIT_ALFELD) sing = true; + if (act_ref == 1 && split == SPLIT_POWELL) + sing = true; if(sing==0) return(sing); int cnt_undef = 0, cnt_nonimplement = 0; @@ -1969,8 +1973,10 @@ bool CheckSingularities(Mesh & mesh, INDEX_2_HASHTABLE & edges, INDEX_2_HAS if (split == SPLIT_HP) hpel.type = ClassifyTrig(hpel, edges, edgepoint_dom, cornerpoint, edgepoint, faces, face_edges, surf_edges, facepoint, dim, fd); - else + else if (split == SPLIT_ALFELD) hpel.type = HP_TRIG_ALFELD; + else if (split == SPLIT_POWELL) + hpel.type = HP_TRIG_POWELL; dd = 2; break; diff --git a/libsrc/meshing/hprefinement.hpp b/libsrc/meshing/hprefinement.hpp index 1506cfb4..3cc7ca9e 100644 --- a/libsrc/meshing/hprefinement.hpp +++ b/libsrc/meshing/hprefinement.hpp @@ -46,6 +46,7 @@ enum HPREF_ELEMENT_TYPE { HP_TRIG_3SINGEDGES = 40, HP_TRIG_ALFELD, + HP_TRIG_POWELL, HP_QUAD = 50, HP_QUAD_SINGCORNER, @@ -347,7 +348,7 @@ public: }; -enum SplittingType { SPLIT_HP, SPLIT_ALFELD }; +enum SplittingType { SPLIT_HP, SPLIT_ALFELD, SPLIT_POWELL}; DLL_HEADER extern void HPRefinement (Mesh & mesh, Refinement * ref, SplittingType split, int levels, double fac1=0.125, bool setorders=true, bool ref_level = false); diff --git a/libsrc/meshing/python_mesh.cpp b/libsrc/meshing/python_mesh.cpp index 284b7997..886122e6 100644 --- a/libsrc/meshing/python_mesh.cpp +++ b/libsrc/meshing/python_mesh.cpp @@ -1359,6 +1359,14 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m) ::netgen::HPRefinement (self, &ref, SPLIT_ALFELD, 1, 0.5, true, true); } ), py::call_guard()) + .def ("SplitPowellSabin", FunctionPointer + ([](Mesh & self) + { + NgLock meshlock (self.MajorMutex(), true); + Refinement & ref = const_cast (self.GetGeometry()->GetRefinement()); + ::netgen::HPRefinement (self, &ref, SPLIT_POWELL, 1, 0.5, true, true); + } + ), py::call_guard()) .def ("SecondOrder", [](Mesh & self) { self.GetGeometry()->GetRefinement().MakeSecondOrder(self); From 87c4e543ad008bbb7f394de0d0b6ca6b8c43d649 Mon Sep 17 00:00:00 2001 From: Umberto Zerbinati Date: Mon, 15 Jan 2024 23:54:44 +0000 Subject: [PATCH 3/3] Introduced fac2 to fix issue with face splits --- libsrc/meshing/hprefinement.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/libsrc/meshing/hprefinement.cpp b/libsrc/meshing/hprefinement.cpp index 2c59be5d..dc7988c5 100644 --- a/libsrc/meshing/hprefinement.cpp +++ b/libsrc/meshing/hprefinement.cpp @@ -677,8 +677,9 @@ namespace netgen INDEX_3_HASHTABLE newfacepts(elements.Size()+1); // prepare new points - // fac1 = max(0.001,min(0.33,fac1)); + double fac2; + fac2 = max(0.001,min(0.33,fac1)); PrintMessage(3, " in HP-REFINEMENT with fac1 ", fac1); *testout << " in HP-REFINEMENT with fac1 " << fac1 << endl; @@ -728,8 +729,8 @@ namespace netgen { Point<3> np; for( int l=0;l<3;l++) - np(l) = (1-2*fac1)*mesh.Point(i3.I1())(l) - + fac1*mesh.Point(i3.I2())(l) + fac1*mesh.Point(i3.I3())(l); + np(l) = (1-2*fac2)*mesh.Point(i3.I1())(l) + + fac2*mesh.Point(i3.I2())(l) + fac2*mesh.Point(i3.I3())(l); int npi = mesh.AddPoint (np); newfacepts.Set (i3, npi); } @@ -817,9 +818,9 @@ namespace netgen for (int l = 0; l < 3; l++) newparam[hprs->splitfaces[j][3]-1][l] = - (1-2*fac1) * el.param[hprs->splitfaces[j][0]-1][l] + - fac1 * el.param[hprs->splitfaces[j][1]-1][l] + - fac1 * el.param[hprs->splitfaces[j][2]-1][l]; + (1-2*fac2) * el.param[hprs->splitfaces[j][0]-1][l] + + fac2 * el.param[hprs->splitfaces[j][1]-1][l] + + fac2 * el.param[hprs->splitfaces[j][2]-1][l]; j++; } // split elements