diff --git a/libsrc/include/nginterface_v2.hpp b/libsrc/include/nginterface_v2.hpp index 54b5c06125a6653b8e704d0db2c59be1bf3bd65d..3c2e209b33e52a8c22d4dc020f7d344260b9b094 100644 --- a/libsrc/include/nginterface_v2.hpp +++ b/libsrc/include/nginterface_v2.hpp @@ -641,6 +641,12 @@ namespace netgen Ng_Buffer<int[2]> GetPeriodicVertices(int idnr) const override; inline int GetTimeStamp() const override; + + + virtual shared_ptr<Mesh> GetMesh () const override { return nullptr; } + virtual shared_ptr<Mesh> SelectMesh () const override{ return nullptr; } + bool Valid () override { return true; } + }; class DLL_HEADER Ngx_netgen_Mesh : public Ngx_Mesh @@ -845,7 +851,6 @@ DLL_HEADER Ngx_netgen_Mesh * LoadMesh (const string & filename); - #ifdef HAVE_NETGEN_SOURCES #include <meshing.hpp> diff --git a/libsrc/mymesh/mymesh_python.cpp b/libsrc/mymesh/mymesh_python.cpp index fe097621ba71eea388efa9d37860bef01faf5037..677e464ff90b071d001f8f05d7091406ef76ee78 100644 --- a/libsrc/mymesh/mymesh_python.cpp +++ b/libsrc/mymesh/mymesh_python.cpp @@ -3,6 +3,12 @@ #include "../general/ngpython.hpp" #include "mymeshclass.hpp" +#include <meshing.hpp> +// #include "nginterface.h" +#include "nginterface.h" +#include "../include/nginterface_v2.hpp" +// #include <meshing.hpp> + #ifdef WIN32 #define DLL_HEADER __declspec(dllimport) #else @@ -13,9 +19,15 @@ using namespace netgen; DLL_HEADER void ExportMyMesh(py::module &m) { - py::class_<MyMesh> (m, "MyMesh") + py::class_<Ngx_Mesh,shared_ptr<Ngx_Mesh>> (m, "Ngx_Mesh"); + //.def(py::init<std::size_t, std::size_t, std::size_t>()); + + py::class_<MyMesh,shared_ptr<MyMesh>> (m, "MyMesh") .def(py::init<std::size_t, std::size_t, std::size_t>()); + py::class_<Ngx_MyMesh,shared_ptr<Ngx_MyMesh>,Ngx_Mesh> (m, "Ngx_MyMesh") + .def(py::init<shared_ptr<MyMesh>>()); + py::class_<MyMesh::Node> (m, "Node") .def("__str__", &MyMesh::Node::print); @@ -33,4 +45,4 @@ PYBIND11_MODULE(libmesh, m) { ExportMyMesh(m); } -#endif \ No newline at end of file +#endif diff --git a/libsrc/mymesh/mymeshclass.hpp b/libsrc/mymesh/mymeshclass.hpp index 537a54db2987b8457bf045c65c6faa62066dfccf..ef5abf21b6e8845f838d228dc862375d9fa270bd 100644 --- a/libsrc/mymesh/mymeshclass.hpp +++ b/libsrc/mymesh/mymeshclass.hpp @@ -1,6 +1,4 @@ -#ifndef MYMESHCLASS -#define MYMESHCLASS -#endif +#pragma once #include <cstdlib> #include <memory> @@ -220,4 +218,4 @@ std::ostream &operator<<(std::ostream &os, const MyMesh::Edge &edge); std::ostream &operator<<(std::ostream &os, const MyMesh::Face &face); std::ostream &operator<<(std::ostream &os, const MyMesh::Volume &volume); -} \ No newline at end of file +} diff --git a/libsrc/mymesh/mymeshclasstest.cpp b/libsrc/mymesh/mymeshclasstest.cpp index 16b43f2c12faf3ce026acd23ae946f73c461946b..2efb312dbff00708bb41dd5ffaa789875c0d150a 100644 --- a/libsrc/mymesh/mymeshclasstest.cpp +++ b/libsrc/mymesh/mymeshclasstest.cpp @@ -1,9 +1,13 @@ #include "mymeshclass.hpp" #include <iostream> +#include <meshing.hpp> +#include <nginterface.h> +#include <nginterface_v2.hpp> int main() { - netgen::MyMesh m = netgen::MyMesh(3, 3, 3); + auto spm = make_shared<netgen::MyMesh>(3, 3, 3); + netgen::MyMesh & m(*spm); std::cout << "Number of Nodes:" << m.getNumNodes() << "\n"; for (auto i : m.getNodes()) { @@ -50,4 +54,6 @@ int main() std::cout << j << " "; std::cout << "\n\n"; } -} \ No newline at end of file + + netgen::Ngx_MyMesh ngsmym(spm); +} diff --git a/libsrc/mymesh/mytest.py b/libsrc/mymesh/mytest.py new file mode 100644 index 0000000000000000000000000000000000000000..4954d211c388485ec4d8b4e1e9d4caa7fe114572 --- /dev/null +++ b/libsrc/mymesh/mytest.py @@ -0,0 +1,46 @@ +#import netgen.gui +#from ngsolve import * +#from netgen.csg import unit_cube +#from ngsolve.meshes import * + +#mesh = MakeQuadMesh(nx=5,ny=5) +#asdf + +# for v in mesh.vertices: +# print (v, v.point) + +# input("step 1 done") + +# for e in mesh.edges: +# print (e, e.elements) + +# input("step 2 done") + +# for el in mesh.Elements(VOL): +# print (el, el.vertices, el.edges) + +# input("step 3 done") + +# for el in mesh.Elements(BND): +# print (el, el.vertices, el.edges) + +# input("step 4 done") + + +# V=H1(mesh,order=1) +# gfu = GridFunction(V) +# gfu.Set(sin(10*x)) +# integral = Integrate(gfu,mesh) + +# Draw(gfu,mesh,"u") +# print(integral, " =!= ", 0.183129283601153) + + +from netgen.mymesh import * + +mesh = MyMesh(2,2,2) +ngxmymesh = Ngx_MyMesh(mesh) + +from ngsolve import * +ngsmesh = Mesh(ngxmymesh) + diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 96a9cdc75f73b970a4eeee65eb7c50bb998d76e6..c6ce69d36661ef1f4525738212fd68ca97e921c6 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -7,7 +7,7 @@ configure_file(__init__.py ${CMAKE_CURRENT_BINARY_DIR}/__init__.py @ONLY) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/__init__.py - meshing.py csg.py geom2d.py stl.py gui.py NgOCC.py read_gmsh.py + meshing.py csg.py geom2d.py stl.py gui.py NgOCC.py read_gmsh.py mymesh.py DESTINATION ${NG_INSTALL_DIR_PYTHON}/${NG_INSTALL_SUFFIX} COMPONENT netgen ) diff --git a/python/mymesh.py b/python/mymesh.py new file mode 100644 index 0000000000000000000000000000000000000000..b36add2816f346e8809e641e68764400cb615483 --- /dev/null +++ b/python/mymesh.py @@ -0,0 +1 @@ +from netgen.libngpy._mymesh import *