LCOV - code coverage report
Current view: top level - src/mesquite/Misc - EdgeIterator.cpp (source / functions) Hit Total Coverage
Test: coverage_sk.info Lines: 29 32 90.6 %
Date: 2020-07-18 00:09:26 Functions: 4 4 100.0 %
Branches: 47 124 37.9 %

           Branch data     Line data    Source code
       1                 :            : /* *****************************************************************
       2                 :            :     MESQUITE -- The Mesh Quality Improvement Toolkit
       3                 :            : 
       4                 :            :     Copyright 2010 Sandia National Laboratories.  Developed at the
       5                 :            :     University of Wisconsin--Madison under SNL contract number
       6                 :            :     624796.  The U.S. Government and the University of Wisconsin
       7                 :            :     retain certain rights to this software.
       8                 :            : 
       9                 :            :     This library is free software; you can redistribute it and/or
      10                 :            :     modify it under the terms of the GNU Lesser General Public
      11                 :            :     License as published by the Free Software Foundation; either
      12                 :            :     version 2.1 of the License, or (at your option) any later version.
      13                 :            : 
      14                 :            :     This library is distributed in the hope that it will be useful,
      15                 :            :     but WITHOUT ANY WARRANTY; without even the implied warranty of
      16                 :            :     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      17                 :            :     Lesser General Public License for more details.
      18                 :            : 
      19                 :            :     You should have received a copy of the GNU Lesser General Public License
      20                 :            :     (lgpl.txt) along with this library; if not, write to the Free Software
      21                 :            :     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
      22                 :            : 
      23                 :            :     (2010) [email protected]
      24                 :            : 
      25                 :            :   ***************************************************************** */
      26                 :            : 
      27                 :            : /** \file EdgeIterator.cpp
      28                 :            :  *  \brief
      29                 :            :  *  \author Jason Kraftcheck
      30                 :            :  */
      31                 :            : 
      32                 :            : #include "Mesquite.hpp"
      33                 :            : #include "EdgeIterator.hpp"
      34                 :            : 
      35                 :            : #include <algorithm>
      36                 :            : 
      37                 :            : namespace MBMesquite
      38                 :            : {
      39                 :            : 
      40                 :         82 : EdgeIterator::EdgeIterator( PatchData* p, MsqError& err ) : patchPtr( p ), vertIdx( 0 )
      41                 :            : {
      42         [ +  - ]:         41 :     p->generate_vertex_to_element_data();
      43 [ +  - ][ +  - ]:         41 :     if( patchPtr->num_nodes() )
      44                 :            :     {
      45         [ +  - ]:         41 :         get_adjacent_vertices( err );
      46 [ +  - ][ -  + ]:         41 :         if( adjIter == adjList.end() )
      47                 :            :         {
      48 [ #  # ][ #  # ]:         41 :             step( err );MSQ_ERRRTN( err );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
      49                 :            :         }
      50                 :            :     }
      51                 :            :     else
      52                 :          0 :         adjIter = adjList.end();
      53                 :            : }
      54                 :            : 
      55                 :      24595 : void EdgeIterator::get_adjacent_vertices( MsqError& err )
      56                 :            : {
      57                 :      24595 :     adjList.clear();
      58                 :            : 
      59                 :            :     // Get all adjacent elements
      60                 :            :     size_t num_elem;
      61 [ +  - ][ +  - ]:      49190 :     const size_t* elems = patchPtr->get_vertex_element_adjacencies( vertIdx, num_elem, err );MSQ_ERRRTN( err );
         [ -  + ][ #  # ]
         [ #  # ][ -  + ]
      62                 :            : 
      63                 :            :     // Get all adjacent vertices from elements
      64         [ +  - ]:      24595 :     std::vector< size_t > elem_verts;
      65         [ +  + ]:     154171 :     for( size_t e = 0; e < num_elem; ++e )
      66                 :            :     {
      67         [ +  - ]:     129576 :         MsqMeshEntity& elem = patchPtr->element_by_index( elems[e] );
      68         [ +  - ]:     129576 :         EntityTopology type = elem.get_element_type();
      69         [ +  - ]:     129576 :         size_t num_edges    = TopologyInfo::edges( type );
      70                 :            : 
      71                 :            :         bool mid_edge, mid_face, mid_vol;
      72 [ +  - ][ +  - ]:     129576 :         TopologyInfo::higher_order( type, elem.node_count(), mid_edge, mid_face, mid_vol, err );MSQ_ERRRTN( err );
         [ +  - ][ -  + ]
         [ #  # ][ #  # ]
                 [ -  + ]
      73                 :            : 
      74                 :            :         // For each edge
      75         [ +  + ]:     800664 :         for( size_t d = 0; d < num_edges; ++d )
      76                 :            :         {
      77 [ +  - ][ +  - ]:     671088 :             const unsigned* edge = TopologyInfo::edge_vertices( type, d, err );MSQ_ERRRTN( err );
         [ -  + ][ #  # ]
         [ #  # ][ -  + ]
      78         [ +  - ]:     671088 :             size_t vert1 = elem.get_vertex_index( edge[0] );
      79         [ +  - ]:     671088 :             size_t vert2 = elem.get_vertex_index( edge[1] );
      80                 :            : 
      81                 :     671088 :             size_t pmid = ~(size_t)0;
      82         [ -  + ]:     671088 :             if( mid_edge )
      83                 :            :             {
      84 [ #  # ][ #  # ]:          0 :                 int p = TopologyInfo::higher_order_from_side( type, elem.node_count(), 1, d, err );MSQ_ERRRTN( err );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
      85         [ #  # ]:          0 :                 pmid = elem.get_vertex_index_array()[p];
      86                 :            :             }
      87                 :            : 
      88                 :            :             // If this edge contains the input vertex (vert_idx)
      89                 :            :             // AND the input vertex index is less than the
      90                 :            :             // other vertex (avoids iterating over this edge twice)
      91                 :            :             // add it to the list.
      92         [ +  + ]:     671088 :             if( vert1 > vert2 )
      93                 :            :             {
      94 [ +  + ][ +  - ]:     325500 :                 if( vert2 == vertIdx ) adjList.push_back( Edge( vert1, pmid ) );
                 [ +  - ]
      95                 :            :             }
      96                 :            :             else
      97                 :            :             {
      98 [ +  + ][ +  - ]:     345588 :                 if( vert1 == vertIdx ) adjList.push_back( Edge( vert2, pmid ) );
                 [ +  - ]
      99                 :            :             }
     100                 :            :         }
     101                 :            :     }
     102                 :            : 
     103                 :            :     // Remove duplicates
     104         [ +  - ]:      24595 :     std::sort( adjList.begin(), adjList.end() );
     105         [ +  - ]:      24595 :     adjIter = std::unique( adjList.begin(), adjList.end() );
     106 [ +  - ][ +  - ]:      24595 :     adjList.resize( adjIter - adjList.begin() );
     107         [ +  - ]:      24595 :     adjIter = adjList.begin();
     108                 :            : }
     109                 :            : 
     110 [ +  - ][ +  - ]:        120 : }  // namespace MBMesquite

Generated by: LCOV version 1.11