mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2024-12-28 10:20:34 +05:00
Parallel version for 1d mesher number of segment
This commit is contained in:
parent
642fc469af
commit
78ffe50bb9
@ -281,6 +281,9 @@ SMESH_Algo::GetUsedHypothesis(SMESH_Mesh & aMesh,
|
||||
if ( _usedHypList == savedHyps )
|
||||
savedHyps.swap( me->_usedHypList );
|
||||
|
||||
for(auto hyp:_usedHypList){
|
||||
std::cout << hyp << std::endl;
|
||||
}
|
||||
return _usedHypList;
|
||||
}
|
||||
|
||||
|
@ -262,6 +262,7 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh,
|
||||
std::cout << "Waiting" << std::endl;
|
||||
it->wait();
|
||||
}
|
||||
cout << "Number of segments: " << aMesh.NbEdges() << endl;
|
||||
//Resetting threaded pool info
|
||||
previousShapeType = shapeType;
|
||||
pending.clear();
|
||||
|
@ -65,6 +65,7 @@ using namespace std;
|
||||
//#define PRINT_WHO_COMPUTE_WHAT
|
||||
#endif
|
||||
|
||||
#define PRINT_WHO_COMPUTE_WHAT
|
||||
//=============================================================================
|
||||
/*!
|
||||
* \brief Allocate some memory at construction and release it at destruction.
|
||||
@ -206,6 +207,20 @@ SMESH_Algo* SMESH_subMesh::GetAlgo() const
|
||||
return _algo;
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Returns a current algorithm
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
SMESH_Algo* SMESH_subMesh::CopyAlgo() const
|
||||
{
|
||||
//SMESH_Algo* algo = (SMESH_Algo*) new StdMeshers_Regular_1D(666, _father->GetGent());
|
||||
SMESH_Algo* algo;
|
||||
|
||||
return algo;
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Allow algo->Compute() if a sub-shape of lower dim is meshed but
|
||||
@ -1392,6 +1407,7 @@ bool SMESH_subMesh::ComputeStateEngine(compute_event event)
|
||||
else if (( event == COMPUTE || event == COMPUTE_SUBMESH )
|
||||
&& !_alwaysComputed )
|
||||
{
|
||||
// LOCK: Adding node to mesh
|
||||
_father->Lock();
|
||||
const TopoDS_Vertex & V = TopoDS::Vertex( _subShape );
|
||||
gp_Pnt P = BRep_Tool::Pnt(V);
|
||||
@ -1400,6 +1416,7 @@ bool SMESH_subMesh::ComputeStateEngine(compute_event event)
|
||||
_computeState = COMPUTE_OK;
|
||||
}
|
||||
_father->Unlock();
|
||||
// UNLOCK
|
||||
}
|
||||
if ( event == MODIF_ALGO_STATE )
|
||||
cleanDependants();
|
||||
@ -1502,10 +1519,13 @@ bool SMESH_subMesh::ComputeStateEngine(compute_event event)
|
||||
case COMPUTE:
|
||||
case COMPUTE_SUBMESH:
|
||||
{
|
||||
_father->Lock();
|
||||
algo = GetAlgo();
|
||||
SMESH_Algo* algo2 = CopyAlgo();
|
||||
cout << "Algo2" << algo2;
|
||||
ASSERT(algo);
|
||||
ret = algo->CheckHypothesis((*_father), _subShape, hyp_status);
|
||||
//_father->Lock();
|
||||
//ret = algo->CheckHypothesis((*_father), _subShape, hyp_status);
|
||||
//_father->Unlock();
|
||||
if (!ret)
|
||||
{
|
||||
MESSAGE("***** verify compute state *****");
|
||||
@ -1516,7 +1536,9 @@ bool SMESH_subMesh::ComputeStateEngine(compute_event event)
|
||||
TopoDS_Shape shape = _subShape;
|
||||
algo->SubMeshesToCompute().assign( 1, this );
|
||||
// check submeshes needed
|
||||
if (_father->HasShapeToMesh() ) {
|
||||
// Forcing to false for parallel run
|
||||
// TODO: Remove forced false
|
||||
if (_father->HasShapeToMesh() && false) {
|
||||
bool subComputed = false, subFailed = false;
|
||||
if (!algo->OnlyUnaryInput()) {
|
||||
// --- commented for bos#22320 to compute all sub-shapes at once if possible;
|
||||
@ -1544,7 +1566,6 @@ bool SMESH_subMesh::ComputeStateEngine(compute_event event)
|
||||
break; // goto exit
|
||||
}
|
||||
}
|
||||
_father->Unlock();
|
||||
// Compute
|
||||
|
||||
// to restore cout that may be redirected by algo
|
||||
@ -1647,8 +1668,10 @@ bool SMESH_subMesh::ComputeStateEngine(compute_event event)
|
||||
#ifdef PRINT_WHO_COMPUTE_WHAT
|
||||
for (subS.ReInit(); subS.More(); subS.Next())
|
||||
{
|
||||
const std::list <const SMESHDS_Hypothesis *> & hyps =
|
||||
_father->Lock();
|
||||
const std::list <const SMESHDS_Hypothesis *> hyps =
|
||||
_algo->GetUsedHypothesis( *_father, _subShape );
|
||||
_father->Unlock();
|
||||
SMESH_Comment hypStr;
|
||||
if ( !hyps.empty() )
|
||||
{
|
||||
@ -1734,9 +1757,9 @@ bool SMESH_subMesh::ComputeStateEngine(compute_event event)
|
||||
updateDependantsState( SUBMESH_COMPUTED );
|
||||
}
|
||||
// let algo clear its data gathered while algo->Compute()
|
||||
_father->Lock();
|
||||
algo->CheckHypothesis((*_father), _subShape, hyp_status);
|
||||
_father->Unlock();
|
||||
//_father->Lock();
|
||||
//algo->CheckHypothesis((*_father), _subShape, hyp_status);
|
||||
//_father->Unlock();
|
||||
}
|
||||
break;
|
||||
case COMPUTE_CANCELED: // nothing to do
|
||||
@ -2172,8 +2195,10 @@ TopoDS_Shape SMESH_subMesh::getCollection(SMESH_Gen * /*theGen*/,
|
||||
return _subShape;
|
||||
|
||||
const bool skipAuxHyps = false;
|
||||
_father->Lock();
|
||||
list<const SMESHDS_Hypothesis*> usedHyps =
|
||||
theAlgo->GetUsedHypothesis( *_father, _subShape, skipAuxHyps ); // copy
|
||||
_father->Lock();
|
||||
std::list < TopoDS_Shape > assiShapes = theAlgo->GetAssignedShapes();
|
||||
|
||||
// put in a compound all shapes with the same hypothesis assigned
|
||||
@ -2201,6 +2226,7 @@ TopoDS_Shape SMESH_subMesh::getCollection(SMESH_Gen * /*theGen*/,
|
||||
}
|
||||
else if ( subMesh->GetComputeState() == READY_TO_COMPUTE )
|
||||
{
|
||||
_father->Lock();
|
||||
SMESH_Algo* anAlgo = subMesh->GetAlgo();
|
||||
if (( anAlgo->IsSameName( *theAlgo )) && // same algo
|
||||
( anAlgo->GetUsedHypothesis( *_father, S, skipAuxHyps ) == usedHyps ) && // same hyps
|
||||
@ -2212,6 +2238,7 @@ TopoDS_Shape SMESH_subMesh::getCollection(SMESH_Gen * /*theGen*/,
|
||||
theSubComputed = false;
|
||||
theSubs.push_back( subMesh );
|
||||
}
|
||||
_father->Unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,6 +79,7 @@ class SMESH_EXPORT SMESH_subMesh
|
||||
SMESH_subMesh *GetFirstToCompute();
|
||||
|
||||
SMESH_Algo* GetAlgo() const;
|
||||
SMESH_Algo* CopyAlgo() const;
|
||||
|
||||
const std::map < int, SMESH_subMesh * >& DependsOn();
|
||||
bool DependsOn( const SMESH_subMesh* other ) const;
|
||||
|
@ -126,14 +126,22 @@ bool StdMeshers_Regular_1D::CheckHypothesis( SMESH_Mesh& aMesh,
|
||||
_onlyUnaryInput = true;
|
||||
|
||||
// check propagation in a redefined GetUsedHypothesis()
|
||||
const list <const SMESHDS_Hypothesis * > & hyps =
|
||||
const list <const SMESHDS_Hypothesis * > hyps =
|
||||
GetUsedHypothesis(aMesh, aShape, /*ignoreAuxiliaryHyps=*/false);
|
||||
|
||||
const SMESH_HypoFilter & propagFilter = StdMeshers_Propagation::GetFilter();
|
||||
|
||||
// find non-auxiliary hypothesis
|
||||
const SMESHDS_Hypothesis *theHyp = 0;
|
||||
set< string > propagTypes;
|
||||
std::cout << "For shape " << aShape.HashCode(1) << " of type "<< aShape.ShapeType() <<
|
||||
"CheckHypothesis" << std::endl;
|
||||
for(auto hyp:hyps){
|
||||
SMESH_Comment hypStr;
|
||||
hypStr << hyp << " " << hyp->GetName() << " ";
|
||||
((SMESHDS_Hypothesis*)hyp)->SaveTo( hypStr.Stream() );
|
||||
hypStr << " ";
|
||||
std::cout << hypStr << std::endl;
|
||||
}
|
||||
list <const SMESHDS_Hypothesis * >::const_iterator h = hyps.begin();
|
||||
for ( ; h != hyps.end(); ++h ) {
|
||||
if ( static_cast<const SMESH_Hypothesis*>(*h)->IsAuxiliary() ) {
|
||||
@ -848,8 +856,12 @@ bool StdMeshers_Regular_1D::computeInternalParameters(SMESH_Mesh & theMesh,
|
||||
{
|
||||
// Number Of Segments hypothesis
|
||||
nbSegments = _ivalue[ NB_SEGMENTS_IND ];
|
||||
if ( nbSegments < 1 ) return false;
|
||||
if ( nbSegments == 1 ) return true;
|
||||
if ( nbSegments < 1 ) {
|
||||
return false;
|
||||
}
|
||||
if ( nbSegments == 1 ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (_ivalue[ DISTR_TYPE_IND ])
|
||||
{
|
||||
@ -1170,10 +1182,16 @@ bool StdMeshers_Regular_1D::computeInternalParameters(SMESH_Mesh & theMesh,
|
||||
|
||||
bool StdMeshers_Regular_1D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape & theShape)
|
||||
{
|
||||
if ( _hypType == NONE )
|
||||
return false;
|
||||
SMESH_Hypothesis::Hypothesis_Status hyp_status;
|
||||
theMesh.Lock();
|
||||
bool ret = this->CheckHypothesis(theMesh, theShape, hyp_status);
|
||||
int hypType = _hypType;
|
||||
theMesh.Unlock();
|
||||
|
||||
if ( _hypType == ADAPTIVE )
|
||||
if ( hypType == NONE )
|
||||
return false;
|
||||
|
||||
if ( hypType == ADAPTIVE )
|
||||
{
|
||||
_adaptiveHyp->GetAlgo()->InitComputeError();
|
||||
_adaptiveHyp->GetAlgo()->Compute( theMesh, theShape );
|
||||
@ -1183,6 +1201,7 @@ bool StdMeshers_Regular_1D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape & t
|
||||
SMESHDS_Mesh * meshDS = theMesh.GetMeshDS();
|
||||
|
||||
theMesh.Lock();
|
||||
|
||||
const TopoDS_Edge & EE = TopoDS::Edge(theShape);
|
||||
TopoDS_Edge E = TopoDS::Edge(EE.Oriented(TopAbs_FORWARD));
|
||||
int shapeID = meshDS->ShapeToIndex( E );
|
||||
@ -1199,6 +1218,7 @@ bool StdMeshers_Regular_1D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape & t
|
||||
const SMDS_MeshNode * nLast = SMESH_Algo::VertexNode( VLast, meshDS );
|
||||
if ( !nFirst || !nLast ){
|
||||
theMesh.Unlock();
|
||||
std::cout << "exit no node" << std::endl;
|
||||
return error( COMPERR_BAD_INPUT_MESH, "No node on vertex");
|
||||
}
|
||||
// remove elements created by e.g. pattern mapping (PAL21999)
|
||||
@ -1232,7 +1252,7 @@ bool StdMeshers_Regular_1D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape & t
|
||||
// take into account reversing the edge the hypothesis is propagated from
|
||||
// (_mainEdge.Orientation() marks mutual orientation of EDGEs in propagation chain)
|
||||
reversed = ( _mainEdge.Orientation() == TopAbs_REVERSED );
|
||||
if ( _hypType != DISTRIB_PROPAGATION ) {
|
||||
if ( hypType != DISTRIB_PROPAGATION ) {
|
||||
int mainID = meshDS->ShapeToIndex(_mainEdge);
|
||||
if ( std::find( _revEdgesIDs.begin(), _revEdgesIDs.end(), mainID) != _revEdgesIDs.end())
|
||||
reversed = !reversed;
|
||||
@ -1245,6 +1265,8 @@ bool StdMeshers_Regular_1D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape & t
|
||||
BRepAdaptor_Curve C3d( E );
|
||||
if ( ! computeInternalParameters( theMesh, C3d, length, f, l, params, reversed, true )) {
|
||||
theMesh.Unlock();
|
||||
std::cout << "exit Compute internal failed" << std::endl;
|
||||
|
||||
return false;
|
||||
}
|
||||
redistributeNearVertices( theMesh, C3d, length, params, VFirst, VLast );
|
||||
@ -1336,6 +1358,8 @@ bool StdMeshers_Regular_1D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape & t
|
||||
}
|
||||
}
|
||||
theMesh.Unlock();
|
||||
std::cout << "exit normal" << std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user