2019-08-06 20:38:44 +05:00
|
|
|
#ifndef NETGEN_MESHING_PYTHON_MESH_HPP
|
|
|
|
#define NETGEN_MESHING_PYTHON_MESH_HPP
|
2019-07-26 02:25:58 +05:00
|
|
|
|
2019-08-06 20:38:44 +05:00
|
|
|
#include <core/python_ngcore.hpp>
|
2019-08-23 16:26:14 +05:00
|
|
|
|
2019-07-26 02:25:58 +05:00
|
|
|
#include "meshing.hpp"
|
|
|
|
|
|
|
|
namespace netgen
|
|
|
|
{
|
|
|
|
// TODO: Clarify a lot of these parameters
|
|
|
|
static string meshingparameter_description = R"delimiter(
|
|
|
|
Meshing Parameters
|
|
|
|
-------------------
|
|
|
|
|
|
|
|
maxh: float = 1e10
|
|
|
|
Global upper bound for mesh size.
|
|
|
|
|
|
|
|
grading: float = 0.3
|
|
|
|
Mesh grading how fast the local mesh size can change.
|
|
|
|
|
|
|
|
meshsizefilename: str = None
|
|
|
|
Load meshsize from file. Can set local mesh size for points
|
|
|
|
and along edges. File must have the format:
|
|
|
|
|
|
|
|
nr_points
|
|
|
|
x1, y1, z1, meshsize
|
|
|
|
x2, y2, z2, meshsize
|
|
|
|
...
|
|
|
|
xn, yn, zn, meshsize
|
|
|
|
|
|
|
|
nr_edges
|
|
|
|
x11, y11, z11, x12, y12, z12, meshsize
|
|
|
|
...
|
|
|
|
xn1, yn1, zn1, xn2, yn2, zn2, meshsize
|
|
|
|
|
|
|
|
segmentsperedge: float = 1.
|
|
|
|
Minimal number of segments per edge.
|
|
|
|
|
2019-09-02 19:51:32 +05:00
|
|
|
quad_dominated: bool = False
|
2019-07-26 02:25:58 +05:00
|
|
|
Quad-dominated surface meshing.
|
|
|
|
|
|
|
|
blockfill: bool = True
|
|
|
|
Do fast blockfilling.
|
|
|
|
|
|
|
|
filldist: float = 0.1
|
|
|
|
Block fill up to distance
|
|
|
|
|
|
|
|
delaunay: bool = True
|
|
|
|
Use delaunay meshing.
|
|
|
|
|
|
|
|
Optimization Parameters
|
|
|
|
-----------------------
|
|
|
|
|
|
|
|
optimize3d: str = "cmdmustm"
|
|
|
|
3d optimization strategy:
|
|
|
|
m .. move nodes
|
|
|
|
M .. move nodes, cheap functional
|
|
|
|
s .. swap faces
|
|
|
|
c .. combine elements
|
|
|
|
d .. divide elements
|
|
|
|
p .. plot, no pause
|
|
|
|
P .. plot, Pause
|
|
|
|
h .. Histogramm, no pause
|
|
|
|
H .. Histogramm, pause
|
|
|
|
|
|
|
|
optsteps3d: int = 3
|
|
|
|
Number of 3d optimization steps.
|
|
|
|
|
2019-10-08 19:46:16 +05:00
|
|
|
optimize2d: str = "smcmSmcmSmcm"
|
2019-07-26 02:25:58 +05:00
|
|
|
2d optimization strategy:
|
|
|
|
s .. swap, opt 6 lines/node
|
|
|
|
S .. swap, optimal elements
|
|
|
|
m .. move nodes
|
|
|
|
p .. plot, no pause
|
|
|
|
P .. plot, pause
|
|
|
|
c .. combine
|
|
|
|
|
|
|
|
optsteps2d: int = 3
|
|
|
|
Number of 2d optimization steps.
|
|
|
|
|
|
|
|
elsizeweight: float = 0.2
|
|
|
|
Weight of element size w.r.t. element shape in optimization.
|
|
|
|
|
|
|
|
)delimiter";
|
|
|
|
|
2019-08-06 13:42:53 +05:00
|
|
|
inline void CreateMPfromKwargs(MeshingParameters& mp, py::kwargs kwargs, bool throw_if_not_all_parsed=true)
|
2019-07-26 19:51:54 +05:00
|
|
|
{
|
|
|
|
if(kwargs.contains("optimize3d"))
|
2019-08-02 19:22:53 +05:00
|
|
|
mp.optimize3d = py::cast<string>(kwargs.attr("pop")("optimize3d"));
|
2019-07-26 19:51:54 +05:00
|
|
|
if(kwargs.contains("optsteps3d"))
|
2019-08-02 19:22:53 +05:00
|
|
|
mp.optsteps3d = py::cast<int>(kwargs.attr("pop")("optsteps3d"));
|
2019-07-26 19:51:54 +05:00
|
|
|
if(kwargs.contains("optimize2d"))
|
2019-08-02 19:22:53 +05:00
|
|
|
mp.optimize2d = py::cast<string>(kwargs.attr("pop")("optimize2d"));
|
2019-07-26 19:51:54 +05:00
|
|
|
if(kwargs.contains("optsteps2d"))
|
2019-08-02 19:22:53 +05:00
|
|
|
mp.optsteps2d = py::cast<int>(kwargs.attr("pop")("optsteps2d"));
|
2019-07-26 19:51:54 +05:00
|
|
|
if(kwargs.contains("opterrpow"))
|
2019-08-02 19:22:53 +05:00
|
|
|
mp.opterrpow = py::cast<double>(kwargs.attr("pop")("opterrpow"));
|
2019-07-26 19:51:54 +05:00
|
|
|
if(kwargs.contains("blockfill"))
|
2019-08-02 19:22:53 +05:00
|
|
|
mp.blockfill = py::cast<bool>(kwargs.attr("pop")("blockfill"));
|
2019-07-26 19:51:54 +05:00
|
|
|
if(kwargs.contains("filldist"))
|
2019-08-02 19:22:53 +05:00
|
|
|
mp.filldist = py::cast<double>(kwargs.attr("pop")("filldist"));
|
2019-07-26 19:51:54 +05:00
|
|
|
if(kwargs.contains("safety"))
|
2019-08-02 19:22:53 +05:00
|
|
|
mp.safety = py::cast<double>(kwargs.attr("pop")("safety"));
|
2019-07-26 19:51:54 +05:00
|
|
|
if(kwargs.contains("relinnersafety"))
|
2019-08-02 19:22:53 +05:00
|
|
|
mp.relinnersafety = py::cast<double>(kwargs.attr("pop")("relinnersafety"));
|
2019-07-26 19:51:54 +05:00
|
|
|
if(kwargs.contains("uselocalh"))
|
2019-08-02 19:22:53 +05:00
|
|
|
mp.uselocalh = py::cast<bool>(kwargs.attr("pop")("uselocalh"));
|
2019-07-26 19:51:54 +05:00
|
|
|
if(kwargs.contains("grading"))
|
2019-08-02 19:22:53 +05:00
|
|
|
mp.grading = py::cast<double>(kwargs.attr("pop")("grading"));
|
2019-07-26 19:51:54 +05:00
|
|
|
if(kwargs.contains("delaunay"))
|
2019-08-02 19:22:53 +05:00
|
|
|
mp.delaunay = py::cast<bool>(kwargs.attr("pop")("delaunay"));
|
2019-07-26 19:51:54 +05:00
|
|
|
if(kwargs.contains("maxh"))
|
2019-08-02 19:22:53 +05:00
|
|
|
mp.maxh = py::cast<double>(kwargs.attr("pop")("maxh"));
|
2019-07-26 19:51:54 +05:00
|
|
|
if(kwargs.contains("minh"))
|
2019-08-02 19:22:53 +05:00
|
|
|
mp.minh = py::cast<double>(kwargs.attr("pop")("minh"));
|
2019-07-26 19:51:54 +05:00
|
|
|
if(kwargs.contains("meshsizefilename"))
|
2019-08-02 19:22:53 +05:00
|
|
|
mp.meshsizefilename = py::cast<string>(kwargs.attr("pop")("meshsizefilename"));
|
2019-07-26 19:51:54 +05:00
|
|
|
if(kwargs.contains("startinsurface"))
|
2019-08-02 19:22:53 +05:00
|
|
|
mp.startinsurface = py::cast<bool>(kwargs.attr("pop")("startinsurface"));
|
2019-07-26 19:51:54 +05:00
|
|
|
if(kwargs.contains("checkoverlap"))
|
2019-08-02 19:22:53 +05:00
|
|
|
mp.checkoverlap = py::cast<bool>(kwargs.attr("pop")("checkoverlap"));
|
2019-07-26 19:51:54 +05:00
|
|
|
if(kwargs.contains("checkoverlappingboundary"))
|
2019-08-02 19:22:53 +05:00
|
|
|
mp.checkoverlappingboundary = py::cast<bool>(kwargs.attr("pop")("checkoverlappingboundary"));
|
2019-07-26 19:51:54 +05:00
|
|
|
if(kwargs.contains("checkchartboundary"))
|
2019-08-02 19:22:53 +05:00
|
|
|
mp.checkchartboundary = py::cast<bool>(kwargs.attr("pop")("checkchartboundary"));
|
2019-07-26 19:51:54 +05:00
|
|
|
if(kwargs.contains("curvaturesafety"))
|
2019-08-02 19:22:53 +05:00
|
|
|
mp.curvaturesafety = py::cast<double>(kwargs.attr("pop")("curvaturesafety"));
|
2019-07-26 19:51:54 +05:00
|
|
|
if(kwargs.contains("segmentsperedge"))
|
2019-08-02 19:22:53 +05:00
|
|
|
mp.segmentsperedge = py::cast<double>(kwargs.attr("pop")("segmentsperedge"));
|
2019-07-26 19:51:54 +05:00
|
|
|
if(kwargs.contains("parthread"))
|
2019-08-02 19:22:53 +05:00
|
|
|
mp.parthread = py::cast<bool>(kwargs.attr("pop")("parthread"));
|
2019-07-26 19:51:54 +05:00
|
|
|
if(kwargs.contains("elsizeweight"))
|
2019-08-02 19:22:53 +05:00
|
|
|
mp.elsizeweight = py::cast<double>(kwargs.attr("pop")("elsizeweight"));
|
2019-07-26 19:51:54 +05:00
|
|
|
if(kwargs.contains("perfstepsstart"))
|
2019-08-02 19:22:53 +05:00
|
|
|
mp.perfstepsstart = py::cast<int>(kwargs.attr("pop")("perfstepsstart"));
|
2019-07-26 19:51:54 +05:00
|
|
|
if(kwargs.contains("perfstepsend"))
|
2019-08-02 19:22:53 +05:00
|
|
|
mp.perfstepsend = py::cast<int>(kwargs.attr("pop")("perfstepsend"));
|
2019-07-26 19:51:54 +05:00
|
|
|
if(kwargs.contains("giveuptol2d"))
|
2019-08-02 19:22:53 +05:00
|
|
|
mp.giveuptol2d = py::cast<int>(kwargs.attr("pop")("giveuptol2d"));
|
2019-07-26 19:51:54 +05:00
|
|
|
if(kwargs.contains("giveuptol"))
|
2019-08-02 19:22:53 +05:00
|
|
|
mp.giveuptol = py::cast<int>(kwargs.attr("pop")("giveuptol"));
|
2019-07-26 19:51:54 +05:00
|
|
|
if(kwargs.contains("maxoutersteps"))
|
2019-08-02 19:22:53 +05:00
|
|
|
mp.maxoutersteps = py::cast<int>(kwargs.attr("pop")("maxoutersteps"));
|
2019-07-26 19:51:54 +05:00
|
|
|
if(kwargs.contains("starshapeclass"))
|
2019-08-02 19:22:53 +05:00
|
|
|
mp.starshapeclass = py::cast<int>(kwargs.attr("pop")("starshapeclass"));
|
2019-07-26 19:51:54 +05:00
|
|
|
if(kwargs.contains("baseelnp"))
|
2019-08-02 19:22:53 +05:00
|
|
|
mp.baseelnp = py::cast<int>(kwargs.attr("pop")("baseelnp"));
|
2019-07-26 19:51:54 +05:00
|
|
|
if(kwargs.contains("sloppy"))
|
2019-08-06 13:44:58 +05:00
|
|
|
mp.sloppy = py::cast<int>(kwargs.attr("pop")("sloppy"));
|
2019-07-26 19:51:54 +05:00
|
|
|
if(kwargs.contains("badellimit"))
|
2019-08-02 19:22:53 +05:00
|
|
|
mp.badellimit = py::cast<double>(kwargs.attr("pop")("badellimit"));
|
2019-07-26 19:51:54 +05:00
|
|
|
if(kwargs.contains("check_impossible"))
|
2019-08-02 19:22:53 +05:00
|
|
|
mp.check_impossible = py::cast<bool>(kwargs.attr("pop")("check_impossible"));
|
2019-07-26 19:51:54 +05:00
|
|
|
if(kwargs.contains("only3D_domain_nr"))
|
2019-08-02 19:22:53 +05:00
|
|
|
mp.only3D_domain_nr = py::cast<int>(kwargs.attr("pop")("only3D_domain_nr"));
|
2019-07-26 19:51:54 +05:00
|
|
|
if(kwargs.contains("secondorder"))
|
2019-08-02 19:22:53 +05:00
|
|
|
mp.secondorder = py::cast<bool>(kwargs.attr("pop")("secondorder"));
|
2019-07-26 19:51:54 +05:00
|
|
|
if(kwargs.contains("elementorder"))
|
2019-08-02 19:22:53 +05:00
|
|
|
mp.elementorder = py::cast<int>(kwargs.attr("pop")("elementorder"));
|
2019-07-26 19:51:54 +05:00
|
|
|
if(kwargs.contains("quad"))
|
2019-09-02 19:51:32 +05:00
|
|
|
{
|
|
|
|
cout << "WARNING: Meshing parameter 'quad' is deprecated, use 'quad_dominated' instead!" << endl;
|
|
|
|
mp.quad = py::cast<bool>(kwargs.attr("pop")("quad"));
|
|
|
|
}
|
|
|
|
if(kwargs.contains("quad_dominated"))
|
|
|
|
mp.quad = py::cast<bool>(kwargs.attr("pop")("quad_dominated"));
|
2019-07-26 19:51:54 +05:00
|
|
|
if(kwargs.contains("try_hexes"))
|
2019-08-02 19:22:53 +05:00
|
|
|
mp.try_hexes = py::cast<bool>(kwargs.attr("pop")("try_hexes"));
|
2019-07-26 19:51:54 +05:00
|
|
|
if(kwargs.contains("inverttets"))
|
2019-08-02 19:22:53 +05:00
|
|
|
mp.inverttets = py::cast<bool>(kwargs.attr("pop")("inverttets"));
|
2019-07-26 19:51:54 +05:00
|
|
|
if(kwargs.contains("inverttrigs"))
|
2019-08-02 19:22:53 +05:00
|
|
|
mp.inverttrigs = py::cast<bool>(kwargs.attr("pop")("inverttrigs"));
|
2019-07-26 19:51:54 +05:00
|
|
|
if(kwargs.contains("autozrefine"))
|
2019-08-02 19:22:53 +05:00
|
|
|
mp.autozrefine = py::cast<bool>(kwargs.attr("pop")("autozrefine"));
|
2019-09-26 19:15:50 +05:00
|
|
|
if(kwargs.contains("parallel_meshing"))
|
|
|
|
mp.parallel_meshing = py::cast<bool>(kwargs.attr("pop")("parallel_meshing"));
|
|
|
|
if(kwargs.contains("nthreads"))
|
|
|
|
mp.nthreads = py::cast<int>(kwargs.attr("pop")("nthreads"));
|
2019-11-04 23:34:46 +05:00
|
|
|
if(kwargs.contains("closeedgefac"))
|
|
|
|
mp.closeedgefac = py::cast<optional<double>>(kwargs.attr("pop")("closeedgefac"));
|
2019-08-02 19:22:53 +05:00
|
|
|
if(kwargs.size())
|
2019-08-06 13:42:53 +05:00
|
|
|
{
|
|
|
|
if(throw_if_not_all_parsed)
|
|
|
|
throw Exception(string("Not all kwargs given to GenerateMesh could be parsed:") + string(py::str(kwargs)));
|
2019-08-06 20:38:44 +05:00
|
|
|
mp.geometrySpecificParameters = CreateFlagsFromKwArgs(kwargs);
|
2019-08-06 13:42:53 +05:00
|
|
|
}
|
2019-07-26 19:51:54 +05:00
|
|
|
}
|
2019-07-26 02:25:58 +05:00
|
|
|
} // namespace netgen
|
2019-08-06 20:38:44 +05:00
|
|
|
|
|
|
|
#endif // NETGEN_MESHING_PYTHON_MESH_HPP
|
|
|
|
|