X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FStdMeshers%2FStdMeshers_ViscousLayers.cxx;h=15490846958af42bb33a46bde5243a33355c7ebf;hb=88ff35ddd4a4442397bc5f6ba893aaf9c51b1856;hp=270330be4ed87c7136859482f8130fbd0b2191ac;hpb=70eb9c09d00f9c4b0e48d5aba70676e45e779f9c;p=modules%2Fsmesh.git diff --git a/src/StdMeshers/StdMeshers_ViscousLayers.cxx b/src/StdMeshers/StdMeshers_ViscousLayers.cxx index 270330be4..154908469 100644 --- a/src/StdMeshers/StdMeshers_ViscousLayers.cxx +++ b/src/StdMeshers/StdMeshers_ViscousLayers.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2019 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -206,8 +206,8 @@ namespace VISCOUS_3D virtual void ProcessEvent(const int event, const int eventType, SMESH_subMesh* subMesh, - SMESH_subMeshEventListenerData* data, - const SMESH_Hypothesis* hyp) + SMESH_subMeshEventListenerData* /*data*/, + const SMESH_Hypothesis* /*hyp*/) { if (( SMESH_subMesh::COMPUTE_EVENT == eventType ) && ( SMESH_subMesh::CHECK_COMPUTE_STATE != event && @@ -917,7 +917,7 @@ namespace VISCOUS_3D private: - bool findSolidsWithLayers(); + bool findSolidsWithLayers(const bool checkFaceMesh=true); bool setBefore( _SolidData& solidBefore, _SolidData& solidAfter ); bool findFacesWithLayers(const bool onlyWith=false); void findPeriodicFaces(); @@ -1091,7 +1091,7 @@ namespace VISCOUS_3D Handle(ShapeAnalysis_Surface)& surface, const TopoDS_Face& F, SMESH_MesherHelper& helper); - bool smoothComplexEdge( _SolidData& data, + bool smoothComplexEdge( _SolidData& data, Handle(ShapeAnalysis_Surface)& surface, const TopoDS_Face& F, SMESH_MesherHelper& helper); @@ -1376,8 +1376,8 @@ std::istream & StdMeshers_ViscousLayers::LoadFrom(std::istream & load) } return load; } // -------------------------------------------------------------------------------- -bool StdMeshers_ViscousLayers::SetParametersByMesh(const SMESH_Mesh* theMesh, - const TopoDS_Shape& theShape) +bool StdMeshers_ViscousLayers::SetParametersByMesh(const SMESH_Mesh* /*theMesh*/, + const TopoDS_Shape& /*theShape*/) { // TODO return false; @@ -1771,7 +1771,7 @@ namespace VISCOUS_3D PyDump(SMESH_Mesh& m) { int tag = 3 + m.GetId(); const char* fname = "/tmp/viscous.py"; - cout << "execfile('"<GetSubMesh( allSolids(i) ); if ( sm->GetSubMeshDS() && sm->GetSubMeshDS()->NbElements() > 0 ) continue; // solid is already meshed + // TODO: check if algo is hidden SMESH_Algo* algo = sm->GetAlgo(); if ( !algo ) continue; - // TODO: check if algo is hidden + // check if all FACEs are meshed, which can be false if Compute() a sub-shape + if ( checkFaceMesh ) + { + bool facesMeshed = true; + SMESH_subMeshIteratorPtr smIt = sm->getDependsOnIterator(false,true); + while ( smIt->more() && facesMeshed ) + { + SMESH_subMesh * faceSM = smIt->next(); + if ( faceSM->GetSubShape().ShapeType() != TopAbs_FACE ) + break; + facesMeshed = faceSM->IsMeshComputed(); + } + if ( !facesMeshed ) + continue; + } + // find StdMeshers_ViscousLayers hyp assigned to the i-th solid const list & allHyps = algo->GetUsedHypothesis(*_mesh, allSolids(i), /*ignoreAuxiliary=*/false); _SolidData* soData = 0; @@ -3304,12 +3319,22 @@ bool _ViscousBuilder::findShapesToSmooth( _SolidData& data ) if ( isC1 ) { double maxEdgeLen = 3 * Min( eov._edges[0]->_maxLen, eov._hyp.GetTotalThickness() ); - double eLen1 = SMESH_Algo::EdgeLength( TopoDS::Edge( dirOfEdges[i].first->_shape )); - double eLen2 = SMESH_Algo::EdgeLength( TopoDS::Edge( dirOfEdges[j].first->_shape )); - if ( eLen1 < maxEdgeLen ) eov._eosC1.push_back( dirOfEdges[i].first ); - if ( eLen2 < maxEdgeLen ) eov._eosC1.push_back( dirOfEdges[j].first ); - dirOfEdges[i].first = 0; - dirOfEdges[j].first = 0; + for ( int isJ = 0; isJ < 2; ++isJ ) // loop on [i,j] + { + size_t k = isJ ? j : i; + const TopoDS_Edge& e = TopoDS::Edge( dirOfEdges[k].first->_shape ); + double eLen = SMESH_Algo::EdgeLength( e ); + if ( eLen < maxEdgeLen ) + { + TopoDS_Shape oppV = SMESH_MesherHelper::IthVertex( 0, e ); + if ( oppV.IsSame( V )) + oppV = SMESH_MesherHelper::IthVertex( 1, e ); + _EdgesOnShape* eovOpp = data.GetShapeEdges( oppV ); + if ( dirOfEdges[k].second * eovOpp->_edges[0]->_normal < 0 ) + eov._eosC1.push_back( dirOfEdges[k].first ); + } + dirOfEdges[k].first = 0; + } } } } // fill _eosC1 of VERTEXes @@ -3928,7 +3953,7 @@ gp_XYZ _ViscousBuilder::getFaceNormal(const SMDS_MeshNode* node, bool _ViscousBuilder::getFaceNormalAtSingularity( const gp_XY& uv, const TopoDS_Face& face, - SMESH_MesherHelper& helper, + SMESH_MesherHelper& /*helper*/, gp_Dir& normal ) { BRepAdaptor_Surface surface( face ); @@ -5287,7 +5312,9 @@ bool _ViscousBuilder::smoothAndCheck(_SolidData& data, } // loop on data._edgesOnShape if ( !is1stBlocked ) + { dumpFunctionEnd(); + } if ( closestFace && le ) { @@ -5500,7 +5527,7 @@ void _ViscousBuilder::makeOffsetSurface( _EdgesOnShape& eos, SMESH_MesherHelper& eos._offsetSurf = new ShapeAnalysis_Surface( surf ); } - catch ( Standard_Failure ) + catch ( Standard_Failure& ) { } } @@ -5602,8 +5629,9 @@ void _ViscousBuilder::putOnOffsetSurface( _EdgesOnShape& eos, << "_InfStep" << infStep << "_" << smooStep ); for ( ; i < eos._edges.size(); ++i ) { - if ( eos._edges[i]->Is( _LayerEdge::MARKED )) + if ( eos._edges[i]->Is( _LayerEdge::MARKED )) { dumpMove( eos._edges[i]->_nodes.back() ); + } } dumpFunctionEnd(); } @@ -6061,10 +6089,10 @@ bool _Smoother1D::smoothAnalyticEdge( _SolidData& data, */ //================================================================================ -bool _Smoother1D::smoothComplexEdge( _SolidData& data, +bool _Smoother1D::smoothComplexEdge( _SolidData& /*data*/, Handle(ShapeAnalysis_Surface)& surface, const TopoDS_Face& F, - SMESH_MesherHelper& helper) + SMESH_MesherHelper& /*helper*/) { if ( _offPoints.empty() ) return false; @@ -6452,7 +6480,7 @@ gp_XYZ _Smoother1D::getNormalNormal( const gp_XYZ & normal, void _Smoother1D::offPointsToPython() const { const char* fname = "/tmp/offPoints.py"; - cout << "execfile('"<& eosToSmooth, */ //================================================================================ -void _ViscousBuilder::limitMaxLenByCurvature( _SolidData& data, SMESH_MesherHelper& helper ) +void _ViscousBuilder::limitMaxLenByCurvature( _SolidData& data, SMESH_MesherHelper& /*helper*/ ) { // find intersection of neighbor _LayerEdge's to limit _maxLen // according to local curvature (IPAL52648) @@ -6773,9 +6801,9 @@ void _ViscousBuilder::limitMaxLenByCurvature( _SolidData& data, SMESH_MesherHelp void _ViscousBuilder::limitMaxLenByCurvature( _LayerEdge* e1, _LayerEdge* e2, - _EdgesOnShape& eos1, - _EdgesOnShape& eos2, - const bool isSmoothable ) + _EdgesOnShape& /*eos1*/, + _EdgesOnShape& /*eos2*/, + const bool /*isSmoothable*/ ) { if (( e1->_nodes[0]->GetPosition()->GetDim() != e2->_nodes[0]->GetPosition()->GetDim() ) && @@ -7094,7 +7122,7 @@ void _ViscousBuilder::findEdgesToUpdateNormalNearConvexFace( _ConvexFace & bool _ViscousBuilder::updateNormals( _SolidData& data, SMESH_MesherHelper& helper, int stepNb, - double stepSize) + double /*stepSize*/) { updateNormalsOfC1Vertices( data ); @@ -7259,7 +7287,7 @@ bool _ViscousBuilder::updateNormals( _SolidData& data, _LayerEdge* edge = e2neIt->first; _LayerEdge& newEdge = e2neIt->second; _EdgesOnShape* eos = data.GetShapeEdges( edge ); - if ( edge->Is( _LayerEdge::BLOCKED && newEdge._maxLen > edge->_len )) + if ( edge->Is( _LayerEdge::BLOCKED ) && newEdge._maxLen > edge->_len ) continue; // Check if a new _normal is OK: @@ -7434,7 +7462,7 @@ bool _ViscousBuilder::isNewNormalOk( _SolidData& data, //================================================================================ bool _ViscousBuilder::updateNormalsOfSmoothed( _SolidData& data, - SMESH_MesherHelper& helper, + SMESH_MesherHelper& /*helper*/, const int nbSteps, const double stepSize ) { @@ -8892,7 +8920,7 @@ int _LayerEdge::Smooth(const int step, const bool isConcaveFace, bool findBest ) //================================================================================ void _LayerEdge::ChooseSmooFunction( const set< TGeomID >& concaveVertices, - const TNode2Edge& n2eMap) + const TNode2Edge& /*n2eMap*/) { if ( _smooFunction ) return; @@ -9085,7 +9113,7 @@ gp_XYZ _LayerEdge::smoothAngular() else norm += cross; } - catch (Standard_Failure) { // if |cross| == 0. + catch (Standard_Failure&) { // if |cross| == 0. } } gp_XYZ vec = newPos - pN; @@ -10462,6 +10490,8 @@ namespace VISCOUS_3D PeriodicFaces( ShrinkFace* sf1, ShrinkFace* sf2 ): _shriFace{ sf1, sf2 } {} bool IncludeShrunk( const TopoDS_Face& face, const TopTools_MapOfShape& shrunkFaces ) const; bool MoveNodes( const TopoDS_Face& tgtFace ); + void Clear() { _nnMap.clear(); } + bool IsEmpty() const { return _nnMap.empty(); } }; //-------------------------------------------------------------------------------- @@ -10722,7 +10752,7 @@ namespace VISCOUS_3D { points.reserve( _boundarySize ); size_t nb = _boundary.rbegin()->_nodes.size(); - int lastID = _boundary.rbegin()->Node( nb - 1 )->GetID(); + smIdType lastID = _boundary.rbegin()->Node( nb - 1 )->GetID(); std::list< BndPart >::const_iterator part = _boundary.begin(); for ( ; part != _boundary.end(); ++part ) { @@ -10756,6 +10786,13 @@ namespace VISCOUS_3D return & _periodicFaces[ i ]; return 0; } + void ClearPeriodic( const TopoDS_Face& face ) + { + for ( size_t i = 0; i < _periodicFaces.size(); ++i ) + if ( _periodicFaces[ i ]._shriFace[0]->IsSame( face ) || + _periodicFaces[ i ]._shriFace[1]->IsSame( face )) + _periodicFaces[ i ].Clear(); + } }; //================================================================================ @@ -10765,6 +10802,7 @@ namespace VISCOUS_3D bool PeriodicFaces::IncludeShrunk( const TopoDS_Face& face, const TopTools_MapOfShape& shrunkFaces ) const { + if ( IsEmpty() ) return false; return (( _shriFace[0]->IsSame( face ) && _shriFace[1]->IsShrunk( shrunkFaces )) || ( _shriFace[1]->IsSame( face ) && _shriFace[0]->IsShrunk( shrunkFaces ))); } @@ -10785,7 +10823,8 @@ namespace VISCOUS_3D if ( iSrc != 0 ) { trsfInverse = _trsf; - trsfInverse.Invert(); + if ( !trsfInverse.Invert()) + return false; trsf = &trsfInverse; } SMESHDS_Mesh* meshDS = dataSrc->GetHelper().GetMeshDS(); @@ -10823,10 +10862,10 @@ namespace VISCOUS_3D } } bool done = ( n2n == _nnMap.end() ); - // cout << "MMMMMMMOOOOOOOOOOVVVVVVVVVVVEEEEEEEE " - // << _shriFace[iSrc]->_subMesh->GetId() << " -> " - // << _shriFace[iTgt]->_subMesh->GetId() << " -- " - // << ( done ? "DONE" : "FAIL") << endl; + debugMsg( "PeriodicFaces::MoveNodes " + << _shriFace[iSrc]->_subMesh->GetId() << " -> " + << _shriFace[iTgt]->_subMesh->GetId() << " -- " + << ( done ? "DONE" : "FAIL")); return done; } @@ -11286,6 +11325,8 @@ bool _ViscousBuilder::shrink(_SolidData& theData) getMeshDS()->RemoveFreeNode( n, smDS, /*fromGroups=*/false ); } } + _periodicity->ClearPeriodic( F ); + // restore position and UV of target nodes gp_Pnt p; for ( size_t iS = 0; iS < subEOS.size(); ++iS ) @@ -11474,7 +11515,7 @@ bool _ViscousBuilder::shrink(_SolidData& theData) bool _ViscousBuilder::prepareEdgeToShrink( _LayerEdge& edge, _EdgesOnShape& eos, SMESH_MesherHelper& helper, - const SMESHDS_SubMesh* faceSubMesh) + const SMESHDS_SubMesh* /*faceSubMesh*/) { const SMDS_MeshNode* srcNode = edge._nodes[0]; const SMDS_MeshNode* tgtNode = edge._nodes.back(); @@ -11528,6 +11569,13 @@ bool _ViscousBuilder::prepareEdgeToShrink( _LayerEdge& edge, if ( !n2 ) return error(SMESH_Comment("Wrongly meshed EDGE ") << getMeshDS()->ShapeToIndex( E )); + if ( n2 == tgtNode ) // for 3D_mesh_GHS3D_01/B1 + { + // shrunk by other SOLID + edge.Set( _LayerEdge::SHRUNK ); // ??? + return true; + } + double uSrc = helper.GetNodeU( E, srcNode, n2 ); double uTgt = helper.GetNodeU( E, tgtNode, srcNode ); double u2 = helper.GetNodeU( E, n2, srcNode ); @@ -11756,7 +11804,7 @@ void _ViscousBuilder::fixBadFaces(const TopoDS_Face& F, */ //================================================================================ -bool _LayerEdge::SetNewLength2d( Handle(Geom_Surface)& surface, +bool _LayerEdge::SetNewLength2d( Handle(Geom_Surface)& /*surface*/, const TopoDS_Face& F, _EdgesOnShape& eos, SMESH_MesherHelper& helper ) @@ -12066,7 +12114,7 @@ void _Shrinker1D::AddEdge( const _LayerEdge* e, GeomAdaptor_Curve aCurve(C, f,l); const double totLen = GCPnts_AbscissaPoint::Length(aCurve, f, l); - int nbExpectNodes = eSubMesh->NbNodes(); + smIdType nbExpectNodes = eSubMesh->NbNodes(); _initU .reserve( nbExpectNodes ); _normPar.reserve( nbExpectNodes ); _nodes .reserve( nbExpectNodes );