Merge branch 'genmesh_firststep_as_meshingparam' into 'master'

Genmesh laststep as meshingparam



See merge request !23
This commit is contained in:
Joachim Schöberl 2016-12-07 20:01:54 +01:00
commit a423258f54
18 changed files with 74 additions and 76 deletions

View File

@ -129,14 +129,12 @@ namespace netgen
extern int CSGGenerateMesh (CSGeometry & geom, extern int CSGGenerateMesh (CSGeometry & geom,
shared_ptr<Mesh> & mesh, MeshingParameters & mparam, shared_ptr<Mesh> & mesh, MeshingParameters & mparam);
int perfstepsstart, int perfstepsend);
int CSGeometry :: GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam, int CSGeometry :: GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam)
int perfstepsstart, int perfstepsend)
{ {
return CSGGenerateMesh (*this, mesh, mparam, perfstepsstart, perfstepsend); return CSGGenerateMesh (*this, mesh, mparam);
} }

View File

@ -313,8 +313,7 @@ namespace netgen
Array<BCModification> bcmodifications; Array<BCModification> bcmodifications;
virtual int GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam, virtual int GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam);
int perfstepsstart, int perfstepsend);
virtual const Refinement & GetRefinement () const; virtual const Refinement & GetRefinement () const;
}; };

View File

@ -658,17 +658,16 @@ namespace netgen
int CSGGenerateMesh (CSGeometry & geom, int CSGGenerateMesh (CSGeometry & geom,
shared_ptr<Mesh> & mesh, MeshingParameters & mparam, shared_ptr<Mesh> & mesh, MeshingParameters & mparam)
int perfstepsstart, int perfstepsend)
{ {
if (mesh && mesh->GetNSE() && if (mesh && mesh->GetNSE() &&
!geom.GetNSolids()) !geom.GetNSolids())
{ {
if (perfstepsstart < MESHCONST_MESHVOLUME) if (mparam.perfstepsstart < MESHCONST_MESHVOLUME)
perfstepsstart = MESHCONST_MESHVOLUME; mparam.perfstepsstart = MESHCONST_MESHVOLUME;
} }
if (perfstepsstart <= MESHCONST_ANALYSE) if (mparam.perfstepsstart <= MESHCONST_ANALYSE)
{ {
if (mesh) if (mesh)
mesh -> DeleteMesh(); mesh -> DeleteMesh();
@ -709,11 +708,11 @@ namespace netgen
} }
if (multithread.terminate || perfstepsend <= MESHCONST_ANALYSE) if (multithread.terminate || mparam.perfstepsend <= MESHCONST_ANALYSE)
return TCL_OK; return TCL_OK;
if (perfstepsstart <= MESHCONST_MESHEDGES) if (mparam.perfstepsstart <= MESHCONST_MESHEDGES)
{ {
FindEdges (geom, *mesh, mparam, true); FindEdges (geom, *mesh, mparam, true);
if (multithread.terminate) return TCL_OK; if (multithread.terminate) return TCL_OK;
@ -746,11 +745,11 @@ namespace netgen
} }
} }
if (multithread.terminate || perfstepsend <= MESHCONST_MESHEDGES) if (multithread.terminate || mparam.perfstepsend <= MESHCONST_MESHEDGES)
return TCL_OK; return TCL_OK;
if (perfstepsstart <= MESHCONST_MESHSURFACE) if (mparam.perfstepsstart <= MESHCONST_MESHSURFACE)
{ {
MeshSurface (geom, *mesh, mparam); MeshSurface (geom, *mesh, mparam);
if (multithread.terminate) return TCL_OK; if (multithread.terminate) return TCL_OK;
@ -791,11 +790,11 @@ namespace netgen
mesh->CalcSurfacesOfNode(); mesh->CalcSurfacesOfNode();
} }
if (multithread.terminate || perfstepsend <= MESHCONST_OPTSURFACE) if (multithread.terminate || mparam.perfstepsend <= MESHCONST_OPTSURFACE)
return TCL_OK; return TCL_OK;
if (perfstepsstart <= MESHCONST_MESHVOLUME) if (mparam.perfstepsstart <= MESHCONST_MESHVOLUME)
{ {
multithread.task = "Volume meshing"; multithread.task = "Volume meshing";
@ -826,11 +825,11 @@ namespace netgen
#endif #endif
} }
if (multithread.terminate || perfstepsend <= MESHCONST_MESHVOLUME) if (multithread.terminate || mparam.perfstepsend <= MESHCONST_MESHVOLUME)
return TCL_OK; return TCL_OK;
if (perfstepsstart <= MESHCONST_OPTVOLUME) if (mparam.perfstepsstart <= MESHCONST_OPTVOLUME)
{ {
multithread.task = "Volume optimization"; multithread.task = "Volume optimization";

View File

@ -626,7 +626,7 @@ DLL_HEADER void ExportCSG(py::module &m)
geo->FindIdenticSurfaces(1e-8 * geo->MaxSize()); geo->FindIdenticSurfaces(1e-8 * geo->MaxSize());
try try
{ {
geo->GenerateMesh (dummy, param, 0, 6); geo->GenerateMesh (dummy, param);
} }
catch (NgException ex) catch (NgException ex)
{ {

View File

@ -986,8 +986,7 @@ namespace netgen
MeshingParameters & mp); MeshingParameters & mp);
int SplineGeometry2d :: GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam, int SplineGeometry2d :: GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam)
int perfstepsstart, int perfstepsend)
{ {
MeshFromSpline2D (*this, mesh, mparam); MeshFromSpline2D (*this, mesh, mparam);
return 0; return 0;

View File

@ -156,8 +156,7 @@ namespace netgen
} }
DLL_HEADER virtual int GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam, DLL_HEADER virtual int GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam);
int perfstepsstart, int perfstepsend);
void PartitionBoundary (MeshingParameters & mp, double h, Mesh & mesh2d); void PartitionBoundary (MeshingParameters & mp, double h, Mesh & mesh2d);

