Cleanup use of netgen_params + restoring use of netgen error functions
This commit is contained in:
parent
15a5ceeea7
commit
54a50107a5
@ -26,10 +26,6 @@
|
|||||||
//
|
//
|
||||||
#include "NETGENPlugin_DriverParam.hxx"
|
#include "NETGENPlugin_DriverParam.hxx"
|
||||||
|
|
||||||
#include "NETGENPlugin_Hypothesis.hxx"
|
|
||||||
|
|
||||||
#include <SMESH_Gen.hxx>
|
|
||||||
#include <StdMeshers_MaxElementVolume.hxx>
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
@ -76,7 +72,7 @@ void printNetgenParams(netgen_params& aParams){
|
|||||||
* @param param_file Name of the file
|
* @param param_file Name of the file
|
||||||
* @param aParams Structure to fill
|
* @param aParams Structure to fill
|
||||||
*/
|
*/
|
||||||
void importNetgenParams(const std::string param_file, netgen_params& aParams, SMESH_Gen *gen){
|
void importNetgenParams(const std::string param_file, netgen_params& aParams){
|
||||||
std::ifstream myfile(param_file);
|
std::ifstream myfile(param_file);
|
||||||
std::string line;
|
std::string line;
|
||||||
|
|
||||||
@ -133,36 +129,6 @@ void importNetgenParams(const std::string param_file, netgen_params& aParams, SM
|
|||||||
std::getline(myfile, line);
|
std::getline(myfile, line);
|
||||||
aParams.maxElementVolume = std::stoi(line);
|
aParams.maxElementVolume = std::stoi(line);
|
||||||
|
|
||||||
if(aParams.has_netgen_param){
|
|
||||||
aParams._hypParameters = new NETGENPlugin_Hypothesis(0, gen);
|
|
||||||
|
|
||||||
aParams._hypParameters->SetMaxSize(aParams.maxh);
|
|
||||||
aParams._hypParameters->SetMinSize(aParams.minh);
|
|
||||||
aParams._hypParameters->SetNbSegPerEdge(aParams.segmentsperedge);
|
|
||||||
aParams._hypParameters->SetGrowthRate(aParams.grading);
|
|
||||||
aParams._hypParameters->SetNbSegPerRadius(aParams.curvaturesafety);
|
|
||||||
aParams._hypParameters->SetSecondOrder(aParams.secondorder);
|
|
||||||
aParams._hypParameters->SetQuadAllowed(aParams.quad);
|
|
||||||
aParams._hypParameters->SetOptimize(aParams.optimize);
|
|
||||||
aParams._hypParameters->SetFineness((NETGENPlugin_Hypothesis::Fineness)aParams.fineness);
|
|
||||||
aParams._hypParameters->SetSurfaceCurvature(aParams.uselocalh);
|
|
||||||
aParams._hypParameters->SetFuseEdges(aParams.merge_solids);
|
|
||||||
aParams._hypParameters->SetChordalErrorEnabled(aParams.chordalError);
|
|
||||||
if(aParams.optimize){
|
|
||||||
aParams._hypParameters->SetNbSurfOptSteps(aParams.optsteps2d);
|
|
||||||
aParams._hypParameters->SetNbVolOptSteps(aParams.optsteps3d);
|
|
||||||
}
|
|
||||||
aParams._hypParameters->SetElemSizeWeight(aParams.elsizeweight);
|
|
||||||
aParams._hypParameters->SetWorstElemMeasure(aParams.opterrpow);
|
|
||||||
aParams._hypParameters->SetUseDelauney(aParams.delaunay);
|
|
||||||
aParams._hypParameters->SetCheckOverlapping(aParams.checkoverlap);
|
|
||||||
aParams._hypParameters->SetCheckChartBoundary(aParams.checkchartboundary);
|
|
||||||
aParams._hypParameters->SetMeshSizeFile(aParams.meshsizefilename);
|
|
||||||
}
|
|
||||||
if(aParams.has_maxelementvolume_hyp){
|
|
||||||
aParams._hypMaxElementVolume = new StdMeshers_MaxElementVolume(1, gen);
|
|
||||||
}
|
|
||||||
// TODO: Handle viscous layer
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -30,11 +30,6 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
class NETGENPlugin_Hypothesis;
|
|
||||||
class StdMeshers_MaxElementVolume;
|
|
||||||
class StdMeshers_ViscousLayers;
|
|
||||||
class SMESH_Gen;
|
|
||||||
|
|
||||||
struct netgen_params{
|
struct netgen_params{
|
||||||
// Params from NETGENPlugin_Mesher
|
// Params from NETGENPlugin_Mesher
|
||||||
// True if _hypParameters is not null
|
// True if _hypParameters is not null
|
||||||
@ -60,6 +55,8 @@ struct netgen_params{
|
|||||||
bool checkchartboundary;
|
bool checkchartboundary;
|
||||||
int closeedgefac;
|
int closeedgefac;
|
||||||
|
|
||||||
|
// Number of threads for the mesher
|
||||||
|
int nbThreads;
|
||||||
|
|
||||||
// True if we have a mesh size file or local size info
|
// True if we have a mesh size file or local size info
|
||||||
bool has_local_size = false;
|
bool has_local_size = false;
|
||||||
@ -70,24 +67,14 @@ struct netgen_params{
|
|||||||
bool has_maxelementvolume_hyp=false;
|
bool has_maxelementvolume_hyp=false;
|
||||||
double maxElementVolume=0.0;
|
double maxElementVolume=0.0;
|
||||||
|
|
||||||
NETGENPlugin_Hypothesis * _hypParameters=nullptr;
|
|
||||||
StdMeshers_MaxElementVolume* _hypMaxElementVolume=nullptr;
|
|
||||||
StdMeshers_ViscousLayers* _viscousLayersHyp=nullptr;
|
|
||||||
double _progressByTic;
|
|
||||||
bool _quadraticMesh=false;
|
|
||||||
int _error=0;
|
|
||||||
std::string _comment;
|
|
||||||
|
|
||||||
// Params from NETGEN2D
|
// Params from NETGEN2D
|
||||||
bool has_LengthFromEdges_hyp=false;
|
bool has_LengthFromEdges_hyp=false;
|
||||||
|
|
||||||
// Number of threads for the mesher
|
|
||||||
int nbThreads;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void printNetgenParams(netgen_params& aParams);
|
void printNetgenParams(netgen_params& aParams);
|
||||||
|
|
||||||
void importNetgenParams(const std::string param_file, netgen_params& aParams, SMESH_Gen * gen);
|
void importNetgenParams(const std::string param_file, netgen_params& aParams);
|
||||||
void exportNetgenParams(const std::string param_file, netgen_params& aParams);
|
void exportNetgenParams(const std::string param_file, netgen_params& aParams);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -212,7 +212,6 @@ bool NETGENPlugin_NETGEN_3D::getSurfaceElements(
|
|||||||
SMESH_ProxyMesh::Ptr proxyMesh,
|
SMESH_ProxyMesh::Ptr proxyMesh,
|
||||||
NETGENPlugin_Internals &internals,
|
NETGENPlugin_Internals &internals,
|
||||||
SMESH_MesherHelper &helper,
|
SMESH_MesherHelper &helper,
|
||||||
netgen_params &aParams,
|
|
||||||
std::map<const SMDS_MeshElement*, tuple<bool, bool>>& listElements
|
std::map<const SMDS_MeshElement*, tuple<bool, bool>>& listElements
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@ -236,7 +235,7 @@ bool NETGENPlugin_NETGEN_3D::getSurfaceElements(
|
|||||||
if ( !aSubMeshDSFace ) continue;
|
if ( !aSubMeshDSFace ) continue;
|
||||||
|
|
||||||
SMDS_ElemIteratorPtr iteratorElem = aSubMeshDSFace->GetElements();
|
SMDS_ElemIteratorPtr iteratorElem = aSubMeshDSFace->GetElements();
|
||||||
if ( aParams._quadraticMesh &&
|
if ( _quadraticMesh &&
|
||||||
dynamic_cast< const SMESH_ProxyMesh::SubMesh*>( aSubMeshDSFace ))
|
dynamic_cast< const SMESH_ProxyMesh::SubMesh*>( aSubMeshDSFace ))
|
||||||
{
|
{
|
||||||
// add medium nodes of proxy triangles to helper (#16843)
|
// add medium nodes of proxy triangles to helper (#16843)
|
||||||
@ -249,14 +248,10 @@ bool NETGENPlugin_NETGEN_3D::getSurfaceElements(
|
|||||||
const SMDS_MeshElement* elem = iteratorElem->next();
|
const SMDS_MeshElement* elem = iteratorElem->next();
|
||||||
// check mesh face
|
// check mesh face
|
||||||
if ( !elem ){
|
if ( !elem ){
|
||||||
aParams._error = COMPERR_BAD_INPUT_MESH;
|
return error( COMPERR_BAD_INPUT_MESH, "Null element encounters");
|
||||||
aParams._comment = "Null element encounters";
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
if ( elem->NbCornerNodes() != 3 ){
|
if ( elem->NbCornerNodes() != 3 ){
|
||||||
aParams._error = COMPERR_BAD_INPUT_MESH;
|
return error( COMPERR_BAD_INPUT_MESH, "Not triangle element encounters");
|
||||||
aParams._comment = "Not triangle element encounters";
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
listElements[elem] = tuple(isRev, isInternalFace);
|
listElements[elem] = tuple(isRev, isInternalFace);
|
||||||
}
|
}
|
||||||
@ -272,16 +267,15 @@ bool NETGENPlugin_NETGEN_3D::computeFillNgMesh(
|
|||||||
vector< const SMDS_MeshNode* > &nodeVec,
|
vector< const SMDS_MeshNode* > &nodeVec,
|
||||||
NETGENPlugin_NetgenLibWrapper &ngLib,
|
NETGENPlugin_NetgenLibWrapper &ngLib,
|
||||||
SMESH_MesherHelper &helper,
|
SMESH_MesherHelper &helper,
|
||||||
netgen_params &aParams,
|
|
||||||
int &Netgen_NbOfNodes)
|
int &Netgen_NbOfNodes)
|
||||||
{
|
{
|
||||||
netgen::multithread.terminate = 0;
|
netgen::multithread.terminate = 0;
|
||||||
netgen::multithread.task = "Volume meshing";
|
netgen::multithread.task = "Volume meshing";
|
||||||
aParams._progressByTic = -1.;
|
_progressByTic = -1.;
|
||||||
|
|
||||||
SMESHDS_Mesh* meshDS = aMesh.GetMeshDS();
|
SMESHDS_Mesh* meshDS = aMesh.GetMeshDS();
|
||||||
|
|
||||||
aParams._quadraticMesh = helper.IsQuadraticSubMesh(aShape);
|
_quadraticMesh = helper.IsQuadraticSubMesh(aShape);
|
||||||
helper.SetElementsOnShape( true );
|
helper.SetElementsOnShape( true );
|
||||||
|
|
||||||
Netgen_NbOfNodes = 0;
|
Netgen_NbOfNodes = 0;
|
||||||
@ -311,10 +305,10 @@ bool NETGENPlugin_NETGEN_3D::computeFillNgMesh(
|
|||||||
bool isInternalFace=false;
|
bool isInternalFace=false;
|
||||||
|
|
||||||
SMESH_ProxyMesh::Ptr proxyMesh( new SMESH_ProxyMesh( aMesh ));
|
SMESH_ProxyMesh::Ptr proxyMesh( new SMESH_ProxyMesh( aMesh ));
|
||||||
if ( aParams._viscousLayersHyp )
|
if ( _viscousLayersHyp )
|
||||||
{
|
{
|
||||||
netgen::multithread.percent = 3;
|
netgen::multithread.percent = 3;
|
||||||
proxyMesh = aParams._viscousLayersHyp->Compute( aMesh, aShape );
|
proxyMesh = _viscousLayersHyp->Compute( aMesh, aShape );
|
||||||
if ( !proxyMesh )
|
if ( !proxyMesh )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -327,7 +321,7 @@ bool NETGENPlugin_NETGEN_3D::computeFillNgMesh(
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::map<const SMDS_MeshElement*, tuple<bool, bool>> listElements;
|
std::map<const SMDS_MeshElement*, tuple<bool, bool>> listElements;
|
||||||
bool ret = getSurfaceElements(aMesh, aShape, proxyMesh, internals, helper, aParams, listElements);
|
bool ret = getSurfaceElements(aMesh, aShape, proxyMesh, internals, helper, listElements);
|
||||||
if(ret)
|
if(ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
@ -402,7 +396,6 @@ bool NETGENPlugin_NETGEN_3D::computePrepareParam(
|
|||||||
NETGENPlugin_NetgenLibWrapper &ngLib,
|
NETGENPlugin_NetgenLibWrapper &ngLib,
|
||||||
netgen::OCCGeometry &occgeo,
|
netgen::OCCGeometry &occgeo,
|
||||||
SMESH_MesherHelper &helper,
|
SMESH_MesherHelper &helper,
|
||||||
netgen_params &aParams,
|
|
||||||
int &endWith)
|
int &endWith)
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -413,35 +406,33 @@ bool NETGENPlugin_NETGEN_3D::computePrepareParam(
|
|||||||
NETGENPlugin_Mesher aMesher( &aMesh, helper.GetSubShape(), /*isVolume=*/true );
|
NETGENPlugin_Mesher aMesher( &aMesh, helper.GetSubShape(), /*isVolume=*/true );
|
||||||
|
|
||||||
|
|
||||||
if ( aParams._hypParameters )
|
if ( _hypParameters )
|
||||||
{
|
{
|
||||||
aMesher.SetParameters( aParams._hypParameters );
|
aMesher.SetParameters( _hypParameters );
|
||||||
|
|
||||||
if ( !aParams._hypParameters->GetLocalSizesAndEntries().empty() ||
|
if ( !_hypParameters->GetLocalSizesAndEntries().empty() ||
|
||||||
!aParams._hypParameters->GetMeshSizeFile().empty() )
|
!_hypParameters->GetMeshSizeFile().empty() )
|
||||||
{
|
{
|
||||||
if ( ! &ngMesh->LocalHFunction() )
|
if ( ! &ngMesh->LocalHFunction() )
|
||||||
{
|
{
|
||||||
netgen::Point3d pmin, pmax;
|
netgen::Point3d pmin, pmax;
|
||||||
ngMesh->GetBox( pmin, pmax, 0 );
|
ngMesh->GetBox( pmin, pmax, 0 );
|
||||||
ngMesh->SetLocalH( pmin, pmax, aParams._hypParameters->GetGrowthRate() );
|
ngMesh->SetLocalH( pmin, pmax, _hypParameters->GetGrowthRate() );
|
||||||
}
|
}
|
||||||
aMesher.SetLocalSize( occgeo, *ngMesh );
|
aMesher.SetLocalSize( occgeo, *ngMesh );
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ngMesh->LoadLocalMeshSize( netgen::mparam.meshsizefilename );
|
ngMesh->LoadLocalMeshSize( netgen::mparam.meshsizefilename );
|
||||||
} catch (netgen::NgException & ex) {
|
} catch (netgen::NgException & ex) {
|
||||||
aParams._error = COMPERR_BAD_PARMETERS;
|
return error( COMPERR_BAD_PARMETERS, ex.What() );
|
||||||
aParams._comment = ex.What();
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( !aParams._hypParameters->GetOptimize() )
|
if ( !_hypParameters->GetOptimize() )
|
||||||
endWith = netgen::MESHCONST_MESHVOLUME;
|
endWith = netgen::MESHCONST_MESHVOLUME;
|
||||||
}
|
}
|
||||||
else if ( aParams._hypMaxElementVolume )
|
else if ( _hypMaxElementVolume )
|
||||||
{
|
{
|
||||||
netgen::mparam.maxh = pow( 72, 1/6. ) * pow( aParams.maxElementVolume, 1/3. );
|
netgen::mparam.maxh = pow( 72, 1/6. ) * pow( _maxElementVolume, 1/3. );
|
||||||
// limitVolumeSize( ngMesh, mparam.maxh ); // result is unpredictable
|
// limitVolumeSize( ngMesh, mparam.maxh ); // result is unpredictable
|
||||||
}
|
}
|
||||||
else if ( aMesh.HasShapeToMesh() )
|
else if ( aMesh.HasShapeToMesh() )
|
||||||
@ -456,7 +447,7 @@ bool NETGENPlugin_NETGEN_3D::computePrepareParam(
|
|||||||
netgen::mparam.maxh = Dist(pmin, pmax)/2;
|
netgen::mparam.maxh = Dist(pmin, pmax)/2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !aParams._hypParameters && aMesh.HasShapeToMesh() )
|
if ( !_hypParameters && aMesh.HasShapeToMesh() )
|
||||||
{
|
{
|
||||||
netgen::mparam.minh = aMesher.GetDefaultMinSize( helper.GetSubShape(), netgen::mparam.maxh );
|
netgen::mparam.minh = aMesher.GetDefaultMinSize( helper.GetSubShape(), netgen::mparam.maxh );
|
||||||
}
|
}
|
||||||
@ -468,7 +459,6 @@ bool NETGENPlugin_NETGEN_3D::computeRunMesher(
|
|||||||
vector< const SMDS_MeshNode* > &nodeVec,
|
vector< const SMDS_MeshNode* > &nodeVec,
|
||||||
netgen::Mesh* ngMesh,
|
netgen::Mesh* ngMesh,
|
||||||
NETGENPlugin_NetgenLibWrapper &ngLib,
|
NETGENPlugin_NetgenLibWrapper &ngLib,
|
||||||
netgen_params &aParams,
|
|
||||||
int &startWith, int &endWith)
|
int &startWith, int &endWith)
|
||||||
{
|
{
|
||||||
int err = 1;
|
int err = 1;
|
||||||
@ -483,8 +473,7 @@ bool NETGENPlugin_NETGEN_3D::computeRunMesher(
|
|||||||
if(netgen::multithread.terminate)
|
if(netgen::multithread.terminate)
|
||||||
return false;
|
return false;
|
||||||
if ( err ){
|
if ( err ){
|
||||||
aParams._comment = SMESH_Comment("Error in netgen::OCCGenerateMesh() at ") << netgen::multithread.task;
|
error(SMESH_Comment("Error in netgen::OCCGenerateMesh() at ") << netgen::multithread.task);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Standard_Failure& ex)
|
catch (Standard_Failure& ex)
|
||||||
@ -494,8 +483,7 @@ bool NETGENPlugin_NETGEN_3D::computeRunMesher(
|
|||||||
<< ": " << ex.DynamicType()->Name();
|
<< ": " << ex.DynamicType()->Name();
|
||||||
if ( ex.GetMessageString() && strlen( ex.GetMessageString() ))
|
if ( ex.GetMessageString() && strlen( ex.GetMessageString() ))
|
||||||
str << ": " << ex.GetMessageString();
|
str << ": " << ex.GetMessageString();
|
||||||
aParams._comment = str;
|
error(str);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
catch (netgen::NgException& exc)
|
catch (netgen::NgException& exc)
|
||||||
{
|
{
|
||||||
@ -503,25 +491,21 @@ bool NETGENPlugin_NETGEN_3D::computeRunMesher(
|
|||||||
if ( strlen( netgen::multithread.task ) > 0 )
|
if ( strlen( netgen::multithread.task ) > 0 )
|
||||||
str << " at " << netgen::multithread.task;
|
str << " at " << netgen::multithread.task;
|
||||||
str << ": " << exc.What();
|
str << ": " << exc.What();
|
||||||
aParams._comment = str;
|
error(str);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
SMESH_Comment str("Exception in netgen::OCCGenerateMesh()");
|
SMESH_Comment str("Exception in netgen::OCCGenerateMesh()");
|
||||||
if ( strlen( netgen::multithread.task ) > 0 )
|
if ( strlen( netgen::multithread.task ) > 0 )
|
||||||
str << " at " << netgen::multithread.task;
|
str << " at " << netgen::multithread.task;
|
||||||
aParams._comment = str;
|
error(str);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( err )
|
if ( err )
|
||||||
{
|
{
|
||||||
SMESH_ComputeErrorPtr ce = NETGENPlugin_Mesher::ReadErrors(nodeVec);
|
SMESH_ComputeErrorPtr ce = NETGENPlugin_Mesher::ReadErrors(nodeVec);
|
||||||
if ( ce && ce->HasBadElems() ){
|
if ( ce && ce->HasBadElems() ){
|
||||||
aParams._error = ce->myName;
|
error( ce );
|
||||||
aParams._comment = ce->myComment;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -586,30 +570,12 @@ bool NETGENPlugin_NETGEN_3D::Compute(
|
|||||||
int endWith = netgen::MESHCONST_OPTVOLUME;
|
int endWith = netgen::MESHCONST_OPTVOLUME;
|
||||||
int Netgen_NbOfNodes;
|
int Netgen_NbOfNodes;
|
||||||
|
|
||||||
netgen_params aParams;
|
computeFillNgMesh(aMesh, aShape, nodeVec, ngLib, helper, Netgen_NbOfNodes);
|
||||||
|
|
||||||
aParams._hypParameters = const_cast<NETGENPlugin_Hypothesis*>(_hypParameters);
|
|
||||||
aParams._hypMaxElementVolume = const_cast<StdMeshers_MaxElementVolume*>(_hypMaxElementVolume);
|
|
||||||
aParams.maxElementVolume = _maxElementVolume;
|
|
||||||
aParams._progressByTic = _progressByTic;
|
|
||||||
aParams._quadraticMesh = _quadraticMesh;
|
|
||||||
aParams._viscousLayersHyp = const_cast<StdMeshers_ViscousLayers*>(_viscousLayersHyp);
|
|
||||||
|
|
||||||
bool ret;
|
|
||||||
ret = computeFillNgMesh(aMesh, aShape, nodeVec, ngLib, helper, aParams, Netgen_NbOfNodes);
|
|
||||||
if(ret)
|
|
||||||
return error( aParams._error, aParams._comment);
|
|
||||||
|
|
||||||
netgen::OCCGeometry occgeo;
|
netgen::OCCGeometry occgeo;
|
||||||
computePrepareParam(aMesh, ngLib, occgeo, helper, aParams, endWith);
|
computePrepareParam(aMesh, ngLib, occgeo, helper, endWith);
|
||||||
ret = computeRunMesher(occgeo, nodeVec, ngLib._ngMesh, ngLib, aParams, startWith, endWith);
|
computeRunMesher(occgeo, nodeVec, ngLib._ngMesh, ngLib, startWith, endWith);
|
||||||
if(ret){
|
|
||||||
if(aParams._error)
|
|
||||||
return error(aParams._error, aParams._comment);
|
|
||||||
|
|
||||||
error(aParams._comment);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
computeFillMesh(nodeVec, ngLib, helper, Netgen_NbOfNodes);
|
computeFillMesh(nodeVec, ngLib, helper, Netgen_NbOfNodes);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -77,7 +77,6 @@ class NETGENPLUGIN_EXPORT NETGENPlugin_NETGEN_3D: public SMESH_3D_Algo
|
|||||||
std::vector< const SMDS_MeshNode* > &nodeVec,
|
std::vector< const SMDS_MeshNode* > &nodeVec,
|
||||||
NETGENPlugin_NetgenLibWrapper &ngLib,
|
NETGENPlugin_NetgenLibWrapper &ngLib,
|
||||||
SMESH_MesherHelper &helper,
|
SMESH_MesherHelper &helper,
|
||||||
netgen_params &aParams,
|
|
||||||
int &Netgen_NbOfNodes);
|
int &Netgen_NbOfNodes);
|
||||||
|
|
||||||
bool computePrepareParam(
|
bool computePrepareParam(
|
||||||
@ -85,7 +84,6 @@ class NETGENPLUGIN_EXPORT NETGENPlugin_NETGEN_3D: public SMESH_3D_Algo
|
|||||||
NETGENPlugin_NetgenLibWrapper &ngLib,
|
NETGENPlugin_NetgenLibWrapper &ngLib,
|
||||||
netgen::OCCGeometry &occgeo,
|
netgen::OCCGeometry &occgeo,
|
||||||
SMESH_MesherHelper &helper,
|
SMESH_MesherHelper &helper,
|
||||||
netgen_params &aParams,
|
|
||||||
int &endWith);
|
int &endWith);
|
||||||
|
|
||||||
bool computeRunMesher(
|
bool computeRunMesher(
|
||||||
@ -93,7 +91,6 @@ class NETGENPLUGIN_EXPORT NETGENPlugin_NETGEN_3D: public SMESH_3D_Algo
|
|||||||
std::vector< const SMDS_MeshNode* > &nodeVec,
|
std::vector< const SMDS_MeshNode* > &nodeVec,
|
||||||
netgen::Mesh* ngMesh,
|
netgen::Mesh* ngMesh,
|
||||||
NETGENPlugin_NetgenLibWrapper &ngLib,
|
NETGENPlugin_NetgenLibWrapper &ngLib,
|
||||||
netgen_params &aParams,
|
|
||||||
int &startWith, int &endWith);
|
int &startWith, int &endWith);
|
||||||
|
|
||||||
bool computeFillMesh(
|
bool computeFillMesh(
|
||||||
@ -110,7 +107,6 @@ class NETGENPLUGIN_EXPORT NETGENPlugin_NETGEN_3D: public SMESH_3D_Algo
|
|||||||
SMESH_ProxyMesh::Ptr proxyMesh,
|
SMESH_ProxyMesh::Ptr proxyMesh,
|
||||||
NETGENPlugin_Internals &internals,
|
NETGENPlugin_Internals &internals,
|
||||||
SMESH_MesherHelper &helper,
|
SMESH_MesherHelper &helper,
|
||||||
netgen_params &aParams,
|
|
||||||
std::map<const SMDS_MeshElement*, std::tuple<bool, bool>>& listElements);
|
std::map<const SMDS_MeshElement*, std::tuple<bool, bool>>& listElements);
|
||||||
|
|
||||||
bool compute(SMESH_Mesh& mesh,
|
bool compute(SMESH_Mesh& mesh,
|
||||||
|
@ -141,7 +141,6 @@ void NETGENPlugin_NETGEN_3D_Remote::fillParameters(const NETGENPlugin_Hypothesis
|
|||||||
// write in a binary file the orientation for each 2D element of the mesh
|
// write in a binary file the orientation for each 2D element of the mesh
|
||||||
void NETGENPlugin_NETGEN_3D_Remote::exportElementOrientation(SMESH_Mesh& aMesh,
|
void NETGENPlugin_NETGEN_3D_Remote::exportElementOrientation(SMESH_Mesh& aMesh,
|
||||||
const TopoDS_Shape& aShape,
|
const TopoDS_Shape& aShape,
|
||||||
netgen_params& aParams,
|
|
||||||
const std::string output_file)
|
const std::string output_file)
|
||||||
{
|
{
|
||||||
SMESH_MesherHelper helper(aMesh);
|
SMESH_MesherHelper helper(aMesh);
|
||||||
@ -165,7 +164,7 @@ void NETGENPlugin_NETGEN_3D_Remote::exportElementOrientation(SMESH_Mesh& aMesh,
|
|||||||
if ( !aSubMeshDSFace ) continue;
|
if ( !aSubMeshDSFace ) continue;
|
||||||
|
|
||||||
SMDS_ElemIteratorPtr iteratorElem = aSubMeshDSFace->GetElements();
|
SMDS_ElemIteratorPtr iteratorElem = aSubMeshDSFace->GetElements();
|
||||||
if ( aParams._quadraticMesh &&
|
if ( _quadraticMesh &&
|
||||||
dynamic_cast< const SMESH_ProxyMesh::SubMesh*>( aSubMeshDSFace ))
|
dynamic_cast< const SMESH_ProxyMesh::SubMesh*>( aSubMeshDSFace ))
|
||||||
{
|
{
|
||||||
// add medium nodes of proxy triangles to helper (#16843)
|
// add medium nodes of proxy triangles to helper (#16843)
|
||||||
@ -238,7 +237,7 @@ bool NETGENPlugin_NETGEN_3D_Remote::Compute(SMESH_Mesh& aMesh,
|
|||||||
exportNetgenParams(param_file.string(), aParams);
|
exportNetgenParams(param_file.string(), aParams);
|
||||||
|
|
||||||
// Exporting element orientation
|
// Exporting element orientation
|
||||||
exportElementOrientation(aMesh, aShape, aParams, element_orientation_file.string());
|
exportElementOrientation(aMesh, aShape, element_orientation_file.string());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calling run_mesher
|
// Calling run_mesher
|
||||||
|
@ -64,7 +64,6 @@ class NETGENPLUGIN_EXPORT NETGENPlugin_NETGEN_3D_Remote: public NETGENPlugin_NET
|
|||||||
protected:
|
protected:
|
||||||
void exportElementOrientation(SMESH_Mesh& aMesh,
|
void exportElementOrientation(SMESH_Mesh& aMesh,
|
||||||
const TopoDS_Shape& aShape,
|
const TopoDS_Shape& aShape,
|
||||||
netgen_params& aParams,
|
|
||||||
const std::string output_file);
|
const std::string output_file);
|
||||||
|
|
||||||
void fillParameters(const NETGENPlugin_Hypothesis* hyp,
|
void fillParameters(const NETGENPlugin_Hypothesis* hyp,
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
#include "NETGENPlugin_DriverParam.hxx"
|
#include "NETGENPlugin_DriverParam.hxx"
|
||||||
#include "NETGENPlugin_Hypothesis.hxx"
|
#include "NETGENPlugin_Hypothesis.hxx"
|
||||||
|
#include "StdMeshers_MaxElementVolume.hxx"
|
||||||
|
|
||||||
#include <SMESH_Gen.hxx>
|
#include <SMESH_Gen.hxx>
|
||||||
#include <SMESH_Mesh.hxx>
|
#include <SMESH_Mesh.hxx>
|
||||||
@ -98,6 +99,47 @@ NETGENPlugin_NETGEN_3D_SA::~NETGENPlugin_NETGEN_3D_SA()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
void NETGENPlugin_NETGEN_3D_SA::fillHyp(netgen_params aParams, SMESH_Gen* gen)
|
||||||
|
{
|
||||||
|
if(aParams.has_netgen_param){
|
||||||
|
NETGENPlugin_Hypothesis * hypParameters = new NETGENPlugin_Hypothesis(0, gen);
|
||||||
|
|
||||||
|
hypParameters->SetMaxSize(aParams.maxh);
|
||||||
|
hypParameters->SetMinSize(aParams.minh);
|
||||||
|
hypParameters->SetNbSegPerEdge(aParams.segmentsperedge);
|
||||||
|
hypParameters->SetGrowthRate(aParams.grading);
|
||||||
|
hypParameters->SetNbSegPerRadius(aParams.curvaturesafety);
|
||||||
|
hypParameters->SetSecondOrder(aParams.secondorder);
|
||||||
|
hypParameters->SetQuadAllowed(aParams.quad);
|
||||||
|
hypParameters->SetOptimize(aParams.optimize);
|
||||||
|
hypParameters->SetFineness((NETGENPlugin_Hypothesis::Fineness)aParams.fineness);
|
||||||
|
hypParameters->SetSurfaceCurvature(aParams.uselocalh);
|
||||||
|
hypParameters->SetFuseEdges(aParams.merge_solids);
|
||||||
|
hypParameters->SetChordalErrorEnabled(aParams.chordalError);
|
||||||
|
if(aParams.optimize){
|
||||||
|
hypParameters->SetNbSurfOptSteps(aParams.optsteps2d);
|
||||||
|
hypParameters->SetNbVolOptSteps(aParams.optsteps3d);
|
||||||
|
}
|
||||||
|
hypParameters->SetElemSizeWeight(aParams.elsizeweight);
|
||||||
|
hypParameters->SetWorstElemMeasure(aParams.opterrpow);
|
||||||
|
hypParameters->SetUseDelauney(aParams.delaunay);
|
||||||
|
hypParameters->SetCheckOverlapping(aParams.checkoverlap);
|
||||||
|
hypParameters->SetCheckChartBoundary(aParams.checkchartboundary);
|
||||||
|
hypParameters->SetMeshSizeFile(aParams.meshsizefilename);
|
||||||
|
|
||||||
|
_hypParameters = dynamic_cast< const NETGENPlugin_Hypothesis *> (hypParameters);
|
||||||
|
}
|
||||||
|
if(aParams.has_maxelementvolume_hyp){
|
||||||
|
_hypMaxElementVolume = new StdMeshers_MaxElementVolume(1, gen);
|
||||||
|
_maxElementVolume = aParams.maxElementVolume;
|
||||||
|
}
|
||||||
|
// TODO: Handle viscous layer
|
||||||
|
}
|
||||||
|
|
||||||
bool NETGENPlugin_NETGEN_3D_SA::computeFillNewElementFile(
|
bool NETGENPlugin_NETGEN_3D_SA::computeFillNewElementFile(
|
||||||
std::vector< const SMDS_MeshNode* > &nodeVec,
|
std::vector< const SMDS_MeshNode* > &nodeVec,
|
||||||
NETGENPlugin_NetgenLibWrapper &ngLib,
|
NETGENPlugin_NetgenLibWrapper &ngLib,
|
||||||
@ -150,8 +192,7 @@ bool NETGENPlugin_NETGEN_3D_SA::computeFillNewElementFile(
|
|||||||
|
|
||||||
|
|
||||||
bool NETGENPlugin_NETGEN_3D_SA::Compute(TopoDS_Shape &aShape, SMESH_Mesh& aMesh, netgen_params& aParams,
|
bool NETGENPlugin_NETGEN_3D_SA::Compute(TopoDS_Shape &aShape, SMESH_Mesh& aMesh, netgen_params& aParams,
|
||||||
std::string new_element_file, std::string element_orientation_file,
|
std::string new_element_file, bool output_mesh)
|
||||||
bool output_mesh)
|
|
||||||
{
|
{
|
||||||
// vector of nodes in which node index == netgen ID
|
// vector of nodes in which node index == netgen ID
|
||||||
vector< const SMDS_MeshNode* > nodeVec;
|
vector< const SMDS_MeshNode* > nodeVec;
|
||||||
@ -161,22 +202,12 @@ bool NETGENPlugin_NETGEN_3D_SA::Compute(TopoDS_Shape &aShape, SMESH_Mesh& aMesh,
|
|||||||
int endWith = netgen::MESHCONST_OPTVOLUME;
|
int endWith = netgen::MESHCONST_OPTVOLUME;
|
||||||
int Netgen_NbOfNodes=0;
|
int Netgen_NbOfNodes=0;
|
||||||
|
|
||||||
bool ret;
|
NETGENPlugin_NETGEN_3D::computeFillNgMesh(aMesh, aShape, nodeVec, ngLib, helper, Netgen_NbOfNodes);
|
||||||
ret = NETGENPlugin_NETGEN_3D::computeFillNgMesh(aMesh, aShape, nodeVec, ngLib, helper, aParams, Netgen_NbOfNodes);
|
|
||||||
if(ret)
|
|
||||||
return error( aParams._error, aParams._comment);
|
|
||||||
|
|
||||||
netgen::OCCGeometry occgeo;
|
netgen::OCCGeometry occgeo;
|
||||||
NETGENPlugin_NETGEN_3D::computePrepareParam(aMesh, ngLib, occgeo, helper, aParams, endWith);
|
NETGENPlugin_NETGEN_3D::computePrepareParam(aMesh, ngLib, occgeo, helper, endWith);
|
||||||
|
|
||||||
ret = NETGENPlugin_NETGEN_3D::computeRunMesher(occgeo, nodeVec, ngLib._ngMesh, ngLib, aParams, startWith, endWith);
|
NETGENPlugin_NETGEN_3D::computeRunMesher(occgeo, nodeVec, ngLib._ngMesh, ngLib, startWith, endWith);
|
||||||
if(ret){
|
|
||||||
if(aParams._error)
|
|
||||||
return error(aParams._error, aParams._comment);
|
|
||||||
|
|
||||||
error(aParams._comment);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
computeFillNewElementFile(nodeVec, ngLib, new_element_file, Netgen_NbOfNodes);
|
computeFillNewElementFile(nodeVec, ngLib, new_element_file, Netgen_NbOfNodes);
|
||||||
|
|
||||||
@ -210,13 +241,14 @@ int NETGENPlugin_NETGEN_3D_SA::run(const std::string input_mesh_file,
|
|||||||
// Importing hypothesis
|
// Importing hypothesis
|
||||||
netgen_params myParams;
|
netgen_params myParams;
|
||||||
|
|
||||||
importNetgenParams(hypo_file, myParams, &gen);
|
importNetgenParams(hypo_file, myParams);
|
||||||
|
fillHyp(myParams, &gen);
|
||||||
// Setting number of threads for netgen
|
// Setting number of threads for netgen
|
||||||
myParams.nbThreads = nbThreads;
|
myParams.nbThreads = nbThreads;
|
||||||
|
|
||||||
MESSAGE("Meshing with netgen3d");
|
MESSAGE("Meshing with netgen3d");
|
||||||
int ret = Compute(myShape, *myMesh, myParams,
|
int ret = Compute(myShape, *myMesh, myParams,
|
||||||
new_element_file, element_orientation_file,
|
new_element_file,
|
||||||
!output_mesh_file.empty());
|
!output_mesh_file.empty());
|
||||||
|
|
||||||
|
|
||||||
@ -240,10 +272,14 @@ bool NETGENPlugin_NETGEN_3D_SA::getSurfaceElements(
|
|||||||
SMESH_ProxyMesh::Ptr proxyMesh,
|
SMESH_ProxyMesh::Ptr proxyMesh,
|
||||||
NETGENPlugin_Internals &internals,
|
NETGENPlugin_Internals &internals,
|
||||||
SMESH_MesherHelper &helper,
|
SMESH_MesherHelper &helper,
|
||||||
netgen_params &aParams,
|
|
||||||
std::map<const SMDS_MeshElement*, tuple<bool, bool>>& listElements
|
std::map<const SMDS_MeshElement*, tuple<bool, bool>>& listElements
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
// To remove compilation warnings
|
||||||
|
(void) aShape;
|
||||||
|
(void) proxyMesh;
|
||||||
|
(void) internals;
|
||||||
|
(void) helper;
|
||||||
SMESHDS_Mesh* meshDS = aMesh.GetMeshDS();
|
SMESHDS_Mesh* meshDS = aMesh.GetMeshDS();
|
||||||
|
|
||||||
// Get list of elements + their orientation from element_orientation file
|
// Get list of elements + their orientation from element_orientation file
|
||||||
@ -283,7 +319,6 @@ bool NETGENPlugin_NETGEN_3D_SA::getSurfaceElements(
|
|||||||
// Adding elements from Mesh
|
// Adding elements from Mesh
|
||||||
SMDS_ElemIteratorPtr iteratorElem = meshDS->elementsIterator(SMDSAbs_Face);
|
SMDS_ElemIteratorPtr iteratorElem = meshDS->elementsIterator(SMDSAbs_Face);
|
||||||
bool isRev;
|
bool isRev;
|
||||||
bool isInternalFace = false;
|
|
||||||
|
|
||||||
bool isIn;
|
bool isIn;
|
||||||
|
|
||||||
@ -292,14 +327,10 @@ bool NETGENPlugin_NETGEN_3D_SA::getSurfaceElements(
|
|||||||
// check mesh face
|
// check mesh face
|
||||||
const SMDS_MeshElement* elem = iteratorElem->next();
|
const SMDS_MeshElement* elem = iteratorElem->next();
|
||||||
if ( !elem ){
|
if ( !elem ){
|
||||||
aParams._error = COMPERR_BAD_INPUT_MESH;
|
return error( COMPERR_BAD_INPUT_MESH, "Null element encounters");
|
||||||
aParams._comment = "Null element encounters";
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
if ( elem->NbCornerNodes() != 3 ){
|
if ( elem->NbCornerNodes() != 3 ){
|
||||||
aParams._error = COMPERR_BAD_INPUT_MESH;
|
return error( COMPERR_BAD_INPUT_MESH, "Not triangle element encounters");
|
||||||
aParams._comment = "Not triangle element encounters";
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
// Keeping only element that are in the element orientation file
|
// Keeping only element that are in the element orientation file
|
||||||
isIn = elemOrientation.count(elem->GetID())==1;
|
isIn = elemOrientation.count(elem->GetID())==1;
|
||||||
|
@ -48,9 +48,9 @@ class NETGENPLUGIN_EXPORT NETGENPlugin_NETGEN_3D_SA: public NETGENPlugin_NETGEN_
|
|||||||
NETGENPlugin_NETGEN_3D_SA();
|
NETGENPlugin_NETGEN_3D_SA();
|
||||||
virtual ~NETGENPlugin_NETGEN_3D_SA();
|
virtual ~NETGENPlugin_NETGEN_3D_SA();
|
||||||
|
|
||||||
|
void fillHyp(netgen_params aParams, SMESH_Gen* gen);
|
||||||
bool Compute(TopoDS_Shape &aShape, SMESH_Mesh& aMesh, netgen_params& aParams,
|
bool Compute(TopoDS_Shape &aShape, SMESH_Mesh& aMesh, netgen_params& aParams,
|
||||||
std::string new_element_file, std::string element_orientation_file,
|
std::string new_element_file, bool output_mesh);
|
||||||
bool output_mesh);
|
|
||||||
|
|
||||||
int run(const std::string input_mesh_file,
|
int run(const std::string input_mesh_file,
|
||||||
const std::string shape_file,
|
const std::string shape_file,
|
||||||
@ -76,7 +76,6 @@ class NETGENPLUGIN_EXPORT NETGENPlugin_NETGEN_3D_SA: public NETGENPlugin_NETGEN_
|
|||||||
SMESH_ProxyMesh::Ptr proxyMesh,
|
SMESH_ProxyMesh::Ptr proxyMesh,
|
||||||
NETGENPlugin_Internals &internals,
|
NETGENPlugin_Internals &internals,
|
||||||
SMESH_MesherHelper &helper,
|
SMESH_MesherHelper &helper,
|
||||||
netgen_params &aParams,
|
|
||||||
std::map<const SMDS_MeshElement*, tuple<bool, bool>>& listElements
|
std::map<const SMDS_MeshElement*, tuple<bool, bool>>& listElements
|
||||||
) override;
|
) override;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user