From e8712aa8ae7c82afee793da8fd248cfc29a58c2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joachim=20Sch=C3=B6berl?= Date: Wed, 31 May 2017 23:44:50 +0200 Subject: [PATCH] export Mesh.SecondOrder --- libsrc/meshing/python_mesh.cpp | 17 +++++++++++++++++ py_tutorials/exportNeutral.py | 4 ++-- py_tutorials/mesh.py | 3 ++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/libsrc/meshing/python_mesh.cpp b/libsrc/meshing/python_mesh.cpp index 774aae17..90037fd5 100644 --- a/libsrc/meshing/python_mesh.cpp +++ b/libsrc/meshing/python_mesh.cpp @@ -237,6 +237,14 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m) li.append (py::cast(self[i])); return li; })) + .def_property_readonly("points", + FunctionPointer ([](const Element & self) -> py::list + { + py::list li; + for (int i = 0; i < self.GetNP(); i++) + li.append (py::cast(self[i])); + return li; + })) ; py::class_(m, "Element2D") @@ -601,6 +609,15 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m) Refinement().Refine(self); })) + .def ("SecondOrder", FunctionPointer + ([](Mesh & self) + { + if (self.GetGeometry()) + self.GetGeometry()->GetRefinement().MakeSecondOrder(self); + else + Refinement().MakeSecondOrder(self); + })) + .def ("SetGeometry", FunctionPointer ([](Mesh & self, shared_ptr geo) { diff --git a/py_tutorials/exportNeutral.py b/py_tutorials/exportNeutral.py index ad58ea41..5ed1928f 100644 --- a/py_tutorials/exportNeutral.py +++ b/py_tutorials/exportNeutral.py @@ -17,8 +17,8 @@ def Export (mesh, filename): print (len(volels), file=f) for el in volels: print (el.index, end=" ", file=f) - for j in el.vertices: - print (j.nr, end=" ", file=f) + for p in el.points: + print (p.nr, end=" ", file=f) print(file=f) diff --git a/py_tutorials/mesh.py b/py_tutorials/mesh.py index 1337a23a..c4937395 100644 --- a/py_tutorials/mesh.py +++ b/py_tutorials/mesh.py @@ -8,7 +8,7 @@ param.maxh = 10 print (param) m1 = GenerateMesh (geo, param) - +m1.SecondOrder() import exportNeutral exportNeutral.Export (m1, "shaft.mesh") @@ -16,3 +16,4 @@ exportNeutral.Export (m1, "shaft.mesh") Save (m1, "mesh.vol", geo) +