View File

@ -258,7 +258,7 @@ DLL_HEADER void ExportGeom2d(py::module &m)
mesh->SetGeometry(self); mesh->SetGeometry(self);
SetGlobalMesh (mesh); SetGlobalMesh (mesh);
ng_geometry = self; ng_geometry = self;
self->GenerateMesh(mesh, mparam, 0, 0); self->GenerateMesh(mesh, mparam);
return mesh; return mesh;
})) }))

View File

@ -14,12 +14,11 @@ namespace netgen
int NetgenGeometry :: GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam, int NetgenGeometry :: GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam)
int perfstepsstart, int perfstepsend)
{ {
if (!mesh) return 1; if (!mesh) return 1;
if (perfstepsstart <= MESHCONST_MESHVOLUME) if (mparam.perfstepsstart <= MESHCONST_MESHVOLUME)
{ {
multithread.task = "Volume meshing"; multithread.task = "Volume meshing";
@ -37,11 +36,11 @@ namespace netgen
} }
if (multithread.terminate || perfstepsend <= MESHCONST_MESHVOLUME) if (multithread.terminate || mparam.perfstepsend <= MESHCONST_MESHVOLUME)
return 0; return 0;
if (perfstepsstart <= MESHCONST_OPTVOLUME) if (mparam.perfstepsstart <= MESHCONST_OPTVOLUME)
{ {
multithread.task = "Volume optimization"; multithread.task = "Volume optimization";

View File

@ -18,8 +18,7 @@ namespace netgen
public: public:
virtual ~NetgenGeometry () { ; } virtual ~NetgenGeometry () { ; }
virtual int GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam, virtual int GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam);
int perfstepsstart, int perfstepsend);
virtual const Refinement & GetRefinement () const; virtual const Refinement & GetRefinement () const;

View File

@ -1092,6 +1092,11 @@ namespace netgen
double elsizeweight = 0.2; double elsizeweight = 0.2;
/// init with default values /// init with default values
/// start at step
int perfstepsstart = 0;
/// end at step
int perfstepsend = 6;
/// from mp3: /// from mp3:
/// give up quality class, 2d meshing /// give up quality class, 2d meshing

View File

@ -586,23 +586,31 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m)
; ;
py::enum_<MESHING_STEP>(m,"MeshingStep")
.value("MESHEDGES",MESHCONST_MESHEDGES)
.value("MESHSURFACE",MESHCONST_OPTSURFACE)
.value("MESHVOLUME",MESHCONST_OPTVOLUME)
;
typedef MeshingParameters MP; typedef MeshingParameters MP;
py::class_<MP> (m, "MeshingParameters") py::class_<MP> (m, "MeshingParameters")
.def(py::init<>()) .def(py::init<>())
.def("__init__", .def("__init__",
[](MP *instance, double maxh, bool quad_dominated, int optsteps2d, int optsteps3d) [](MP *instance, double maxh, bool quad_dominated, int optsteps2d, int optsteps3d,
MESHING_STEP perfstepsend)
{ {
new (instance) MeshingParameters; new (instance) MeshingParameters;
instance->maxh = maxh; instance->maxh = maxh;
instance->quad = int(quad_dominated); instance->quad = int(quad_dominated);
instance->optsteps2d = optsteps2d; instance->optsteps2d = optsteps2d;
instance->optsteps3d = optsteps3d; instance->optsteps3d = optsteps3d;
instance->perfstepsend = perfstepsend;
}, },
py::arg("maxh")=1000, py::arg("maxh")=1000,
py::arg("quad_dominated")=false, py::arg("quad_dominated")=false,
py::arg("optsteps2d") = 3, py::arg("optsteps2d") = 3,
py::arg("optsteps3d") = 3 py::arg("optsteps3d") = 3,
, py::arg("perfstepsend") = MESHCONST_OPTVOLUME,
"create meshing parameters" "create meshing parameters"
) )
.def("__str__", &ToString<MP>) .def("__str__", &ToString<MP>)

View File

@ -1273,12 +1273,11 @@ namespace netgen
int OCCGenerateMesh (OCCGeometry & geom, shared_ptr<Mesh> & mesh, MeshingParameters & mparam, int OCCGenerateMesh (OCCGeometry & geom, shared_ptr<Mesh> & mesh, MeshingParameters & mparam)
int perfstepsstart, int perfstepsend)
{ {
multithread.percent = 0; multithread.percent = 0;
if (perfstepsstart <= MESHCONST_ANALYSE) if (mparam.perfstepsstart <= MESHCONST_ANALYSE)
{ {
// delete mesh; // delete mesh;
// mesh = make_shared<Mesh>(); // mesh = make_shared<Mesh>();
@ -1287,10 +1286,10 @@ namespace netgen
OCCSetLocalMeshSize(geom,*mesh); OCCSetLocalMeshSize(geom,*mesh);
} }
if (multithread.terminate || perfstepsend <= MESHCONST_ANALYSE) if (multithread.terminate || mparam.perfstepsend <= MESHCONST_ANALYSE)
return TCL_OK; return TCL_OK;
if (perfstepsstart <= MESHCONST_MESHEDGES) if (mparam.perfstepsstart <= MESHCONST_MESHEDGES)
{ {
OCCFindEdges (geom, *mesh); OCCFindEdges (geom, *mesh);
@ -1360,12 +1359,12 @@ namespace netgen
#endif #endif
} }
if (multithread.terminate || perfstepsend <= MESHCONST_MESHEDGES) if (multithread.terminate || mparam.perfstepsend <= MESHCONST_MESHEDGES)
return TCL_OK; return TCL_OK;
if (perfstepsstart <= MESHCONST_MESHSURFACE) if (mparam.perfstepsstart <= MESHCONST_MESHSURFACE)
{ {
OCCMeshSurface (geom, *mesh, perfstepsend); OCCMeshSurface (geom, *mesh, mparam.perfstepsend);
if (multithread.terminate) return TCL_OK; if (multithread.terminate) return TCL_OK;
#ifdef LOG_STREAM #ifdef LOG_STREAM
@ -1384,10 +1383,10 @@ namespace netgen
mesh->CalcSurfacesOfNode(); mesh->CalcSurfacesOfNode();
} }
if (multithread.terminate || perfstepsend <= MESHCONST_OPTSURFACE) if (multithread.terminate || mparam.perfstepsend <= MESHCONST_OPTSURFACE)
return TCL_OK; return TCL_OK;
if (perfstepsstart <= MESHCONST_MESHVOLUME) if (mparam.perfstepsstart <= MESHCONST_MESHVOLUME)
{ {
multithread.task = "Volume meshing"; multithread.task = "Volume meshing";
@ -1426,10 +1425,10 @@ namespace netgen
#endif #endif
} }
if (multithread.terminate || perfstepsend <= MESHCONST_MESHVOLUME) if (multithread.terminate || mparam.perfstepsend <= MESHCONST_MESHVOLUME)
return TCL_OK; return TCL_OK;
if (perfstepsstart <= MESHCONST_OPTVOLUME) if (mparam.perfstepsstart <= MESHCONST_OPTVOLUME)
{ {
multithread.task = "Volume optimization"; multithread.task = "Volume optimization";

View File

@ -1564,10 +1564,9 @@ namespace netgen
int OCCGeometry :: GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam, int OCCGeometry :: GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam)
int perfstepsstart, int perfstepsend)
{ {
return OCCGenerateMesh (*this, mesh, mparam, perfstepsstart, perfstepsend); return OCCGenerateMesh (*this, mesh, mparam);
} }

View File

@ -387,8 +387,7 @@ namespace netgen
// void WriteOCC_STL(char * filename); // void WriteOCC_STL(char * filename);
DLL_HEADER virtual int GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam, DLL_HEADER virtual int GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam);
int perfstepsstart, int perfstepsend);
DLL_HEADER virtual const Refinement & GetRefinement () const; DLL_HEADER virtual const Refinement & GetRefinement () const;
}; };
@ -442,8 +441,7 @@ namespace netgen
// External access to the mesh generation functions within the OCC // External access to the mesh generation functions within the OCC
// subsystem (Not sure if this is the best way to implement this....!!) // subsystem (Not sure if this is the best way to implement this....!!)
extern int OCCGenerateMesh (OCCGeometry & occgeometry, shared_ptr<Mesh> & mesh, extern int OCCGenerateMesh (OCCGeometry & occgeometry, shared_ptr<Mesh> & mesh,
MeshingParameters & mparam, MeshingParameters & mparam);
int perfstepsstart, int perfstepsend);
extern void OCCSetLocalMeshSize(OCCGeometry & geom, Mesh & mesh); extern void OCCSetLocalMeshSize(OCCGeometry & geom, Mesh & mesh);

