Quinoa unit test code coverage report
Current view: top level - Mesh - Around.hpp (source / functions) Hit Total Coverage
Commit: Quinoa_v0.3-957-gb4f0efae0 Lines: 4 4 100.0 %
Date: 2021-11-09 12:13:43 Functions: 0 0 -
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 9 18 50.0 %

           Branch data     Line data    Source code
       1                 :            : // *****************************************************************************
       2                 :            : /*!
       3                 :            :   \file      src/Mesh/Around.hpp
       4                 :            :   \copyright 2012-2015 J. Bakosi,
       5                 :            :              2016-2018 Los Alamos National Security, LLC.,
       6                 :            :              2019-2021 Triad National Security, LLC.
       7                 :            :              All rights reserved. See the LICENSE file for details.
       8                 :            :   \brief     Helper class for iterating through linked lists of derived data
       9                 :            :   \details   Helper class for iterating through every item in a linked list data
      10                 :            :     structure derived from unstructured mesh connectivity.
      11                 :            :   \see src/Mesh/DerivedData.h
      12                 :            : */
      13                 :            : // *****************************************************************************
      14                 :            : #ifndef Around_h
      15                 :            : #define Around_h
      16                 :            : 
      17                 :            : #include <vector>
      18                 :            : #include <map>
      19                 :            : #include <utility>
      20                 :            : #include <cstddef>
      21                 :            : #include "Types.hpp"
      22                 :            : #include "Fields.hpp"
      23                 :            : #include "UnsMesh.hpp"
      24                 :            : 
      25                 :            : namespace tk {
      26                 :            : 
      27                 :            : //! \brief Helper class simplifying client code for iterating on entries
      28                 :            : //!   surrounding entries via linked lists derived from unstructured mesh
      29                 :            : //!   connectivity
      30                 :            : class Around {
      31                 :            : 
      32                 :            :   private:
      33                 :            :     //! Linked list type: T1: item list, T2: index list
      34                 :            :     using List =
      35                 :            :       std::pair< std::vector< std::size_t >, std::vector< std::size_t > >;
      36                 :            : 
      37                 :            :     //! Non-const iterator to the item list in List::T1
      38                 :            :     using iterator = List::first_type::iterator;
      39                 :            : 
      40                 :            :     //! Const iterator to the item list in List::T1
      41                 :            :     using const_iterator = List::first_type::const_iterator;
      42                 :            : 
      43                 :            :     //! Difference type for iterator/pointer arithmetics
      44                 :            :     using diff_type = List::first_type::difference_type;
      45                 :            : 
      46                 :            :   public:
      47                 :            :     //! Constructor
      48                 :            :     //! \param[in] list Linked list (vectors) storing derived data
      49                 :            :     //! \param[in] idx Index of entry whose surrounding items we will iterate on
      50                 :            :     explicit Around( const List& list, std::size_t idx ) :
      51                 :            :       m_list( list ), m_idx( idx ) {}
      52                 :            : 
      53                 :            :     //! Const iterator to the beginning of the entries of surrounding entries
      54                 :            :     //! \return Iterator to the beginning of the entries of surrounding entries
      55                 :            :     //! \note This class does not allow modifing the underlying linked list, so
      56                 :            :     //!   the begin/end iterators are aliased to cbegin/cend.
      57                 :            :     const_iterator begin() const noexcept { return this->cbegin(); }
      58                 :            : 
      59                 :            :     //! Const iterator to the entry after the last of the surrounding entries
      60                 :            :     //! \return Iterator to the entry after the last of the surrounding entries
      61                 :            :     //! \note This class does not allow modifing the underlying linked list, so
      62                 :            :     //!   the begin/end iterators are aliased to cbegin/cend.
      63                 :            :     const_iterator end() const noexcept { return this->cend(); }
      64                 :            : 
      65                 :            :     //! Iterator to the beginning of the entries of surrounding entries
      66                 :            :     //! \return Iterator to the beginning of the entries of surrounding entries
      67                 :            :     const_iterator cbegin() const noexcept {
      68                 :       1062 :       return m_list.first.cbegin() +
      69 [ +  - ][ +  - ]:       1118 :              static_cast< diff_type >( m_list.second[m_idx] + 1 );
                 [ +  - ]
      70                 :            :     }
      71                 :            : 
      72                 :            :     //! Iterator to the entry after the last of the surrounding entries
      73                 :            :     //! \return Iterator to the entry after the last of the surrounding entries
      74                 :            :     const_iterator cend() const noexcept {
      75 [ +  - ][ +  - ]:         56 :       return m_list.first.cbegin() +
                 [ +  - ]
      76 [ +  - ][ +  - ]:       1118 :              static_cast< diff_type >( m_list.second[m_idx+1] + 1 );
                 [ +  - ]
      77                 :            :     }
      78                 :            : 
      79                 :            :   private:
      80                 :            :     const List& m_list; //!< Linked list to iterate in
      81                 :            :     std::size_t m_idx;  //!< Index whose surrounding entries to iterate on
      82                 :            : };
      83                 :            : 
      84                 :            : } // tk::
      85                 :            : 
      86                 :            : #endif // Around_h

Generated by: LCOV version 1.14