0021543: EDF 1978 SMESH: Viscous layer for 2D meshes

Extend the class to store 1D proxy elements
This commit is contained in:
eap 2012-10-15 13:03:16 +00:00
parent 4605267548
commit 3750df108a
2 changed files with 105 additions and 45 deletions

View File

@ -178,6 +178,21 @@ const SMDS_MeshNode* SMESH_ProxyMesh::GetProxyNode( const SMDS_MeshNode* node )
return proxy;
}
//================================================================================
/*!
* \brief Returns number of proxy sub-meshes
*/
//================================================================================
int SMESH_ProxyMesh::NbProxySubMeshes() const
{
int nb = 0;
for ( size_t i = 0; i < _subMeshes.size(); ++i )
nb += bool( _subMeshes[i] );
return nb;
}
namespace
{
//================================================================================
@ -329,7 +344,7 @@ SMESH_ProxyMesh::SubMesh* SMESH_ProxyMesh::getProxySubMesh(int index)
if ( int(_subMeshes.size()) <= index )
_subMeshes.resize( index+1, 0 );
if ( !_subMeshes[index] )
_subMeshes[index] = new SubMesh( index );
_subMeshes[index] = newSubmesh( index );
return _subMeshes[index];
}
@ -408,24 +423,24 @@ void SMESH_ProxyMesh::takeTmpElemsInMesh( SMESH_ProxyMesh* proxyMesh )
//================================================================================
/*!
* \brief Removes tmp faces from the _mesh
* \brief Removes tmp elements from the _mesh
*/
//================================================================================
void SMESH_ProxyMesh::removeTmpElement( const SMDS_MeshElement* face )
void SMESH_ProxyMesh::removeTmpElement( const SMDS_MeshElement* elem )
{
if ( face && face->GetID() > 0 )
if ( elem && elem->GetID() > 0 )
{
set< const SMDS_MeshElement* >::iterator i = _elemsInMesh.find( face );
set< const SMDS_MeshElement* >::iterator i = _elemsInMesh.find( elem );
if ( i != _elemsInMesh.end() )
{
GetMeshDS()->RemoveFreeElement( face, 0 );
GetMeshDS()->RemoveFreeElement( elem, 0 );
_elemsInMesh.erase( i );
}
}
else
{
delete face;
delete elem;
}
}
@ -435,9 +450,9 @@ void SMESH_ProxyMesh::removeTmpElement( const SMDS_MeshElement* face )
*/
//================================================================================
void SMESH_ProxyMesh::storeTmpElement( const SMDS_MeshElement* face )
void SMESH_ProxyMesh::storeTmpElement( const SMDS_MeshElement* elem )
{
_elemsInMesh.insert( face );
_elemsInMesh.insert( elem );
}
//================================================================================
@ -499,18 +514,20 @@ void SMESH_ProxyMesh::SubMesh::Clear()
//================================================================================
/*!
* \brief Return number of elements in a proxy submesh
* \brief Return number of elements in a proxy sub-mesh. The method is meaningful
* for a sub-mesh containing tmp faces.
*/
//================================================================================
int SMESH_ProxyMesh::SubMesh::NbElements() const
{
return _elements.size();
return _uvPtStructVec.empty() ? _elements.size() : _uvPtStructVec.size() - 1;
}
//================================================================================
/*!
* \brief Return elements of a proxy submesh
* \brief Return elements of a proxy sub-mesh. The method is meaningful
* for a sub-mesh containing tmp faces.
*/
//================================================================================
@ -520,6 +537,39 @@ SMDS_ElemIteratorPtr SMESH_ProxyMesh::SubMesh::GetElements() const
( new SMDS_ElementVectorIterator( _elements.begin(), _elements.end() ));
}
//================================================================================
/*!
* \brief Return number of nodes in a proxy sub-mesh. The method is meaningful
* for a sub-mesh containing nodes of 2D viscous layer.
*/
//================================================================================
int SMESH_ProxyMesh::SubMesh::NbNodes() const
{
return _uvPtStructVec.size();
}
//================================================================================
/*!
* \brief Return nodes of a proxy sub-mesh. The method is meaningful
* for a sub-mesh containing nodes of 2D viscous layer.
*/
//================================================================================
SMDS_NodeIteratorPtr SMESH_ProxyMesh::SubMesh::GetNodes() const
{
if ( !_uvPtStructVec.empty() )
return SMDS_NodeIteratorPtr ( new SMDS_SetIterator
< SMDS_pNode,
UVPtStructVec::const_iterator,
UVPtStruct::NodeAccessor >
( _uvPtStructVec.begin(), _uvPtStructVec.end() ));
return SMDS_NodeIteratorPtr
( new SMDS_SetIterator< SMDS_pNode, std::vector< SMDS_pElement >::const_iterator>
( _elements.begin(), _elements.end() ));
}
//================================================================================
/*!
* \brief Store an element

View File

@ -28,6 +28,7 @@
#include "SMDS_MeshElement.hxx"
#include "SMESHDS_SubMesh.hxx"
#include "SMESH_TypeDefs.hxx"
#include <TopoDS_Shape.hxx>
@ -40,7 +41,8 @@ class SMESHDS_Mesh;
class SMESH_Mesh;
/*!
* \brief Container of mesh faces substituting other faces in the input mesh of 3D algorithm
* \brief Container of xD mesh elements substituting other ones in the
* input mesh of an (x+1)D algorithm
*/
class SMESH_EXPORT SMESH_ProxyMesh
{
@ -60,26 +62,29 @@ public:
const TN2NMap* GetNodeNodeMap() const { return _n2n; }
const SMDS_MeshNode* GetProxyNode( const SMDS_MeshNode* n ) const;
const UVPtStructVec& GetUVPtStructVec() const { return _uvPtStructVec; }
virtual void AddElement(const SMDS_MeshElement * e);
virtual int NbElements() const;
virtual int NbNodes() const;
virtual SMDS_ElemIteratorPtr GetElements() const;
virtual SMDS_NodeIteratorPtr GetNodes() const;
virtual void Clear();
virtual bool Contains(const SMDS_MeshElement * ME) const;
template< class ITERATOR >
void ChangeElements( ITERATOR it, ITERATOR end )
{
// change SubMesh contents without deleting tmp faces
// change SubMesh contents without deleting tmp elements
// for which the caller is responsible
_elements.clear();
while ( it != end ) _elements.push_back( *it++ );
_elements.assign( it, end );
}
SubMesh(int index=0):SMESHDS_SubMesh(0,index),_n2n(0) {}
~SubMesh() { Clear(); }
virtual ~SubMesh() { Clear(); }
private:
protected:
std::vector<const SMDS_MeshElement *> _elements;
TN2NMap* _n2n;
UVPtStructVec _uvPtStructVec; // for SubMesh of EDGE
friend class SMESH_ProxyMesh;
};
//--------------------------------------------------------------------------------
@ -90,16 +95,19 @@ public:
SMESH_ProxyMesh(const SMESH_Mesh& mesh) { _mesh = &mesh; }
virtual ~SMESH_ProxyMesh();
// Returns the submesh of a face; it can be a proxy sub-mesh
const SMESHDS_SubMesh* GetSubMesh(const TopoDS_Shape& face) const;
// Returns the submesh of a shape; it can be a proxy sub-mesh
const SMESHDS_SubMesh* GetSubMesh(const TopoDS_Shape& shape) const;
// Returns the proxy sub-mesh of a face; it can be NULL
const SubMesh* GetProxySubMesh(const TopoDS_Shape& face) const;
// Returns the proxy sub-mesh of a shape; it can be NULL
const SubMesh* GetProxySubMesh(const TopoDS_Shape& shape) const;
// Returns the proxy node of a node; the input node is returned if no proxy exists
const SMDS_MeshNode* GetProxyNode( const SMDS_MeshNode* node ) const;
// Returns iterator on all faces of the mesh taking into account substitutions
// Returns number of proxy sub-meshes
int NbProxySubMeshes() const;
// Returns iterator on all faces of the mesh taking into account substitutions.
// To be used in case of mesh without shape
SMDS_ElemIteratorPtr GetFaces() const;
@ -113,7 +121,7 @@ public:
const SMESH_Mesh* GetMesh() const { return _mesh; }
SMESH_Mesh* GetMesh() const { return const_cast<SMESH_Mesh*>( _mesh ); }
SMESHDS_Mesh* GetMeshDS() const;
@ -125,6 +133,8 @@ public:
int shapeIndex(const TopoDS_Shape& shape) const;
virtual SubMesh* newSubmesh(int index=0) const { return new SubMesh(index); }
// returns a proxy sub-mesh; zero index is for the case of mesh w/o shape
SubMesh* findProxySubMesh(int shapeIndex=0) const;
@ -140,11 +150,11 @@ public:
// move tmp elements residing the _mesh from other proxy mesh to this
void takeTmpElemsInMesh( SMESH_ProxyMesh* proxyMesh );
// removes tmp faces from the _mesh
void removeTmpElement( const SMDS_MeshElement* face );
// removes tmp element from the _mesh
void removeTmpElement( const SMDS_MeshElement* elem );
// stores tmp element residing the _mesh
void storeTmpElement( const SMDS_MeshElement* face );
void storeTmpElement( const SMDS_MeshElement* elem );
// store node-node correspondence
void setNode2Node(const SMDS_MeshNode* srcNode,