copy mesh from py

This commit is contained in:
Joachim Schöberl 2019-04-10 14:13:12 +02:00
parent 11259d0a88
commit 2794dda996
2 changed files with 24 additions and 9 deletions

View File

@ -90,6 +90,7 @@ namespace netgen
Mesh & Mesh :: operator= (const Mesh & mesh2) Mesh & Mesh :: operator= (const Mesh & mesh2)
{ {
dimension = mesh2.dimension;
points = mesh2.points; points = mesh2.points;
// eltyps = mesh2.eltyps; // eltyps = mesh2.eltyps;
segments = mesh2.segments; segments = mesh2.segments;

View File

@ -17,6 +17,8 @@ namespace netgen
{ {
extern bool netgen_executable_started; extern bool netgen_executable_started;
extern shared_ptr<NetgenGeometry> ng_geometry; extern shared_ptr<NetgenGeometry> ng_geometry;
extern void Optimize2d (Mesh & mesh, MeshingParameters & mp);
#ifdef PARALLEL #ifdef PARALLEL
/** we need allreduce in python-wrapped communicators **/ /** we need allreduce in python-wrapped communicators **/
template <typename T> template <typename T>
@ -865,13 +867,20 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m)
}, },
py::arg("mp")=NGDummyArgument(),py::call_guard<py::gil_scoped_release>()) py::arg("mp")=NGDummyArgument(),py::call_guard<py::gil_scoped_release>())
.def ("OptimizeVolumeMesh", FunctionPointer .def ("OptimizeVolumeMesh", [](Mesh & self)
([](Mesh & self)
{ {
MeshingParameters mp; MeshingParameters mp;
mp.optsteps3d = 5; mp.optsteps3d = 5;
OptimizeVolume (mp, self); OptimizeVolume (mp, self);
}),py::call_guard<py::gil_scoped_release>()) },py::call_guard<py::gil_scoped_release>())
.def ("OptimizeMesh2d", [](Mesh & self)
{
self.CalcLocalH(0.5);
MeshingParameters mp;
mp.optsteps2d = 5;
Optimize2d (self, mp);
},py::call_guard<py::gil_scoped_release>())
.def ("Refine", FunctionPointer .def ("Refine", FunctionPointer
([](Mesh & self) ([](Mesh & self)
@ -975,12 +984,17 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m)
}, },
py::arg("name"), py::arg("set")=true) py::arg("name"), py::arg("set")=true)
.def ("Scale", FunctionPointer([](Mesh & self, double factor) .def ("Scale", [](Mesh & self, double factor)
{ {
for(auto i = 0; i<self.GetNP();i++) for(auto i = 0; i<self.GetNP();i++)
self.Point(i).Scale(factor); self.Point(i).Scale(factor);
})) })
.def ("Copy", [](Mesh & self)
{
auto m2 = make_shared<Mesh> ();
*m2 = self;
return m2;
})
; ;
m.def("ImportMesh", [](const string& filename) m.def("ImportMesh", [](const string& filename)