Salome HOME
23427: [CEA 2073] No hypothesis "Viscous Layers" with Netgen 1D-2D-3D
authoreap <eap@opencascade.com>
Wed, 12 Apr 2017 13:55:16 +0000 (16:55 +0300)
committereap <eap@opencascade.com>
Wed, 12 Apr 2017 13:55:16 +0000 (16:55 +0300)
Add GetElementsByNodes() that return elements including all given nodes.

doc/salome/gui/SMESH/input/constructing_meshes.doc
idl/SMESH_Mesh.idl
src/SMDS/SMDS_Mesh.cxx
src/SMDS/SMDS_Mesh.hxx
src/SMESH_I/SMESH_Mesh_i.cxx
src/SMESH_I/SMESH_Mesh_i.hxx

index 6794b398bea21a50f333c7a54e881af35a9223a5..2481807fd0888fdda36ee1c0c880f28b4a8cb8c0 100644 (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
 
 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.
 
 used to mesh faces; then the nodes of faces are used to mesh
 solids. This automatically assures the conformity of the mesh.
 
index 805b21df68590e0e04a7c16b1de072b6bd6eba82..cef3831ee99245d92db46a343f57f552c267c7f8 100644 (file)
@@ -975,6 +975,11 @@ module SMESH
      */
     long FindElementByNodes(in long_array nodes);
 
      */
     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
      */
     /*!
      * Returns true if given element is polygon
      */
index 5d8294700d96607f3d3cd38eb93ad8405dd1e60a..7c8e6632747f0d84552e71e066e6690fd6d1b3e5 100644 (file)
@@ -2458,6 +2458,49 @@ const SMDS_MeshElement* SMDS_Mesh::FindElement (const vector<const SMDS_MeshNode
   return NULL;
 }
 
   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  :
 //=======================================================================
 //function : DumpNodes
 //purpose  :
index b1af99a1d1e6c2d0e8f5b8347130ccd2f4328f93..d1d0b1120a83f9c196119639d9fdaf5ca6ed7f9e 100644 (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 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
 
   /*!
    * \brief Raise an exception if free memory (ram+swap) too low
index a075dadce83d21437eebba69f9bbb11eeac2a505..268dfd829b3fc4fc058a6aa1a141a57ec528911e 100644 (file)
@@ -4771,6 +4771,35 @@ CORBA::Long SMESH_Mesh_i::FindElementByNodes(const SMESH::long_array& nodes)
   return elemID;
 }
 
   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
 //=============================================================================
 /*!
  * Returns true if given element is polygon
index 8aaa79bae4201174e2019ce25b9c2f7b2d427c81..62d08763d3e4dac3a7c3aa8514e0e1f3387e57f4 100644 (file)
@@ -536,8 +536,8 @@ public:
    * Returns true if given node is medium node
    * in one of quadratic elements
    */
    * Returns true if given node is medium node
    * in one of quadratic elements
    */
-  CORBA::Boolean IsMediumNodeOfAnyElem(CORBA::Long idn,
-                                       SMESH::ElementType theElemType);
+  CORBA::Boolean IsMediumNodeOfAnyElem(CORBA::Long        idn,
+                                       SMESH::ElementType elemType);
 
   /*!
    * Returns number of edges for given element
 
   /*!
    * Returns number of edges for given element
@@ -563,6 +563,12 @@ public:
    */
   CORBA::Long FindElementByNodes(const SMESH::long_array& nodes);
 
    */
   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
    */
   /*!
    * Returns true if given element is polygon
    */