diff --git a/libsrc/csg/csgeom.cpp b/libsrc/csg/csgeom.cpp index c1256a19..59f34ca7 100644 --- a/libsrc/csg/csgeom.cpp +++ b/libsrc/csg/csgeom.cpp @@ -220,7 +220,16 @@ namespace netgen int CSGeometry :: GenerateMesh (shared_ptr & mesh, MeshingParameters & mparam) { - return CSGGenerateMesh (*this, mesh, mparam); + if(restricted_h.Size()) + { + // copy so that we don't change mparam outside + MeshingParameters mp = mparam; + for(const auto& [pnt, maxh] : restricted_h) + mp.meshsize_points.Append({pnt, maxh}); + return CSGGenerateMesh (*this, mesh, mp); + } + else + return CSGGenerateMesh (*this, mesh, mparam); } class WritePrimitivesIt : public SolidIterator diff --git a/libsrc/geom2d/geometry2d.cpp b/libsrc/geom2d/geometry2d.cpp index 11ea2df9..864ffe68 100644 --- a/libsrc/geom2d/geometry2d.cpp +++ b/libsrc/geom2d/geometry2d.cpp @@ -1058,7 +1058,16 @@ namespace netgen int SplineGeometry2d :: GenerateMesh (shared_ptr & mesh, MeshingParameters & mparam) { - MeshFromSpline2D (*this, mesh, mparam); + if(restricted_h.Size()) + { + // copy so that we don't change mparam outside + MeshingParameters mp = mparam; + for(const auto& [pnt, maxh] : restricted_h) + mp.meshsize_points.Append({pnt, maxh}); + MeshFromSpline2D (*this, mesh, mp); + } + else + MeshFromSpline2D (*this, mesh, mparam); return 0; } diff --git a/libsrc/meshing/basegeom.cpp b/libsrc/meshing/basegeom.cpp index a305d478..56a79bc2 100644 --- a/libsrc/meshing/basegeom.cpp +++ b/libsrc/meshing/basegeom.cpp @@ -518,10 +518,16 @@ namespace netgen - int NetgenGeometry :: GenerateMesh (shared_ptr & mesh, MeshingParameters & mparam) + int NetgenGeometry :: GenerateMesh (shared_ptr & mesh, MeshingParameters & mp) { multithread.percent = 0; + // copy so that we don't change them outside + MeshingParameters mparam = mp; + if(restricted_h.Size()) + for(const auto& [pnt, maxh] : restricted_h) + mparam.meshsize_points.Append({pnt, maxh}); + if(mparam.perfstepsstart <= MESHCONST_ANALYSE) { if(!mesh) diff --git a/libsrc/meshing/basegeom.hpp b/libsrc/meshing/basegeom.hpp index a1ac8ac8..f7ed62ab 100644 --- a/libsrc/meshing/basegeom.hpp +++ b/libsrc/meshing/basegeom.hpp @@ -109,6 +109,7 @@ namespace netgen Array> vertices; Array> edges; Array> faces; + Array, double>> restricted_h; Box<3> bounding_box; public: NetgenGeometry() @@ -119,6 +120,11 @@ namespace netgen virtual int GenerateMesh (shared_ptr & mesh, MeshingParameters & mparam); + void RestrictH(const Point<3>& pnt, double maxh) + { + restricted_h.Append({pnt, maxh}); + } + virtual const Refinement & GetRefinement () const { return *ref; diff --git a/libsrc/meshing/python_mesh.cpp b/libsrc/meshing/python_mesh.cpp index eb6dba69..f0a761df 100644 --- a/libsrc/meshing/python_mesh.cpp +++ b/libsrc/meshing/python_mesh.cpp @@ -611,6 +611,7 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m) py::implicitly_convertible< int, PointIndex>(); py::class_> (m, "NetgenGeometry", py::dynamic_attr()) + .def("RestrictH", &NetgenGeometry::RestrictH) ; py::class_>(m, "Mesh")