23427: [CEA 2073] No hypothesis "Viscous Layers" with Netgen 1D-2D-3D

Add GetElementsByNodes() that return elements including all given nodes.
This commit is contained in:
eap 2017-04-12 16:55:16 +03:00
parent c150e1e4c4
commit 69aa7507f2
6 changed files with 89 additions and 3 deletions

View File

@ -19,7 +19,7 @@ and hypotheses.
Mesh generation on the geometry is performed in the bottom-up
flow: nodes on vertices are created first, then edges are divided into
segments using nodes on vertices; the node of segments are then
segments using nodes on vertices; the nodes of segments are then
used to mesh faces; then the nodes of faces are used to mesh
solids. This automatically assures the conformity of the mesh.

View File

@ -975,6 +975,11 @@ module SMESH
*/
long FindElementByNodes(in long_array nodes);
/*!
* Return elements including all given nodes.
*/
long_array GetElementsByNodes(in long_array nodes, in ElementType elem_type);
/*!
* Returns true if given element is polygon
*/

View File

@ -2458,6 +2458,49 @@ const SMDS_MeshElement* SMDS_Mesh::FindElement (const vector<const SMDS_MeshNode
return NULL;
}
//================================================================================
/*!
* \brief Return elements including all given nodes
* \param [in] nodes - nodes to find elements around
* \param [out] foundElems - the found elements
* \param [in] type - type of elements to find
* \return int - a number of found elements
*/
//================================================================================
int SMDS_Mesh::GetElementsByNodes(const std::vector<const SMDS_MeshNode *>& nodes,
std::vector<const SMDS_MeshElement *>& foundElems,
const SMDSAbs_ElementType type)
{
// chose a node with minimal number of inverse elements
const SMDS_MeshNode* n0 = nodes[0];
int minNbInverse = n0 ? n0->NbInverseElements( type ) : 1000;
for ( size_t i = 1; i < nodes.size(); ++i )
if ( nodes[i] && nodes[i]->NbInverseElements( type ) < minNbInverse )
{
n0 = nodes[i];
minNbInverse = n0->NbInverseElements( type );
}
foundElems.clear();
if ( n0 )
{
foundElems.reserve( minNbInverse );
SMDS_ElemIteratorPtr eIt = n0->GetInverseElementIterator( type );
while ( eIt->more() )
{
const SMDS_MeshElement* e = eIt->next();
bool includeAll = true;
for ( size_t i = 0; i < nodes.size() && includeAll; ++i )
if ( nodes[i] != n0 && e->GetNodeIndex( nodes[i] ) < 0 )
includeAll = false;
if ( includeAll )
foundElems.push_back( e );
}
}
return foundElems.size();
}
//=======================================================================
//function : DumpNodes
//purpose :

View File

@ -689,6 +689,9 @@ public:
static const SMDS_MeshElement* FindElement(const std::vector<const SMDS_MeshNode *>& nodes,
const SMDSAbs_ElementType type=SMDSAbs_All,
const bool noMedium=true);
static int GetElementsByNodes(const std::vector<const SMDS_MeshNode *>& nodes,
std::vector<const SMDS_MeshElement *>& foundElems,
const SMDSAbs_ElementType type=SMDSAbs_All);
/*!
* \brief Raise an exception if free memory (ram+swap) too low

View File

@ -4771,6 +4771,35 @@ CORBA::Long SMESH_Mesh_i::FindElementByNodes(const SMESH::long_array& nodes)
return elemID;
}
//================================================================================
/*!
* \brief Return elements including all given nodes.
*/
//================================================================================
SMESH::long_array* SMESH_Mesh_i::GetElementsByNodes(const SMESH::long_array& nodes,
SMESH::ElementType elemType)
{
if ( _preMeshInfo )
_preMeshInfo->FullLoadFromFile();
SMESH::long_array_var result = new SMESH::long_array();
if ( SMESHDS_Mesh* mesh = _impl->GetMeshDS() )
{
vector< const SMDS_MeshNode * > nn( nodes.length() );
for ( CORBA::ULong i = 0; i < nodes.length(); ++i )
nn[i] = mesh->FindNode( nodes[i] );
std::vector<const SMDS_MeshElement *> elems;
mesh->GetElementsByNodes( nn, elems, (SMDSAbs_ElementType) elemType );
result->length( elems.size() );
for ( size_t i = 0; i < elems.size(); ++i )
result[i] = elems[i]->GetID();
}
return result._retn();
}
//=============================================================================
/*!
* Returns true if given element is polygon

View File

@ -537,7 +537,7 @@ public:
* in one of quadratic elements
*/
CORBA::Boolean IsMediumNodeOfAnyElem(CORBA::Long idn,
SMESH::ElementType theElemType);
SMESH::ElementType elemType);
/*!
* Returns number of edges for given element
@ -563,6 +563,12 @@ public:
*/
CORBA::Long FindElementByNodes(const SMESH::long_array& nodes);
/*!
* Return elements including all given nodes.
*/
SMESH::long_array* GetElementsByNodes(const SMESH::long_array& nodes,
SMESH::ElementType elemType);
/*!
* Returns true if given element is polygon
*/