mirror of
https://github.com/NGSolve/netgen.git
synced 2025-01-24 20:00:33 +05:00
Merge branch 'meshingparameters' into 'master'
Meshingparameters See merge request jschoeberl/netgen!184
This commit is contained in:
commit
ed135fc61e
@ -694,12 +694,14 @@ However, when r = 0, the top part becomes a point(tip) and meshing fails!
|
||||
res["max"] = MoveToNumpy(max);
|
||||
return res;
|
||||
}, py::call_guard<py::gil_scoped_release>())
|
||||
.def("GenerateMesh", [](shared_ptr<CSGeometry> geo, py::kwargs kwargs)
|
||||
.def("GenerateMesh", [](shared_ptr<CSGeometry> geo,
|
||||
MeshingParameters* pars, py::kwargs kwargs)
|
||||
{
|
||||
MeshingParameters mp;
|
||||
if(pars) mp = *pars;
|
||||
{
|
||||
py::gil_scoped_acquire aq;
|
||||
mp = CreateMPfromKwargs(kwargs);
|
||||
CreateMPfromKwargs(mp, kwargs);
|
||||
}
|
||||
auto mesh = make_shared<Mesh>();
|
||||
SetGlobalMesh (mesh);
|
||||
@ -708,7 +710,8 @@ However, when r = 0, the top part becomes a point(tip) and meshing fails!
|
||||
geo->FindIdenticSurfaces(1e-8 * geo->MaxSize());
|
||||
geo->GenerateMesh (mesh, mp);
|
||||
return mesh;
|
||||
}, meshingparameter_description.c_str(),
|
||||
}, py::arg("mp") = nullptr,
|
||||
meshingparameter_description.c_str(),
|
||||
py::call_guard<py::gil_scoped_release>())
|
||||
;
|
||||
|
||||
|
@ -363,12 +363,15 @@ DLL_HEADER void ExportGeom2d(py::module &m)
|
||||
//cout << i << " : " << self.splines[i]->GetPoint(0.1) << " , " << self.splines[i]->GetPoint(0.5) << endl;
|
||||
}
|
||||
}))
|
||||
.def("GenerateMesh", [](shared_ptr<SplineGeometry2d> self, py::kwargs kwargs)
|
||||
// If we change to c++17 this can become optional<MeshingParameters>
|
||||
.def("GenerateMesh", [](shared_ptr<SplineGeometry2d> self,
|
||||
MeshingParameters* pars, py::kwargs kwargs)
|
||||
{
|
||||
MeshingParameters mp;
|
||||
if(pars) mp = *pars;
|
||||
{
|
||||
py::gil_scoped_acquire aq;
|
||||
mp = CreateMPfromKwargs(kwargs);
|
||||
CreateMPfromKwargs(mp, kwargs);
|
||||
}
|
||||
auto mesh = make_shared<Mesh>();
|
||||
mesh->SetGeometry(self);
|
||||
@ -376,9 +379,10 @@ DLL_HEADER void ExportGeom2d(py::module &m)
|
||||
ng_geometry = self;
|
||||
self->GenerateMesh(mesh, mp);
|
||||
return mesh;
|
||||
}, py::call_guard<py::gil_scoped_release>(),
|
||||
meshingparameter_description.c_str())
|
||||
;
|
||||
}, py::arg("mp") = nullptr,
|
||||
py::call_guard<py::gil_scoped_release>(),
|
||||
meshingparameter_description.c_str())
|
||||
;
|
||||
|
||||
}
|
||||
|
||||
|
@ -857,16 +857,19 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m)
|
||||
self.SetMaxHDomain(maxh);
|
||||
})
|
||||
.def ("GenerateVolumeMesh",
|
||||
[](Mesh & self, py::kwargs kwargs)
|
||||
[](Mesh & self, MeshingParameters* pars,
|
||||
py::kwargs kwargs)
|
||||
{
|
||||
MeshingParameters mp;
|
||||
if(pars) mp = *pars;
|
||||
{
|
||||
py::gil_scoped_acquire acquire;
|
||||
mp = CreateMPfromKwargs(kwargs);
|
||||
CreateMPfromKwargs(mp, kwargs);
|
||||
}
|
||||
MeshVolume (mp, self);
|
||||
OptimizeVolume (mp, self);
|
||||
}, meshingparameter_description.c_str(),
|
||||
}, py::arg("mp")=nullptr,
|
||||
meshingparameter_description.c_str(),
|
||||
py::call_guard<py::gil_scoped_release>())
|
||||
|
||||
.def ("OptimizeVolumeMesh", [](Mesh & self)
|
||||
@ -1024,12 +1027,15 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m)
|
||||
.def(py::init<>())
|
||||
.def(py::init([](py::kwargs kwargs)
|
||||
{
|
||||
return CreateMPfromKwargs(kwargs);
|
||||
MeshingParameters mp;
|
||||
CreateMPfromKwargs(mp, kwargs);
|
||||
return mp;
|
||||
}), meshingparameter_description.c_str())
|
||||
.def("__str__", &ToString<MP>)
|
||||
.def_property("maxh",
|
||||
FunctionPointer ([](const MP & mp ) { return mp.maxh; }),
|
||||
FunctionPointer ([](MP & mp, double maxh) { return mp.maxh = maxh; }))
|
||||
.def_property("maxh", [](const MP & mp ) { return mp.maxh; },
|
||||
[](MP & mp, double maxh) { return mp.maxh = maxh; })
|
||||
.def_property("grading", [](const MP & mp ) { return mp.grading; },
|
||||
[](MP & mp, double grading) { return mp.grading = grading; })
|
||||
.def("RestrictH", FunctionPointer
|
||||
([](MP & mp, double x, double y, double z, double h)
|
||||
{
|
||||
|
@ -80,9 +80,8 @@ elsizeweight: float = 0.2
|
||||
|
||||
)delimiter";
|
||||
|
||||
inline MeshingParameters CreateMPfromKwargs(py::kwargs kwargs)
|
||||
inline void CreateMPfromKwargs(MeshingParameters& mp, py::kwargs kwargs)
|
||||
{
|
||||
MeshingParameters mp;
|
||||
if(kwargs.contains("optimize3d"))
|
||||
mp.optimize3d = py::cast<string>(kwargs["optimize3d"]);
|
||||
if(kwargs.contains("optsteps3d"))
|
||||
@ -165,6 +164,5 @@ elsizeweight: float = 0.2
|
||||
mp.inverttrigs = py::cast<bool>(kwargs["inverttrigs"]);
|
||||
if(kwargs.contains("autozrefine"))
|
||||
mp.autozrefine = py::cast<bool>(kwargs["autozrefine"]);
|
||||
return mp;
|
||||
}
|
||||
} // namespace netgen
|
||||
|
@ -124,12 +124,14 @@ DLL_HEADER void ExportNgOCC(py::module &m)
|
||||
res["max"] = MoveToNumpy(max);
|
||||
return res;
|
||||
}, py::call_guard<py::gil_scoped_release>())
|
||||
.def("GenerateMesh", [](shared_ptr<OCCGeometry> geo, py::kwargs kwargs)
|
||||
.def("GenerateMesh", [](shared_ptr<OCCGeometry> geo,
|
||||
MeshingParameters* pars, py::kwargs kwargs)
|
||||
{
|
||||
MeshingParameters mp;
|
||||
if(pars) mp = *pars;
|
||||
{
|
||||
py::gil_scoped_acquire aq;
|
||||
mp = CreateMPfromKwargs(kwargs);
|
||||
CreateMPfromKwargs(mp, kwargs);
|
||||
}
|
||||
auto mesh = make_shared<Mesh>();
|
||||
SetGlobalMesh(mesh);
|
||||
@ -137,7 +139,7 @@ DLL_HEADER void ExportNgOCC(py::module &m)
|
||||
ng_geometry = geo;
|
||||
geo->GenerateMesh(mesh,mp);
|
||||
return mesh;
|
||||
},
|
||||
}, py::arg("mp") = nullptr,
|
||||
py::call_guard<py::gil_scoped_release>(),
|
||||
meshingparameter_description.c_str())
|
||||
;
|
||||
|
@ -78,12 +78,14 @@ DLL_HEADER void ExportSTL(py::module & m)
|
||||
res["max"] = MoveToNumpy(max);
|
||||
return res;
|
||||
}, py::call_guard<py::gil_scoped_release>())
|
||||
.def("GenerateMesh", [] (shared_ptr<STLGeometry> geo, py::kwargs kwargs)
|
||||
.def("GenerateMesh", [] (shared_ptr<STLGeometry> geo,
|
||||
MeshingParameters* pars, py::kwargs kwargs)
|
||||
{
|
||||
MeshingParameters mp;
|
||||
if(pars) mp = *pars;
|
||||
{
|
||||
py::gil_scoped_acquire aq;
|
||||
mp = CreateMPfromKwargs(kwargs);
|
||||
CreateMPfromKwargs(mp, kwargs);
|
||||
}
|
||||
auto mesh = make_shared<Mesh>();
|
||||
SetGlobalMesh(mesh);
|
||||
@ -91,7 +93,7 @@ DLL_HEADER void ExportSTL(py::module & m)
|
||||
ng_geometry = geo;
|
||||
geo->GenerateMesh(mesh,mp);
|
||||
return mesh;
|
||||
},
|
||||
}, py::arg("mp") = nullptr,
|
||||
py::call_guard<py::gil_scoped_release>(),
|
||||
meshingparameter_description.c_str())
|
||||
;
|
||||
|
@ -1,5 +1,6 @@
|
||||
from .libngpy._csg import *
|
||||
from .libngpy._meshing import Pnt, Vec, Trafo
|
||||
from .meshing import meshsize
|
||||
|
||||
try:
|
||||
from . import csgvis
|
||||
|
@ -1,4 +1,5 @@
|
||||
from .libngpy._geom2d import SplineGeometry
|
||||
from .meshing import meshsize
|
||||
|
||||
unit_square = SplineGeometry()
|
||||
_pnts = [ (0,0), (1,0), (1,1), (0,1) ]
|
||||
|
@ -1 +1,22 @@
|
||||
from .libngpy._meshing import *
|
||||
|
||||
class _MeshsizeObject:
|
||||
pass
|
||||
|
||||
meshsize = _MeshsizeObject()
|
||||
|
||||
meshsize.very_coarse = MeshingParameters(curvaturesafety=1,
|
||||
segmentsperedge=0.3,
|
||||
grading=0.7)
|
||||
meshsize.coarse = MeshingParameters(curvaturesafety=1.5,
|
||||
segmentsperedge=0.5,
|
||||
grading=0.5)
|
||||
meshsize.moderate = MeshingParameters(curvaturesafety=2,
|
||||
segmentsperedge=1,
|
||||
grading=0.3)
|
||||
meshsize.fine = MeshingParameters(curvaturesafety=3,
|
||||
segmentsperedge=2,
|
||||
grading=0.2)
|
||||
meshsize.very_fine = MeshingParameters(curvaturesafety=5,
|
||||
segmentsperedge=3,
|
||||
grading=0.1)
|
||||
|
@ -1 +1,2 @@
|
||||
from .libngpy._NgOCC import *
|
||||
from .meshing import meshsize
|
||||
|
@ -1 +1,2 @@
|
||||
from netgen.libngpy._stl import *
|
||||
from .meshing import meshsize
|
||||
|
Loading…
Reference in New Issue
Block a user