mirror of
https://github.com/NGSolve/netgen.git
synced 2025-01-12 22:20:35 +05:00
occ parameters from python, gui and meshsize parameters now the same
This commit is contained in:
parent
7f442d14f2
commit
9d96c0e432
@ -989,7 +989,7 @@ namespace netgen
|
||||
|
||||
|
||||
void OCCSetLocalMeshSize(OCCGeometry & geom, Mesh & mesh,
|
||||
const MeshingParameters & mparam)
|
||||
const MeshingParameters & mparam, const OCCParameters& occparam)
|
||||
{
|
||||
mesh.SetGlobalH (mparam.maxh);
|
||||
mesh.SetMinimalH (mparam.minh);
|
||||
@ -1273,7 +1273,8 @@ namespace netgen
|
||||
|
||||
|
||||
|
||||
int OCCGenerateMesh (OCCGeometry & geom, shared_ptr<Mesh> & mesh, MeshingParameters & mparam)
|
||||
int OCCGenerateMesh (OCCGeometry & geom, shared_ptr<Mesh> & mesh, MeshingParameters & mparam,
|
||||
const OCCParameters& occparam)
|
||||
{
|
||||
multithread.percent = 0;
|
||||
|
||||
@ -1283,7 +1284,7 @@ namespace netgen
|
||||
mesh = make_shared<Mesh>();
|
||||
mesh->geomtype = Mesh::GEOM_OCC;
|
||||
|
||||
OCCSetLocalMeshSize(geom,*mesh, mparam);
|
||||
OCCSetLocalMeshSize(geom,*mesh, mparam, occparam);
|
||||
}
|
||||
|
||||
if (multithread.terminate || mparam.perfstepsend <= MESHCONST_ANALYSE)
|
||||
|
@ -1684,12 +1684,6 @@ void STEP_GetEntityName(const TopoDS_Shape & theShape, STEPCAFControl_Reader * a
|
||||
|
||||
|
||||
|
||||
int OCCGeometry :: GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam)
|
||||
{
|
||||
return OCCGenerateMesh (*this, mesh, mparam);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
const Refinement & OCCGeometry :: GetRefinement () const
|
||||
@ -1697,20 +1691,6 @@ void STEP_GetEntityName(const TopoDS_Shape & theShape, STEPCAFControl_Reader * a
|
||||
return * new OCCRefinementSurfaces (*this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
OCCParameters :: OCCParameters()
|
||||
{
|
||||
resthcloseedgefac = 1;
|
||||
resthcloseedgeenable = 1;
|
||||
resthminedgelen = 0.001;
|
||||
resthminedgelenenable = 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void OCCParameters :: Print(ostream & ost) const
|
||||
{
|
||||
ost << "OCC Parameters:" << endl
|
||||
@ -1720,11 +1700,13 @@ void STEP_GetEntityName(const TopoDS_Shape & theShape, STEPCAFControl_Reader * a
|
||||
<< ", min len = " << resthminedgelen << endl;
|
||||
}
|
||||
|
||||
DLL_HEADER extern OCCParameters occparam;
|
||||
OCCParameters occparam;
|
||||
|
||||
|
||||
|
||||
OCCParameters occparam;
|
||||
|
||||
int OCCGeometry :: GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam)
|
||||
{
|
||||
return OCCGenerateMesh (*this, mesh, mparam, occparam);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -404,26 +404,19 @@ namespace netgen
|
||||
public:
|
||||
|
||||
/// Factor for meshing close edges
|
||||
double resthcloseedgefac;
|
||||
double resthcloseedgefac = 2.;
|
||||
|
||||
|
||||
/// Enable / Disable detection of close edges
|
||||
int resthcloseedgeenable;
|
||||
int resthcloseedgeenable = true;
|
||||
|
||||
|
||||
/// Minimum edge length to be used for dividing edges to mesh points
|
||||
double resthminedgelen;
|
||||
double resthminedgelen = 0.001;
|
||||
|
||||
|
||||
/// Enable / Disable use of the minimum edge length (by default use 1e-4)
|
||||
int resthminedgelenenable;
|
||||
|
||||
/*!
|
||||
Default Constructor for the OpenCascade
|
||||
Mesh generation parameter set
|
||||
*/
|
||||
OCCParameters();
|
||||
|
||||
int resthminedgelenenable = true;
|
||||
|
||||
/*!
|
||||
Dump all the OpenCascade specific meshing parameters
|
||||
@ -439,16 +432,14 @@ namespace netgen
|
||||
DLL_HEADER OCCGeometry * LoadOCC_STEP (const char * filename);
|
||||
DLL_HEADER OCCGeometry * LoadOCC_BREP (const char * filename);
|
||||
|
||||
DLL_HEADER extern OCCParameters occparam;
|
||||
|
||||
|
||||
// Philippose - 31.09.2009
|
||||
// External access to the mesh generation functions within the OCC
|
||||
// subsystem (Not sure if this is the best way to implement this....!!)
|
||||
DLL_HEADER extern int OCCGenerateMesh (OCCGeometry & occgeometry, shared_ptr<Mesh> & mesh,
|
||||
MeshingParameters & mparam);
|
||||
MeshingParameters & mparam, const OCCParameters& occparam);
|
||||
|
||||
DLL_HEADER extern void OCCSetLocalMeshSize(OCCGeometry & geom, Mesh & mesh, const MeshingParameters & mparam);
|
||||
DLL_HEADER extern void OCCSetLocalMeshSize(OCCGeometry & geom, Mesh & mesh, const MeshingParameters & mparam,
|
||||
const OCCParameters& occparam);
|
||||
|
||||
DLL_HEADER extern void OCCMeshSurface (OCCGeometry & geom, Mesh & mesh, int perfstepsend, MeshingParameters & mparam);
|
||||
|
||||
|
@ -28,6 +28,7 @@ namespace netgen
|
||||
extern DLL_HEADER shared_ptr<NetgenGeometry> ng_geometry;
|
||||
extern DLL_HEADER shared_ptr<Mesh> mesh;
|
||||
extern DLL_HEADER MeshingParameters mparam;
|
||||
extern DLL_HEADER OCCParameters occparam;
|
||||
|
||||
char * err_needsoccgeometry = (char*) "This operation needs an OCC geometry";
|
||||
extern char * err_needsmesh;
|
||||
|
@ -15,6 +15,45 @@ namespace netgen
|
||||
extern std::shared_ptr<NetgenGeometry> ng_geometry;
|
||||
}
|
||||
|
||||
static string occparameter_description = R"delimiter(
|
||||
OCC Specific Meshing Parameters
|
||||
-------------------------------
|
||||
|
||||
closeedgefac: Optional[float] = 1.
|
||||
Factor for meshing close edges, if None it is disabled.
|
||||
|
||||
minedgelen: Optional[float] = 0.001
|
||||
Minimum edge length to be used for dividing edges to mesh points. If
|
||||
None this is disabled.
|
||||
|
||||
)delimiter";
|
||||
|
||||
void CreateOCCParametersFromKwargs(OCCParameters& occparam, py::dict kwargs)
|
||||
{
|
||||
if(kwargs.contains("closeedgefac"))
|
||||
{
|
||||
auto val = kwargs.attr("pop")("closeedgefac");
|
||||
if(val.is_none())
|
||||
occparam.resthcloseedgeenable = false;
|
||||
else
|
||||
{
|
||||
occparam.resthcloseedgefac = py::cast<double>(val);
|
||||
occparam.resthcloseedgeenable = true;
|
||||
}
|
||||
}
|
||||
if(kwargs.contains("minedgelen"))
|
||||
{
|
||||
auto val = kwargs.attr("pop")("minedgelen");
|
||||
if(val.is_none())
|
||||
occparam.resthminedgelenenable = false;
|
||||
else
|
||||
{
|
||||
occparam.resthminedgelen = py::cast<double>(val);
|
||||
occparam.resthminedgelenenable = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
DLL_HEADER void ExportNgOCC(py::module &m)
|
||||
{
|
||||
@ -132,20 +171,27 @@ DLL_HEADER void ExportNgOCC(py::module &m)
|
||||
MeshingParameters* pars, py::kwargs kwargs)
|
||||
{
|
||||
MeshingParameters mp;
|
||||
if(pars) mp = *pars;
|
||||
OCCParameters occparam;
|
||||
{
|
||||
py::gil_scoped_acquire aq;
|
||||
if(pars)
|
||||
{
|
||||
auto mp_kwargs = CreateDictFromFlags(pars->geometrySpecificParameters);
|
||||
CreateOCCParametersFromKwargs(occparam, mp_kwargs);
|
||||
mp = *pars;
|
||||
}
|
||||
CreateOCCParametersFromKwargs(occparam, kwargs);
|
||||
CreateMPfromKwargs(mp, kwargs);
|
||||
}
|
||||
auto mesh = make_shared<Mesh>();
|
||||
SetGlobalMesh(mesh);
|
||||
mesh->SetGeometry(geo);
|
||||
ng_geometry = geo;
|
||||
geo->GenerateMesh(mesh,mp);
|
||||
OCCGenerateMesh(*geo, mesh, mp, occparam);
|
||||
return mesh;
|
||||
}, py::arg("mp") = nullptr,
|
||||
py::call_guard<py::gil_scoped_release>(),
|
||||
meshingparameter_description.c_str())
|
||||
(meshingparameter_description + occparameter_description).c_str())
|
||||
;
|
||||
|
||||
m.def("LoadOCCGeometry",[] (const string & filename)
|
||||
|
@ -21,15 +21,21 @@ static string stlparameter_description = R"delimiter(
|
||||
STL Specific Meshing Parameters
|
||||
-------------------------------
|
||||
|
||||
yangle: float =
|
||||
yangle: float = 30.
|
||||
Angle for edge detection
|
||||
|
||||
contyangle: float =
|
||||
contyangle: float = 20.
|
||||
Edges continue if angle > contyangle
|
||||
|
||||
edgecornerangle: float =
|
||||
edgecornerangle: float = 60.
|
||||
Angle of geometry edge at which the mesher should set a point.
|
||||
|
||||
closeedgefac: Optional[float] = 1.
|
||||
Factor for meshing close edges, if None it is disabled.
|
||||
|
||||
minedgelen: Optional[float] = 0.001
|
||||
Minimum edge length to be used for dividing edges to mesh points. If
|
||||
None this is disabled.
|
||||
)delimiter";
|
||||
|
||||
void CreateSTLParametersFromKwargs(STLParameters& stlparam, py::dict kwargs)
|
||||
|
@ -235,7 +235,7 @@ class DLL_HEADER STLParameters
|
||||
public:
|
||||
/// angle for edge detection
|
||||
double yangle = 30.;
|
||||
double contyangle; //edges continued with contyangle
|
||||
double contyangle = 20.; //edges continued with contyangle
|
||||
/// angle of geometry edge at which the mesher should set a point
|
||||
double edgecornerangle = 60.;
|
||||
/// angle inside on chart
|
||||
@ -243,25 +243,25 @@ public:
|
||||
/// angle for overlapping parts of char
|
||||
double outerchartangle = 70.;
|
||||
/// 0 .. no, 1 .. local, (2 .. global)
|
||||
int usesearchtree;
|
||||
int usesearchtree = 0;
|
||||
///
|
||||
double resthatlasfac;
|
||||
bool resthatlasenable;
|
||||
double atlasminh;
|
||||
double resthatlasfac = 2.;
|
||||
bool resthatlasenable = true;
|
||||
double atlasminh = 0.1;
|
||||
|
||||
double resthsurfcurvfac = 1.;
|
||||
double resthsurfcurvfac = 2.;
|
||||
bool resthsurfcurvenable = false;
|
||||
|
||||
double resthchartdistfac = 1.5;
|
||||
double resthchartdistfac = 1.2;
|
||||
bool resthchartdistenable = true;
|
||||
|
||||
double resthcloseedgefac = 2.;
|
||||
double resthcloseedgefac = 1.;
|
||||
bool resthcloseedgeenable = true;
|
||||
|
||||
double resthedgeanglefac = 1.;
|
||||
bool resthedgeangleenable = false;
|
||||
|
||||
double resthsurfmeshcurvfac = 2.;
|
||||
double resthsurfmeshcurvfac = 1.;
|
||||
bool resthsurfmeshcurvenable = false;
|
||||
|
||||
double resthlinelengthfac = 0.5;
|
||||
|
@ -32,6 +32,7 @@ namespace netgen {
|
||||
MeshingParameters & mp);
|
||||
extern MeshingParameters mparam;
|
||||
DLL_HEADER extern STLParameters stlparam;
|
||||
DLL_HEADER extern OCCParameters occparam;
|
||||
}
|
||||
|
||||
|
||||
@ -859,7 +860,7 @@ namespace nglib
|
||||
// slate
|
||||
me->DeleteMesh();
|
||||
|
||||
OCCSetLocalMeshSize(*occgeom, *me, mparam);
|
||||
OCCSetLocalMeshSize(*occgeom, *me, mparam, occparam);
|
||||
|
||||
return(NG_OK);
|
||||
}
|
||||
|
@ -6,61 +6,66 @@ class _MeshsizeObject:
|
||||
return MeshingParameters(curvaturesafety=1,
|
||||
segmentsperedge=0.3,
|
||||
grading=0.7,
|
||||
resthsurfcurvfac=0.25,
|
||||
resthchartdistfac=0.8,
|
||||
resthlinelengthfac=0.2,
|
||||
resthcloseedgefac=0.5,
|
||||
resthminedgelen=0.002,
|
||||
resthedgeanglefac=0.25,
|
||||
resthsurfmeshcurvfac=1.)
|
||||
surfcurvfac=0.25,
|
||||
chartdistfac=0.8,
|
||||
linelengthfac=0.2,
|
||||
closeedgefac=0.5,
|
||||
minedgelen=0.002,
|
||||
edgeanglefac=0.25,
|
||||
surfmeshcurvfac=1.,
|
||||
optsteps3d=5)
|
||||
@property
|
||||
def coarse(self):
|
||||
return MeshingParameters(curvaturesafety=1.5,
|
||||
segmentsperedge=0.5,
|
||||
grading=0.5,
|
||||
resthsurfcurvfac=0.5,
|
||||
resthchartdistfac=1,
|
||||
resthlinelengthfac=0.35,
|
||||
resthcloseedgefac=1,
|
||||
resthminedgelen=0.02,
|
||||
resthedgeanglefac=0.5,
|
||||
resthsurfmeshcurvfac=1.5)
|
||||
surfcurvfac=0.5,
|
||||
chartdistfac=1,
|
||||
linelengthfac=0.35,
|
||||
closeedgefac=1,
|
||||
minedgelen=0.02,
|
||||
edgeanglefac=0.5,
|
||||
surfmeshcurvfac=1.5,
|
||||
optsteps3d=5)
|
||||
@property
|
||||
def moderate(self):
|
||||
return MeshingParameters(curvaturesafety=2,
|
||||
segmentsperedge=1,
|
||||
grading=0.3,
|
||||
resthsurfcurvfac=1.,
|
||||
resthchartdistfac=1.5,
|
||||
resthlinelengthfac=0.5,
|
||||
resthcloseedgefac=2,
|
||||
resthminedgelen=0.2,
|
||||
resthedgeanglefac=1,
|
||||
resthsurfmeshcurvfac=2.)
|
||||
surfcurvfac=1.,
|
||||
chartdistfac=1.5,
|
||||
linelengthfac=0.5,
|
||||
closeedgefac=2,
|
||||
minedgelen=0.2,
|
||||
edgeanglefac=1,
|
||||
surfmeshcurvfac=2.,
|
||||
optsteps3d=5)
|
||||
@property
|
||||
def fine(self):
|
||||
return MeshingParameters(curvaturesafety=3,
|
||||
segmentsperedge=2,
|
||||
grading=0.2,
|
||||
resthsurfcurvfac=1.5,
|
||||
resthchartdistfac=2,
|
||||
resthlinelengthfac=1.5,
|
||||
resthcloseedgefac=3.5,
|
||||
resthminedgelen=1.,
|
||||
resthedgeanglefac=1.5,
|
||||
resthsurfmeshcurvfac=3.)
|
||||
surfcurvfac=1.5,
|
||||
chartdistfac=2,
|
||||
linelengthfac=1.5,
|
||||
closeedgefac=3.5,
|
||||
minedgelen=1.,
|
||||
edgeanglefac=1.5,
|
||||
surfmeshcurvfac=3.,
|
||||
optsteps3d=5)
|
||||
|
||||
@property
|
||||
def very_fine(self):
|
||||
return MeshingParameters(curvaturesafety=5,
|
||||
segmentsperedge=3,
|
||||
grading=0.1,
|
||||
resthsurfcurvfac=3,
|
||||
resthchartdistfac=5,
|
||||
resthlinelengthfac=3,
|
||||
resthcloseedgefac=5,
|
||||
resthminedgelen=2.,
|
||||
resthedgeanglefac=3.,
|
||||
resthsurfmeshcurvfac=5.)
|
||||
surfcurvfac=3,
|
||||
chartdistfac=5,
|
||||
linelengthfac=3,
|
||||
closeedgefac=5,
|
||||
minedgelen=2.,
|
||||
edgeanglefac=3.,
|
||||
surfmeshcurvfac=5.,
|
||||
optsteps3d=5)
|
||||
|
||||
meshsize = _MeshsizeObject()
|
||||
|
Loading…
Reference in New Issue
Block a user