Merge branch 'geo_restricth' into 'master'

Add NetgenGeometry.RestrictH function

See merge request jschoeberl/netgen!410
This commit is contained in:
Joachim Schöberl 2021-09-08 20:41:04 +00:00
commit 454b8ea760
5 changed files with 34 additions and 3 deletions

View File

@ -220,7 +220,16 @@ namespace netgen
int CSGeometry :: GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam) int CSGeometry :: GenerateMesh (shared_ptr<Mesh> & 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 class WritePrimitivesIt : public SolidIterator

View File

@ -1058,7 +1058,16 @@ namespace netgen
int SplineGeometry2d :: GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam) int SplineGeometry2d :: GenerateMesh (shared_ptr<Mesh> & 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; return 0;
} }

View File

@ -518,10 +518,16 @@ namespace netgen
int NetgenGeometry :: GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam) int NetgenGeometry :: GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mp)
{ {
multithread.percent = 0; 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(mparam.perfstepsstart <= MESHCONST_ANALYSE)
{ {
if(!mesh) if(!mesh)

View File

@ -109,6 +109,7 @@ namespace netgen
Array<unique_ptr<GeometryVertex>> vertices; Array<unique_ptr<GeometryVertex>> vertices;
Array<unique_ptr<GeometryEdge>> edges; Array<unique_ptr<GeometryEdge>> edges;
Array<unique_ptr<GeometryFace>> faces; Array<unique_ptr<GeometryFace>> faces;
Array<std::pair<Point<3>, double>> restricted_h;
Box<3> bounding_box; Box<3> bounding_box;
public: public:
NetgenGeometry() NetgenGeometry()
@ -119,6 +120,11 @@ namespace netgen
virtual int GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam); virtual int GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam);
void RestrictH(const Point<3>& pnt, double maxh)
{
restricted_h.Append({pnt, maxh});
}
virtual const Refinement & GetRefinement () const virtual const Refinement & GetRefinement () const
{ {
return *ref; return *ref;

View File

@ -611,6 +611,7 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m)
py::implicitly_convertible< int, PointIndex>(); py::implicitly_convertible< int, PointIndex>();
py::class_<NetgenGeometry, shared_ptr<NetgenGeometry>> (m, "NetgenGeometry", py::dynamic_attr()) py::class_<NetgenGeometry, shared_ptr<NetgenGeometry>> (m, "NetgenGeometry", py::dynamic_attr())
.def("RestrictH", &NetgenGeometry::RestrictH)
; ;
py::class_<Mesh,shared_ptr<Mesh>>(m, "Mesh") py::class_<Mesh,shared_ptr<Mesh>>(m, "Mesh")