View File

@ -91,10 +91,9 @@ void STLGeometry :: Save (string filename) const
int STLGeometry :: GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam, int STLGeometry :: GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam)
int perfstepsstart, int perfstepsend)
{ {
return STLMeshingDummy (this, mesh, mparam, perfstepsstart, perfstepsend); return STLMeshingDummy (this, mesh, mparam);
} }

View File

@ -452,8 +452,7 @@ namespace netgen
friend class MeshingSTLSurface; friend class MeshingSTLSurface;
virtual int GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam, virtual int GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam);
int perfstepsstart, int perfstepsend);
virtual const Refinement & GetRefinement () const; virtual const Refinement & GetRefinement () const;
}; };
@ -463,8 +462,7 @@ namespace netgen
extern int STLMeshingDummy (STLGeometry* stlgeometry, shared_ptr<Mesh> & mesh, MeshingParameters & mparam, extern int STLMeshingDummy (STLGeometry* stlgeometry, shared_ptr<Mesh> & mesh, MeshingParameters & mparam);
int perfstepsstart, int perfstepsend);
} }

View File

@ -1329,16 +1329,15 @@ void STLGeometry :: RestrictHChartDistOneChart(int chartnum, Array<int>& acttrig
} }
int STLMeshingDummy (STLGeometry* stlgeometry, shared_ptr<Mesh> & mesh, MeshingParameters & mparam, int STLMeshingDummy (STLGeometry* stlgeometry, shared_ptr<Mesh> & mesh, MeshingParameters & mparam)
int perfstepsstart, int perfstepsend)
{ {
if (perfstepsstart > perfstepsend) return 0; if (mparam.perfstepsstart > mparam.perfstepsend) return 0;
multithread.terminate = 0; multithread.terminate = 0;
int success = 1; int success = 1;
//int trialcntouter = 0; //int trialcntouter = 0;
if (perfstepsstart <= MESHCONST_MESHEDGES) if (mparam.perfstepsstart <= MESHCONST_MESHEDGES)
{ {
if (mesh) if (mesh)
mesh -> DeleteMesh(); mesh -> DeleteMesh();
@ -1368,8 +1367,8 @@ int STLMeshingDummy (STLGeometry* stlgeometry, shared_ptr<Mesh> & mesh, MeshingP
if (multithread.terminate) if (multithread.terminate)
return 0; return 0;
if (perfstepsstart <= MESHCONST_MESHSURFACE && if (mparam.perfstepsstart <= MESHCONST_MESHSURFACE &&
perfstepsend >= MESHCONST_MESHSURFACE) mparam.perfstepsend >= MESHCONST_MESHSURFACE)
{ {
if (!stlgeometry->edgesfound) if (!stlgeometry->edgesfound)
@ -1417,8 +1416,8 @@ int STLMeshingDummy (STLGeometry* stlgeometry, shared_ptr<Mesh> & mesh, MeshingP
if (success) if (success)
{ {
if (perfstepsstart <= MESHCONST_OPTSURFACE && if (mparam.perfstepsstart <= MESHCONST_OPTSURFACE &&
perfstepsend >= MESHCONST_OPTSURFACE) mparam.perfstepsend >= MESHCONST_OPTSURFACE)
{ {
if (!stlgeometry->edgesfound) if (!stlgeometry->edgesfound)
{ {
@ -1469,8 +1468,8 @@ int STLMeshingDummy (STLGeometry* stlgeometry, shared_ptr<Mesh> & mesh, MeshingP
if (multithread.terminate) if (multithread.terminate)
return 0; return 0;
if (perfstepsstart <= MESHCONST_MESHVOLUME && if (mparam.perfstepsstart <= MESHCONST_MESHVOLUME &&
perfstepsend >= MESHCONST_MESHVOLUME) mparam.perfstepsend >= MESHCONST_MESHVOLUME)
{ {
if (stlgeometry->volumemeshed) if (stlgeometry->volumemeshed)
{ {
@ -1540,8 +1539,8 @@ int STLMeshingDummy (STLGeometry* stlgeometry, shared_ptr<Mesh> & mesh, MeshingP
if (multithread.terminate) if (multithread.terminate)
return 0; return 0;
if (perfstepsstart <= MESHCONST_OPTVOLUME && if (mparam.perfstepsstart <= MESHCONST_OPTVOLUME &&
perfstepsend >= MESHCONST_OPTVOLUME) mparam.perfstepsend >= MESHCONST_OPTVOLUME)
{ {
if (!stlgeometry->edgesfound) if (!stlgeometry->edgesfound)
{ {

View File

@ -1328,8 +1328,9 @@ namespace netgen
// vsmesh.SetMesh (mesh); // vsmesh.SetMesh (mesh);
SetGlobalMesh (mesh); SetGlobalMesh (mesh);
mesh -> SetGeometry(ng_geometry); mesh -> SetGeometry(ng_geometry);
mparam.perfstepsstart = perfstepsstart;
int res = ng_geometry -> GenerateMesh (mesh, mparam, perfstepsstart, perfstepsend); mparam.perfstepsend = perfstepsend;
int res = ng_geometry -> GenerateMesh (mesh, mparam);
if (res != MESHING3_OK) if (res != MESHING3_OK)
{ {