Add NetgenGeometry.RestrictH function

This commit is contained in:
Christopher Lackner 2021-09-08 22:12:45 +02:00
parent 310a316127
commit 9d48602a2a
5 changed files with 34 additions and 3 deletions

View File

@ -220,6 +220,15 @@ namespace netgen
int CSGeometry :: GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & 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);
}

View File

@ -1058,6 +1058,15 @@ namespace netgen
int SplineGeometry2d :: GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & 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;
}

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;
// 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)

View File

@ -109,6 +109,7 @@ namespace netgen
Array<unique_ptr<GeometryVertex>> vertices;
Array<unique_ptr<GeometryEdge>> edges;
Array<unique_ptr<GeometryFace>> faces;
Array<std::pair<Point<3>, double>> restricted_h;
Box<3> bounding_box;
public:
NetgenGeometry()
@ -119,6 +120,11 @@ namespace netgen
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
{
return *ref;

View File

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