Adding nnthreads as parameter for netgen
This commit is contained in:
parent
54a50107a5
commit
61e4da3b0d
@ -147,6 +147,9 @@ module NETGENPlugin
|
||||
void SetWorstElemMeasure(in short val );
|
||||
short GetWorstElemMeasure();
|
||||
|
||||
void SetNbThreads(in short val );
|
||||
short GetNbThreads();
|
||||
|
||||
void SetUseDelauney(in boolean toUse);
|
||||
boolean GetUseDelauney();
|
||||
|
||||
|
@ -148,6 +148,12 @@ class NETGEN_Algorithm(Mesh_Algorithm):
|
||||
if self.Parameters(): self.params.SetGrowthRate(theRate)
|
||||
pass
|
||||
|
||||
## Sets @c NbThreads parameter
|
||||
# @param theRate new value of the @c NbThreads parameter
|
||||
def SetNbThreads(self, theNumber):
|
||||
if self.Parameters(): self.params.SetNbThreads(theNumber)
|
||||
pass
|
||||
|
||||
## Creates meshing hypothesis according to the chosen algorithm type
|
||||
# and initializes it with default parameters
|
||||
# @param which hypothesis type; can be either @ref SOLE (default) or @ref SIMPLE
|
||||
|
@ -59,6 +59,7 @@ void printNetgenParams(netgen_params& aParams){
|
||||
std::cout << "checkoverlap: " << aParams.checkoverlap << std::endl;
|
||||
std::cout << "checkchartboundary: " << aParams.checkchartboundary << std::endl;
|
||||
std::cout << "closeedgefac: " << aParams.closeedgefac << std::endl;
|
||||
std::cout << "nbThreadMesher: " << aParams.nbThreads << std::endl;
|
||||
std::cout << "has_local_size: " << aParams.has_local_size << std::endl;
|
||||
std::cout << "meshsizefilename: " << aParams.meshsizefilename << std::endl;
|
||||
std::cout << "has_maxelementvolume_hyp: " << aParams.has_maxelementvolume_hyp << std::endl;
|
||||
@ -119,6 +120,8 @@ void importNetgenParams(const std::string param_file, netgen_params& aParams){
|
||||
std::getline(myfile, line);
|
||||
aParams.closeedgefac = std::stoi(line);
|
||||
std::getline(myfile, line);
|
||||
aParams.nbThreads = std::stoi(line);
|
||||
std::getline(myfile, line);
|
||||
aParams.has_local_size = std::stoi(line);
|
||||
std::getline(myfile, line);
|
||||
aParams.meshsizefilename = line;
|
||||
@ -160,6 +163,7 @@ void exportNetgenParams(const std::string param_file, netgen_params& aParams){
|
||||
myfile << aParams.checkoverlap << std::endl;
|
||||
myfile << aParams.checkchartboundary << std::endl;
|
||||
myfile << aParams.closeedgefac << std::endl;
|
||||
myfile << aParams.nbThreads << std::endl;
|
||||
myfile << aParams.has_local_size << std::endl;
|
||||
myfile << aParams.meshsizefilename << std::endl;
|
||||
myfile << aParams.has_maxelementvolume_hyp << std::endl;
|
||||
|
@ -58,6 +58,7 @@ NETGENPlugin_Hypothesis::NETGENPlugin_Hypothesis (int hypId, SMESH_Gen * gen)
|
||||
_nbVolOptSteps (GetDefaultNbVolOptSteps()),
|
||||
_elemSizeWeight (GetDefaultElemSizeWeight()),
|
||||
_worstElemMeasure (GetDefaultWorstElemMeasure()),
|
||||
_nbThreads (GetDefaultNbThreads()),
|
||||
_surfaceCurvature (GetDefaultSurfaceCurvature()),
|
||||
_useDelauney (GetDefaultUseDelauney()),
|
||||
_checkOverlapping (GetDefaultCheckOverlapping()),
|
||||
@ -84,7 +85,7 @@ void NETGENPlugin_Hypothesis::SetMaxSize(double theSize)
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
*
|
||||
*
|
||||
*/
|
||||
//=============================================================================
|
||||
void NETGENPlugin_Hypothesis::SetMinSize(double theSize)
|
||||
@ -98,7 +99,7 @@ void NETGENPlugin_Hypothesis::SetMinSize(double theSize)
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
*
|
||||
*
|
||||
*/
|
||||
//=============================================================================
|
||||
void NETGENPlugin_Hypothesis::SetSecondOrder(bool theVal)
|
||||
@ -112,7 +113,7 @@ void NETGENPlugin_Hypothesis::SetSecondOrder(bool theVal)
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
*
|
||||
*
|
||||
*/
|
||||
//=============================================================================
|
||||
void NETGENPlugin_Hypothesis::SetOptimize(bool theVal)
|
||||
@ -126,7 +127,7 @@ void NETGENPlugin_Hypothesis::SetOptimize(bool theVal)
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
*
|
||||
*
|
||||
*/
|
||||
//=============================================================================
|
||||
void NETGENPlugin_Hypothesis::SetFineness(Fineness theFineness)
|
||||
@ -172,7 +173,7 @@ void NETGENPlugin_Hypothesis::SetFineness(Fineness theFineness)
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
*
|
||||
*
|
||||
*/
|
||||
//=============================================================================
|
||||
void NETGENPlugin_Hypothesis::SetGrowthRate(double theRate)
|
||||
@ -187,7 +188,7 @@ void NETGENPlugin_Hypothesis::SetGrowthRate(double theRate)
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
*
|
||||
*
|
||||
*/
|
||||
//=============================================================================
|
||||
void NETGENPlugin_Hypothesis::SetNbSegPerEdge(double theVal)
|
||||
@ -202,7 +203,7 @@ void NETGENPlugin_Hypothesis::SetNbSegPerEdge(double theVal)
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
*
|
||||
*
|
||||
*/
|
||||
//=============================================================================
|
||||
void NETGENPlugin_Hypothesis::SetNbSegPerRadius(double theVal)
|
||||
@ -217,7 +218,7 @@ void NETGENPlugin_Hypothesis::SetNbSegPerRadius(double theVal)
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
*
|
||||
*
|
||||
*/
|
||||
//=============================================================================
|
||||
void NETGENPlugin_Hypothesis::SetChordalErrorEnabled(bool theVal)
|
||||
@ -231,7 +232,7 @@ void NETGENPlugin_Hypothesis::SetChordalErrorEnabled(bool theVal)
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
*
|
||||
*
|
||||
*/
|
||||
//=============================================================================
|
||||
void NETGENPlugin_Hypothesis::SetChordalError(double theVal)
|
||||
@ -245,7 +246,7 @@ void NETGENPlugin_Hypothesis::SetChordalError(double theVal)
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
*
|
||||
*
|
||||
*/
|
||||
//=============================================================================
|
||||
void NETGENPlugin_Hypothesis::SetLocalSizeOnEntry(const std::string& entry, double localSize)
|
||||
@ -273,7 +274,7 @@ double NETGENPlugin_Hypothesis::GetLocalSizeOnEntry(const std::string& entry)
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
*
|
||||
*
|
||||
*/
|
||||
//=============================================================================
|
||||
void NETGENPlugin_Hypothesis::UnsetLocalSizeOnEntry(const std::string& entry)
|
||||
@ -284,7 +285,7 @@ void NETGENPlugin_Hypothesis::UnsetLocalSizeOnEntry(const std::string& entry)
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
*
|
||||
*
|
||||
*/
|
||||
//=============================================================================
|
||||
void NETGENPlugin_Hypothesis::SetMeshSizeFile(const std::string& fileName)
|
||||
@ -298,7 +299,7 @@ void NETGENPlugin_Hypothesis::SetMeshSizeFile(const std::string& fileName)
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
*
|
||||
*
|
||||
*/
|
||||
//=============================================================================
|
||||
void NETGENPlugin_Hypothesis::SetQuadAllowed(bool theVal)
|
||||
@ -312,7 +313,7 @@ void NETGENPlugin_Hypothesis::SetQuadAllowed(bool theVal)
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
*
|
||||
*
|
||||
*/
|
||||
//=============================================================================
|
||||
void NETGENPlugin_Hypothesis::SetSurfaceCurvature(bool theVal)
|
||||
@ -340,7 +341,7 @@ void NETGENPlugin_Hypothesis::SetFuseEdges(bool theVal)
|
||||
|
||||
//=======================================================================
|
||||
//function : SetNbSurfOptSteps
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void NETGENPlugin_Hypothesis::SetNbSurfOptSteps( int theVal )
|
||||
@ -354,7 +355,7 @@ void NETGENPlugin_Hypothesis::SetNbSurfOptSteps( int theVal )
|
||||
|
||||
//=======================================================================
|
||||
//function : SetNbVolOptSteps
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void NETGENPlugin_Hypothesis::SetNbVolOptSteps( int theVal )
|
||||
@ -368,7 +369,7 @@ void NETGENPlugin_Hypothesis::SetNbVolOptSteps( int theVal )
|
||||
|
||||
//=======================================================================
|
||||
//function : SetElemSizeWeight
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void NETGENPlugin_Hypothesis::SetElemSizeWeight( double theVal )
|
||||
@ -382,7 +383,7 @@ void NETGENPlugin_Hypothesis::SetElemSizeWeight( double theVal )
|
||||
|
||||
//=======================================================================
|
||||
//function : SetWorstElemMeasure
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void NETGENPlugin_Hypothesis::SetWorstElemMeasure( int theVal )
|
||||
@ -396,7 +397,7 @@ void NETGENPlugin_Hypothesis::SetWorstElemMeasure( int theVal )
|
||||
|
||||
//=======================================================================
|
||||
//function : SetUseDelauney
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void NETGENPlugin_Hypothesis::SetUseDelauney( bool theVal )
|
||||
@ -410,7 +411,7 @@ void NETGENPlugin_Hypothesis::SetUseDelauney( bool theVal )
|
||||
|
||||
//=======================================================================
|
||||
//function : SetCheckOverlapping
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void NETGENPlugin_Hypothesis::SetCheckOverlapping( bool theVal )
|
||||
@ -424,7 +425,7 @@ void NETGENPlugin_Hypothesis::SetCheckOverlapping( bool theVal )
|
||||
|
||||
//=======================================================================
|
||||
//function : SetCheckChartBoundary
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void NETGENPlugin_Hypothesis::SetCheckChartBoundary( bool theVal )
|
||||
@ -436,6 +437,20 @@ void NETGENPlugin_Hypothesis::SetCheckChartBoundary( bool theVal )
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetNbThreads
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void NETGENPlugin_Hypothesis::SetNbThreads( int theVal )
|
||||
{
|
||||
if (theVal != _nbThreads)
|
||||
{
|
||||
_nbThreads = theVal;
|
||||
NotifySubMeshesHypothesisModification();
|
||||
}
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
*
|
||||
@ -485,7 +500,7 @@ ostream & NETGENPlugin_Hypothesis::SaveTo(ostream & save)
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
*
|
||||
*
|
||||
*/
|
||||
//=============================================================================
|
||||
istream & NETGENPlugin_Hypothesis::LoadFrom(istream & load)
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "Utils_SALOME_Exception.hxx"
|
||||
|
||||
#include <map>
|
||||
#include <thread>
|
||||
|
||||
// Parameters for work of NETGEN
|
||||
//
|
||||
@ -125,6 +126,9 @@ public:
|
||||
void SetCheckChartBoundary( bool toCheck );
|
||||
bool GetCheckChartBoundary() const { return _checkChartBoundary; }
|
||||
|
||||
void SetNbThreads( int val );
|
||||
int GetNbThreads() const { return _nbThreads; }
|
||||
|
||||
// the default values (taken from NETGEN 4.5 sources)
|
||||
|
||||
static Fineness GetDefaultFineness() { return Moderate; }
|
||||
@ -145,6 +149,7 @@ public:
|
||||
static bool GetDefaultCheckOverlapping() { return true; }
|
||||
static bool GetDefaultCheckChartBoundary(){ return true; }
|
||||
static bool GetDefaultFuseEdges() { return true; }
|
||||
static int GetDefaultNbThreads() { return std::thread::hardware_concurrency(); }
|
||||
|
||||
// Persistence
|
||||
virtual std::ostream & SaveTo (std::ostream & save);
|
||||
@ -197,6 +202,9 @@ private:
|
||||
//bool _blockFilling; -- not used by netgen
|
||||
// (SALOME additions)
|
||||
bool _fuseEdges;
|
||||
|
||||
// Parallelism parameters
|
||||
int _nbThreads;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -60,7 +60,7 @@ bool NETGENPlugin_Hypothesis_i::isToSetParameter<double>(double curValue,
|
||||
NETGENPlugin_Hypothesis_i::
|
||||
NETGENPlugin_Hypothesis_i (PortableServer::POA_ptr thePOA,
|
||||
::SMESH_Gen* theGenImpl)
|
||||
: SALOME::GenericObj_i( thePOA ),
|
||||
: SALOME::GenericObj_i( thePOA ),
|
||||
SMESH_Hypothesis_i( thePOA ),
|
||||
mySetMethodFlags(0)
|
||||
{
|
||||
@ -471,7 +471,7 @@ CORBA::Boolean NETGENPlugin_Hypothesis_i::GetFuseEdges()
|
||||
|
||||
//=======================================================================
|
||||
//function : SetNbSurfOptSteps
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void NETGENPlugin_Hypothesis_i::SetNbSurfOptSteps(CORBA::Short nb )
|
||||
@ -495,7 +495,7 @@ CORBA::Short NETGENPlugin_Hypothesis_i::GetNbSurfOptSteps()
|
||||
|
||||
//=======================================================================
|
||||
//function : SetNbVolOptSteps
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void NETGENPlugin_Hypothesis_i::SetNbVolOptSteps(CORBA::Short nb )
|
||||
@ -520,7 +520,7 @@ CORBA::Short NETGENPlugin_Hypothesis_i::GetNbVolOptSteps()
|
||||
|
||||
//=======================================================================
|
||||
//function : SetElemSizeWeight
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void NETGENPlugin_Hypothesis_i::SetElemSizeWeight(CORBA::Double size )
|
||||
@ -544,7 +544,7 @@ CORBA::Double NETGENPlugin_Hypothesis_i::GetElemSizeWeight()
|
||||
|
||||
//=======================================================================
|
||||
//function : SetWorstElemMeasure
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void NETGENPlugin_Hypothesis_i::SetWorstElemMeasure(CORBA::Short val )
|
||||
@ -558,7 +558,7 @@ void NETGENPlugin_Hypothesis_i::SetWorstElemMeasure(CORBA::Short val )
|
||||
|
||||
//=======================================================================
|
||||
//function : GetWorstElemMeasure
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
CORBA::Short NETGENPlugin_Hypothesis_i::GetWorstElemMeasure()
|
||||
@ -566,9 +566,33 @@ CORBA::Short NETGENPlugin_Hypothesis_i::GetWorstElemMeasure()
|
||||
return (CORBA::Short) GetImpl()->GetWorstElemMeasure();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetNbThreads
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void NETGENPlugin_Hypothesis_i::SetNbThreads(CORBA::Short val )
|
||||
{
|
||||
if ( GetNbThreads() != val )
|
||||
{
|
||||
this->GetImpl()->SetNbThreads( val );
|
||||
SMESH::TPythonDump() << _this() << ".SetNbThreads( " << SMESH::TVar(val) << " )";
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetNbThreads
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
CORBA::Short NETGENPlugin_Hypothesis_i::GetNbThreads()
|
||||
{
|
||||
return (CORBA::Short) GetImpl()->GetNbThreads();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetUseDelauney
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void NETGENPlugin_Hypothesis_i::SetUseDelauney(CORBA::Boolean toUse)
|
||||
@ -582,7 +606,7 @@ void NETGENPlugin_Hypothesis_i::SetUseDelauney(CORBA::Boolean toUse)
|
||||
|
||||
//=======================================================================
|
||||
//function : GetUseDelauney
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
CORBA::Boolean NETGENPlugin_Hypothesis_i::GetUseDelauney()
|
||||
@ -592,7 +616,7 @@ CORBA::Boolean NETGENPlugin_Hypothesis_i::GetUseDelauney()
|
||||
|
||||
//=======================================================================
|
||||
//function : SetCheckOverlapping
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void NETGENPlugin_Hypothesis_i::SetCheckOverlapping(CORBA::Boolean toCheck )
|
||||
@ -606,7 +630,7 @@ void NETGENPlugin_Hypothesis_i::SetCheckOverlapping(CORBA::Boolean toCheck )
|
||||
|
||||
//=======================================================================
|
||||
//function : GetCheckOverlapping
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
CORBA::Boolean NETGENPlugin_Hypothesis_i::GetCheckOverlapping()
|
||||
@ -616,7 +640,7 @@ CORBA::Boolean NETGENPlugin_Hypothesis_i::GetCheckOverlapping()
|
||||
|
||||
//=======================================================================
|
||||
//function : SetCheckChartBoundary
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void NETGENPlugin_Hypothesis_i::SetCheckChartBoundary(CORBA::Boolean toCheck )
|
||||
@ -652,13 +676,13 @@ CORBA::Boolean NETGENPlugin_Hypothesis_i::GetCheckChartBoundary()
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Verify whether hypothesis supports given entity type
|
||||
* \brief Verify whether hypothesis supports given entity type
|
||||
* \param type - dimension (see SMESH::Dimension enumeration)
|
||||
* \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
|
||||
*
|
||||
*
|
||||
* Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
|
||||
*/
|
||||
//================================================================================
|
||||
//================================================================================
|
||||
CORBA::Boolean NETGENPlugin_Hypothesis_i::IsDimSupported( SMESH::Dimension type )
|
||||
{
|
||||
return type == SMESH::DIM_3D;
|
||||
|
@ -113,6 +113,9 @@ class NETGENPLUGIN_EXPORT NETGENPlugin_Hypothesis_i:
|
||||
void SetWorstElemMeasure(CORBA::Short val );
|
||||
CORBA::Short GetWorstElemMeasure();
|
||||
|
||||
void SetNbThreads(CORBA::Short val );
|
||||
CORBA::Short GetNbThreads();
|
||||
|
||||
void SetUseDelauney(CORBA::Boolean toUse);
|
||||
CORBA::Boolean GetUseDelauney();
|
||||
|
||||
@ -125,7 +128,7 @@ class NETGENPLUGIN_EXPORT NETGENPlugin_Hypothesis_i:
|
||||
// Get implementation
|
||||
::NETGENPlugin_Hypothesis* GetImpl();
|
||||
|
||||
// Verify whether hypothesis supports given entity type
|
||||
// Verify whether hypothesis supports given entity type
|
||||
CORBA::Boolean IsDimSupported( SMESH::Dimension type );
|
||||
|
||||
|
||||
|
@ -602,14 +602,13 @@ void NETGENPlugin_Mesher::SetDefaultParameters()
|
||||
|
||||
#ifdef NETGEN_V6
|
||||
|
||||
mparams.nthreads = std::thread::hardware_concurrency();
|
||||
mparams.nthreads = NETGENPlugin_Hypothesis::GetDefaultNbThreads();
|
||||
|
||||
if ( getenv( "SALOME_NETGEN_DISABLE_MULTITHREADING" ))
|
||||
{
|
||||
mparams.nthreads = 1;
|
||||
mparams.parallel_meshing = false;
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -655,6 +654,7 @@ void NETGENPlugin_Mesher::SetParameters(const NETGENPlugin_Hypothesis* hyp)
|
||||
#ifdef NETGEN_V6
|
||||
// std::string
|
||||
mparams.meshsizefilename = hyp->GetMeshSizeFile();
|
||||
mparams.nthreads = hyp->GetNbThreads();
|
||||
#else
|
||||
// const char*
|
||||
mparams.meshsizefilename= hyp->GetMeshSizeFile().empty() ? 0 : hyp->GetMeshSizeFile().c_str();
|
||||
|
@ -127,13 +127,11 @@ void NETGENPlugin_NETGEN_3D_Remote::fillParameters(const NETGENPlugin_Hypothesis
|
||||
#ifdef NETGEN_V6
|
||||
// std::string
|
||||
aParams.meshsizefilename = hyp->GetMeshSizeFile();
|
||||
aParams.closeedgefac = 2;
|
||||
aParams.nbThreads = hyp->GetNbThreads();
|
||||
#else
|
||||
// const char*
|
||||
aParams.meshsizefilename = hyp->GetMeshSizeFile();
|
||||
#endif
|
||||
#ifdef NETGEN_V6
|
||||
aParams.closeedgefac = 2;
|
||||
#else
|
||||
aParams.closeedgefac = 0;
|
||||
#endif
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user