mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-02-04 11:40:33 +05:00
0023118: EDF 11115 SMESH: Hexahedric mesh produces degenerate elements in quadratic conversion.
Improve Hexahedron (i,j,k) to work on composite block with non-continues sub-side FACEs
This commit is contained in:
parent
a8a351ef11
commit
b52b396dce
@ -3397,13 +3397,13 @@ namespace { // Structures used by FixQuadraticElements()
|
|||||||
}
|
}
|
||||||
void SetContinuesFaces() const;
|
void SetContinuesFaces() const;
|
||||||
const QFace* GetContinuesFace( const QFace* face ) const;
|
const QFace* GetContinuesFace( const QFace* face ) const;
|
||||||
bool OnBoundary() const;
|
bool OnBoundary() const;
|
||||||
gp_XYZ MiddlePnt() const { return ( XYZ( node1() ) + XYZ( node2() )) / 2.; }
|
gp_XYZ MiddlePnt() const { return ( XYZ( node1() ) + XYZ( node2() )) / 2.; }
|
||||||
gp_XYZ MediumPnt() const { return XYZ( _mediumNode ); }
|
gp_XYZ MediumPnt() const { return XYZ( _mediumNode ); }
|
||||||
|
|
||||||
SMDS_TypeOfPosition MediumPos() const
|
SMDS_TypeOfPosition MediumPos() const
|
||||||
{ return _mediumNode->GetPosition()->GetTypeOfPosition(); }
|
{ return _mediumNode->GetPosition()->GetTypeOfPosition(); }
|
||||||
SMDS_TypeOfPosition EndPos(bool isSecond) const
|
SMDS_TypeOfPosition EndPos(bool isSecond) const
|
||||||
{ return (isSecond ? node2() : node1())->GetPosition()->GetTypeOfPosition(); }
|
{ return (isSecond ? node2() : node1())->GetPosition()->GetTypeOfPosition(); }
|
||||||
const SMDS_MeshNode* EndPosNode(SMDS_TypeOfPosition pos) const
|
const SMDS_MeshNode* EndPosNode(SMDS_TypeOfPosition pos) const
|
||||||
{ return EndPos(0) == pos ? node1() : EndPos(1) == pos ? node2() : 0; }
|
{ return EndPos(0) == pos ? node1() : EndPos(1) == pos ? node2() : 0; }
|
||||||
@ -4952,7 +4952,7 @@ void SMESH_MesherHelper::FixQuadraticElements(SMESH_ComputeErrorPtr& compError,
|
|||||||
face = TopoDS::Face( f );
|
face = TopoDS::Face( f );
|
||||||
faceHlp.SetSubShape( face );
|
faceHlp.SetSubShape( face );
|
||||||
Handle(Geom_Surface) surf = BRep_Tool::Surface(face,loc);
|
Handle(Geom_Surface) surf = BRep_Tool::Surface(face,loc);
|
||||||
bool isStraight[2];
|
//bool isStraight[2]; // commented for issue 0023118
|
||||||
for ( int is1 = 0; is1 < 2; ++is1 ) // move0 or move1
|
for ( int is1 = 0; is1 < 2; ++is1 ) // move0 or move1
|
||||||
{
|
{
|
||||||
TChainLink& link = is1 ? chain.back() : chain.front();
|
TChainLink& link = is1 ? chain.back() : chain.front();
|
||||||
@ -4965,13 +4965,13 @@ void SMESH_MesherHelper::FixQuadraticElements(SMESH_ComputeErrorPtr& compError,
|
|||||||
( is1 ? move1 : move0 ).SetCoord( uvMove.X(), uvMove.Y(), 0 );
|
( is1 ? move1 : move0 ).SetCoord( uvMove.X(), uvMove.Y(), 0 );
|
||||||
if ( !is1 ) // correct nodeOnFace for move1 (issue 0020919)
|
if ( !is1 ) // correct nodeOnFace for move1 (issue 0020919)
|
||||||
nodeOnFace = (*(++chain.rbegin()))->_mediumNode;
|
nodeOnFace = (*(++chain.rbegin()))->_mediumNode;
|
||||||
isStraight[is1] = isStraightLink( (uv2-uv1).SquareModulus(),
|
// isStraight[is1] = isStraightLink( (uv2-uv1).SquareModulus(),
|
||||||
10 * uvMove.SquareModulus());
|
// 10 * uvMove.SquareModulus());
|
||||||
}
|
|
||||||
if ( isStraight[0] && isStraight[1] ) {
|
|
||||||
MSG("2D straight - ignore");
|
|
||||||
continue; // straight - no need to move nodes of internal links
|
|
||||||
}
|
}
|
||||||
|
// if ( isStraight[0] && isStraight[1] ) {
|
||||||
|
// MSG("2D straight - ignore");
|
||||||
|
// continue; // straight - no need to move nodes of internal links
|
||||||
|
// }
|
||||||
|
|
||||||
// check if a chain is already fixed
|
// check if a chain is already fixed
|
||||||
gp_XY uvm = faceHlp.GetNodeUV( face, linkOnFace->_mediumNode, 0, &checkUV );
|
gp_XY uvm = faceHlp.GetNodeUV( face, linkOnFace->_mediumNode, 0, &checkUV );
|
||||||
|
@ -145,10 +145,10 @@ public:
|
|||||||
public: //** Methods to find and orient faces of 6 sides of the box **//
|
public: //** Methods to find and orient faces of 6 sides of the box **//
|
||||||
|
|
||||||
//!< initialization
|
//!< initialization
|
||||||
bool Init(const TopoDS_Face& f);
|
bool Init(const TopoDS_Face& f, SMESH_Mesh& mesh );
|
||||||
|
|
||||||
//!< try to unite self with other face
|
//!< try to unite self with other face
|
||||||
bool AddContinuousFace( const _QuadFaceGrid& f );
|
bool AddContinuousFace( const _QuadFaceGrid& f, const TopTools_MapOfShape& cornerVertices );
|
||||||
|
|
||||||
//!< Try to set the side as bottom hirizontal side
|
//!< Try to set the side as bottom hirizontal side
|
||||||
bool SetBottomSide(const _FaceSide& side, int* sideIndex=0);
|
bool SetBottomSide(const _FaceSide& side, int* sideIndex=0);
|
||||||
@ -219,6 +219,10 @@ private:
|
|||||||
bool error(const SMESH_ComputeErrorPtr& err)
|
bool error(const SMESH_ComputeErrorPtr& err)
|
||||||
{ myError = err; return ( !myError || myError->IsOK() ); }
|
{ myError = err; return ( !myError || myError->IsOK() ); }
|
||||||
|
|
||||||
|
bool isContinuousMesh(TopoDS_Edge E1, TopoDS_Edge E2, SMESH_Mesh& mesh) const;
|
||||||
|
|
||||||
|
bool needContinuationAtSide( int iSide, const TopTools_MapOfShape& cornerVertices ) const;
|
||||||
|
|
||||||
bool loadCompositeGrid(SMESH_Mesh& mesh);
|
bool loadCompositeGrid(SMESH_Mesh& mesh);
|
||||||
|
|
||||||
bool fillGrid(SMESH_Mesh& theMesh,
|
bool fillGrid(SMESH_Mesh& theMesh,
|
||||||
@ -276,6 +280,50 @@ bool StdMeshers_CompositeHexa_3D::CheckHypothesis(SMESH_Mesh& aMesh,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
//================================================================================
|
||||||
|
/*!
|
||||||
|
* \brief Finds VERTEXes located and block corners
|
||||||
|
*/
|
||||||
|
//================================================================================
|
||||||
|
|
||||||
|
void getBlockCorners( SMESH_Mesh& mesh,
|
||||||
|
const TopoDS_Shape& shape,
|
||||||
|
TopTools_MapOfShape& cornerVV)
|
||||||
|
{
|
||||||
|
set<int> faceIDs; // ids of FACEs in the shape
|
||||||
|
TopExp_Explorer exp;
|
||||||
|
for ( exp.Init( shape, TopAbs_FACE ); exp.More(); exp.Next() )
|
||||||
|
faceIDs.insert( mesh.GetMeshDS()->ShapeToIndex( exp.Current() ));
|
||||||
|
|
||||||
|
TopTools_MapOfShape checkedVV;
|
||||||
|
for ( exp.Init( shape, TopAbs_VERTEX ); exp.More(); exp.Next() )
|
||||||
|
{
|
||||||
|
TopoDS_Vertex V = TopoDS::Vertex( exp.Current() );
|
||||||
|
if ( !checkedVV.Add( V )) continue;
|
||||||
|
|
||||||
|
const SMDS_MeshNode* n = SMESH_Algo::VertexNode( V, mesh.GetMeshDS() );
|
||||||
|
if ( !n ) continue;
|
||||||
|
|
||||||
|
int nbQuads = 0;
|
||||||
|
SMDS_ElemIteratorPtr fIt = n->GetInverseElementIterator(SMDSAbs_Face);
|
||||||
|
while ( fIt->more() )
|
||||||
|
{
|
||||||
|
const SMDS_MeshElement* f = fIt->next();
|
||||||
|
if ( !faceIDs.count( f->getshapeId() )) continue;
|
||||||
|
|
||||||
|
if ( f->NbCornerNodes() == 4 )
|
||||||
|
++nbQuads;
|
||||||
|
else
|
||||||
|
nbQuads = 100;
|
||||||
|
}
|
||||||
|
if ( nbQuads == 3 )
|
||||||
|
cornerVV.Add( V );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//================================================================================
|
//================================================================================
|
||||||
/*!
|
/*!
|
||||||
* \brief Tries to find 6 sides of a box
|
* \brief Tries to find 6 sides of a box
|
||||||
@ -284,6 +332,7 @@ bool StdMeshers_CompositeHexa_3D::CheckHypothesis(SMESH_Mesh& aMesh,
|
|||||||
|
|
||||||
bool StdMeshers_CompositeHexa_3D::findBoxFaces( const TopoDS_Shape& shape,
|
bool StdMeshers_CompositeHexa_3D::findBoxFaces( const TopoDS_Shape& shape,
|
||||||
list< _QuadFaceGrid >& boxFaces,
|
list< _QuadFaceGrid >& boxFaces,
|
||||||
|
SMESH_Mesh& mesh,
|
||||||
_QuadFaceGrid * & fBottom,
|
_QuadFaceGrid * & fBottom,
|
||||||
_QuadFaceGrid * & fTop,
|
_QuadFaceGrid * & fTop,
|
||||||
_QuadFaceGrid * & fFront,
|
_QuadFaceGrid * & fFront,
|
||||||
@ -291,13 +340,18 @@ bool StdMeshers_CompositeHexa_3D::findBoxFaces( const TopoDS_Shape& shape,
|
|||||||
_QuadFaceGrid * & fLeft,
|
_QuadFaceGrid * & fLeft,
|
||||||
_QuadFaceGrid * & fRight)
|
_QuadFaceGrid * & fRight)
|
||||||
{
|
{
|
||||||
|
TopTools_MapOfShape cornerVertices;
|
||||||
|
getBlockCorners( mesh, shape, cornerVertices );
|
||||||
|
if ( cornerVertices.Extent() != 8 )
|
||||||
|
return false;
|
||||||
|
|
||||||
list< _QuadFaceGrid >::iterator boxFace;
|
list< _QuadFaceGrid >::iterator boxFace;
|
||||||
TopExp_Explorer exp;
|
TopExp_Explorer exp;
|
||||||
int nbFaces = 0;
|
int nbFaces = 0;
|
||||||
for ( exp.Init( shape, TopAbs_FACE); exp.More(); exp.Next(), ++nbFaces )
|
for ( exp.Init( shape, TopAbs_FACE ); exp.More(); exp.Next(), ++nbFaces )
|
||||||
{
|
{
|
||||||
_QuadFaceGrid f;
|
_QuadFaceGrid f;
|
||||||
if ( !f.Init( TopoDS::Face( exp.Current() )))
|
if ( !f.Init( TopoDS::Face( exp.Current() ), mesh ))
|
||||||
return error (COMPERR_BAD_SHAPE);
|
return error (COMPERR_BAD_SHAPE);
|
||||||
|
|
||||||
_QuadFaceGrid* prevContinuous = 0;
|
_QuadFaceGrid* prevContinuous = 0;
|
||||||
@ -305,10 +359,10 @@ bool StdMeshers_CompositeHexa_3D::findBoxFaces( const TopoDS_Shape& shape,
|
|||||||
{
|
{
|
||||||
if ( prevContinuous )
|
if ( prevContinuous )
|
||||||
{
|
{
|
||||||
if ( prevContinuous->AddContinuousFace( *boxFace ))
|
if ( prevContinuous->AddContinuousFace( *boxFace, cornerVertices ))
|
||||||
boxFace = --boxFaces.erase( boxFace );
|
boxFace = --boxFaces.erase( boxFace );
|
||||||
}
|
}
|
||||||
else if ( boxFace->AddContinuousFace( f ))
|
else if ( boxFace->AddContinuousFace( f, cornerVertices ))
|
||||||
{
|
{
|
||||||
prevContinuous = & (*boxFace);
|
prevContinuous = & (*boxFace);
|
||||||
}
|
}
|
||||||
@ -326,7 +380,7 @@ bool StdMeshers_CompositeHexa_3D::findBoxFaces( const TopoDS_Shape& shape,
|
|||||||
boxFaces.resize( 6 );
|
boxFaces.resize( 6 );
|
||||||
boxFace = boxFaces.begin();
|
boxFace = boxFaces.begin();
|
||||||
for ( exp.Init( shape, TopAbs_FACE); exp.More(); exp.Next(), ++boxFace )
|
for ( exp.Init( shape, TopAbs_FACE); exp.More(); exp.Next(), ++boxFace )
|
||||||
boxFace->Init( TopoDS::Face( exp.Current() ) );
|
boxFace->Init( TopoDS::Face( exp.Current() ), mesh );
|
||||||
}
|
}
|
||||||
// ----------------------------------------
|
// ----------------------------------------
|
||||||
// Find out position of faces within a box
|
// Find out position of faces within a box
|
||||||
@ -396,7 +450,7 @@ bool StdMeshers_CompositeHexa_3D::Compute(SMESH_Mesh& theMesh,
|
|||||||
// -------------------------
|
// -------------------------
|
||||||
list< _QuadFaceGrid > boxFaceContainer;
|
list< _QuadFaceGrid > boxFaceContainer;
|
||||||
_QuadFaceGrid *fBottom, *fTop, *fFront, *fBack, *fLeft, *fRight;
|
_QuadFaceGrid *fBottom, *fTop, *fFront, *fBack, *fLeft, *fRight;
|
||||||
if ( ! findBoxFaces( theShape, boxFaceContainer,
|
if ( ! findBoxFaces( theShape, boxFaceContainer, theMesh,
|
||||||
fBottom, fTop, fFront, fBack, fLeft, fRight))
|
fBottom, fTop, fFront, fBack, fLeft, fRight))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -559,7 +613,7 @@ bool StdMeshers_CompositeHexa_3D::Evaluate(SMESH_Mesh& theMesh,
|
|||||||
// -------------------------
|
// -------------------------
|
||||||
list< _QuadFaceGrid > boxFaceContainer;
|
list< _QuadFaceGrid > boxFaceContainer;
|
||||||
_QuadFaceGrid *fBottom, *fTop, *fFront, *fBack, *fLeft, *fRight;
|
_QuadFaceGrid *fBottom, *fTop, *fFront, *fBack, *fLeft, *fRight;
|
||||||
if ( ! findBoxFaces( theShape, boxFaceContainer,
|
if ( ! findBoxFaces( theShape, boxFaceContainer, theMesh,
|
||||||
fBottom, fTop, fFront, fBack, fLeft, fRight))
|
fBottom, fTop, fFront, fBack, fLeft, fRight))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -645,7 +699,7 @@ _QuadFaceGrid::_QuadFaceGrid():
|
|||||||
*/
|
*/
|
||||||
//================================================================================
|
//================================================================================
|
||||||
|
|
||||||
bool _QuadFaceGrid::Init(const TopoDS_Face& f)
|
bool _QuadFaceGrid::Init(const TopoDS_Face& f, SMESH_Mesh& mesh)
|
||||||
{
|
{
|
||||||
myFace = f;
|
myFace = f;
|
||||||
mySides = _FaceSide();
|
mySides = _FaceSide();
|
||||||
@ -680,6 +734,12 @@ bool _QuadFaceGrid::Init(const TopoDS_Face& f)
|
|||||||
else if ( SMESH_Algo::IsContinuous( sideEdges.front(), edges.back() )) {
|
else if ( SMESH_Algo::IsContinuous( sideEdges.front(), edges.back() )) {
|
||||||
sideEdges.splice( sideEdges.begin(), edges, --edges.end());
|
sideEdges.splice( sideEdges.begin(), edges, --edges.end());
|
||||||
}
|
}
|
||||||
|
else if ( isContinuousMesh( sideEdges.back(), edges.front(), mesh )) {
|
||||||
|
sideEdges.splice( sideEdges.end(), edges, edges.begin());
|
||||||
|
}
|
||||||
|
else if ( isContinuousMesh( sideEdges.front(), edges.back(), mesh )) {
|
||||||
|
sideEdges.splice( sideEdges.begin(), edges, --edges.end());
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -706,7 +766,8 @@ bool _QuadFaceGrid::Init(const TopoDS_Face& f)
|
|||||||
*/
|
*/
|
||||||
//================================================================================
|
//================================================================================
|
||||||
|
|
||||||
bool _QuadFaceGrid::AddContinuousFace( const _QuadFaceGrid& other )
|
bool _QuadFaceGrid::AddContinuousFace( const _QuadFaceGrid& other,
|
||||||
|
const TopTools_MapOfShape& cornerVertices)
|
||||||
{
|
{
|
||||||
for ( int i = 0; i < 4; ++i )
|
for ( int i = 0; i < 4; ++i )
|
||||||
{
|
{
|
||||||
@ -729,7 +790,10 @@ bool _QuadFaceGrid::AddContinuousFace( const _QuadFaceGrid& other )
|
|||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if ( nbCollinear > 1 ) { // this face becomes composite if not yet is
|
if ( nbCollinear > 1 || // this face becomes composite if not yet is
|
||||||
|
needContinuationAtSide( iMyCommon, cornerVertices) ||
|
||||||
|
other.needContinuationAtSide( i, cornerVertices ))
|
||||||
|
{
|
||||||
DUMP_VERT("Cont 1", mySides.GetSide(iMyCommon)->FirstVertex());
|
DUMP_VERT("Cont 1", mySides.GetSide(iMyCommon)->FirstVertex());
|
||||||
DUMP_VERT("Cont 2", mySides.GetSide(iMyCommon)->LastVertex());
|
DUMP_VERT("Cont 2", mySides.GetSide(iMyCommon)->LastVertex());
|
||||||
DUMP_VERT("Cont 3", otherSide.FirstVertex());
|
DUMP_VERT("Cont 3", otherSide.FirstVertex());
|
||||||
@ -1060,6 +1124,76 @@ bool _QuadFaceGrid::locateChildren()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//================================================================================
|
||||||
|
/*!
|
||||||
|
* \brief Checks structure of a quadrangular mesh at the common VERTEX of two EDGEs.
|
||||||
|
* Returns true if there are two quadrangles near the VERTEX.
|
||||||
|
*/
|
||||||
|
//================================================================================
|
||||||
|
|
||||||
|
bool _QuadFaceGrid::isContinuousMesh(TopoDS_Edge E1, TopoDS_Edge E2, SMESH_Mesh& mesh) const
|
||||||
|
{
|
||||||
|
if (E1.Orientation() > TopAbs_REVERSED) // INTERNAL
|
||||||
|
E1.Orientation( TopAbs_FORWARD );
|
||||||
|
if (E2.Orientation() > TopAbs_REVERSED) // INTERNAL
|
||||||
|
E2.Orientation( TopAbs_FORWARD );
|
||||||
|
|
||||||
|
TopoDS_Vertex V;
|
||||||
|
if ( !TopExp::CommonVertex( E1, E2, V )) return false;
|
||||||
|
|
||||||
|
const SMDS_MeshNode* n = SMESH_Algo::VertexNode( V, mesh.GetMeshDS() );
|
||||||
|
if ( !n ) return false;
|
||||||
|
|
||||||
|
SMESHDS_SubMesh* sm = mesh.GetSubMesh( myFace )->GetSubMeshDS();
|
||||||
|
if ( !sm ) return false;
|
||||||
|
|
||||||
|
int nbQuads = 0;
|
||||||
|
SMDS_ElemIteratorPtr fIt = n->GetInverseElementIterator(SMDSAbs_Face);
|
||||||
|
while ( fIt->more() )
|
||||||
|
{
|
||||||
|
const SMDS_MeshElement* f = fIt->next();
|
||||||
|
if ( !sm->Contains( f )) continue;
|
||||||
|
|
||||||
|
if ( f->NbCornerNodes() == 4 )
|
||||||
|
++nbQuads;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return nbQuads == 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
//================================================================================
|
||||||
|
/*!
|
||||||
|
* \brief Checks if a continuation FACE is needed at a given side according to
|
||||||
|
* presence of corner VERTEXes
|
||||||
|
*/
|
||||||
|
//================================================================================
|
||||||
|
|
||||||
|
bool _QuadFaceGrid::needContinuationAtSide( int iSide,
|
||||||
|
const TopTools_MapOfShape& cornerVertices ) const
|
||||||
|
{
|
||||||
|
if ( cornerVertices.empty() )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// check presence of corners at iSide
|
||||||
|
int nbCorners = 0;
|
||||||
|
const _FaceSide* side = mySides.GetSide( iSide );
|
||||||
|
if ( !side ) return false;
|
||||||
|
int iV, nbV = side->NbVertices();
|
||||||
|
for ( iV = 0; iV < nbV && nbCorners == 0; ++iV )
|
||||||
|
nbCorners += cornerVertices.Contains( side->Vertex( iV ));
|
||||||
|
if ( nbCorners > 0 )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// check presence of corners at other sides
|
||||||
|
nbCorners = 0;
|
||||||
|
nbV = mySides.NbVertices();
|
||||||
|
for ( iV = 0; iV < nbV && nbCorners == 0; ++iV )
|
||||||
|
nbCorners += cornerVertices.Contains( mySides.Vertex( iV ));
|
||||||
|
|
||||||
|
return ( nbCorners > 0 ); // if nbCorners == 2 additional check is needed!!!
|
||||||
|
}
|
||||||
|
|
||||||
//================================================================================
|
//================================================================================
|
||||||
/*!
|
/*!
|
||||||
* \brief Fill myGrid with nodes of patches
|
* \brief Fill myGrid with nodes of patches
|
||||||
|
@ -59,6 +59,7 @@ private:
|
|||||||
|
|
||||||
bool findBoxFaces( const TopoDS_Shape& shape,
|
bool findBoxFaces( const TopoDS_Shape& shape,
|
||||||
list< _QuadFaceGrid >& boxFaceContainer,
|
list< _QuadFaceGrid >& boxFaceContainer,
|
||||||
|
SMESH_Mesh& mesh,
|
||||||
_QuadFaceGrid * & fBottom,
|
_QuadFaceGrid * & fBottom,
|
||||||
_QuadFaceGrid * & fTop,
|
_QuadFaceGrid * & fTop,
|
||||||
_QuadFaceGrid * & fFront,
|
_QuadFaceGrid * & fFront,
|
||||||
|
Loading…
Reference in New Issue
Block a user