LCOV - code coverage report
Current view: top level - ugbase/lib_grid/tools - selector_grid_elem.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 7 0
Test Date: 2025-09-21 23:31:46 Functions: 0.0 % 3 0

            Line data    Source code
       1              : /*
       2              :  * Copyright (c) 2010-2015:  G-CSC, Goethe University Frankfurt
       3              :  * Author: Sebastian Reiter
       4              :  * 
       5              :  * This file is part of UG4.
       6              :  * 
       7              :  * UG4 is free software: you can redistribute it and/or modify it under the
       8              :  * terms of the GNU Lesser General Public License version 3 (as published by the
       9              :  * Free Software Foundation) with the following additional attribution
      10              :  * requirements (according to LGPL/GPL v3 §7):
      11              :  * 
      12              :  * (1) The following notice must be displayed in the Appropriate Legal Notices
      13              :  * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
      14              :  * 
      15              :  * (2) The following notice must be displayed at a prominent place in the
      16              :  * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
      17              :  * 
      18              :  * (3) The following bibliography is recommended for citation and must be
      19              :  * preserved in all covered files:
      20              :  * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
      21              :  *   parallel geometric multigrid solver on hierarchically distributed grids.
      22              :  *   Computing and visualization in science 16, 4 (2013), 151-164"
      23              :  * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
      24              :  *   flexible software system for simulating pde based models on high performance
      25              :  *   computers. Computing and visualization in science 16, 4 (2013), 165-179"
      26              :  * 
      27              :  * This program is distributed in the hope that it will be useful,
      28              :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      29              :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
      30              :  * GNU Lesser General Public License for more details.
      31              :  */
      32              : 
      33              : ////////////////////////////////////////////////////////////////////////
      34              : ////////////////////////////////////////////////////////////////////////
      35              : //      ...
      36              : ////////////////////////////////////////////////////////////////////////
      37              : 
      38              : #ifndef __H__LIBGRID__SELECTOR_GRID_ELEM__
      39              : #define __H__LIBGRID__SELECTOR_GRID_ELEM__
      40              : 
      41              : #include <cassert>
      42              : #include "selector_grid.h"
      43              : 
      44              : namespace ug
      45              : {
      46              : 
      47              : /** \ingroup lib_grid_tools
      48              :  *  \{ */
      49              : 
      50              : ////////////////////////////////////////////////////////////////////////
      51              : ////////////////////////////////////////////////////////////////////////
      52              : //      TElemSelector
      53              : ///     specialization of ISelector for a subset of the elements in a grid of class Grid.
      54              : /**
      55              :  * A selector is a useful class, that allows the user to mark
      56              :  * elements of a grid as selected or deselected.
      57              :  * The selection status is maintained even if new elements
      58              :  * are created or old ones deleted. Features like
      59              :  * autoselection and selection_inheritance allow users to
      60              :  * follow the creation and removal of elements in all kind of
      61              :  * algorithms.
      62              :  *
      63              :  * Please note that the selector has to be registered at a
      64              :  * grid before it may be used. You may register it using the constructor
      65              :  * or the method assign_grid.
      66              :  *
      67              :  * This is a specialization of ISelector for the class Grid that only
      68              :  * works on one element type (either Vertex, Edge, Face or
      69              :  * Volume). Normally you will use the typedefs VertexSelector,
      70              :  * EdgeSelector, FaceSelector or VolumeSelector instead of this class.
      71              :  *
      72              :  * The following methods are the most used:
      73              :  *      - select, deselect, is_selected (see ISelector)
      74              :  *      - begin, end, num, clear.
      75              :  *
      76              :  * You may specify the element-type on which begin, end, num and clear
      77              :  * operate via a template parameter.
      78              :  *
      79              :  * \code
      80              :  * Grid g;
      81              :  * FaceSelector fsel(g);
      82              :  *
      83              :  * // ... create elements and select some
      84              :  *
      85              :  * // number of selected triangles
      86              :  * int nSelTris = fsel.num<Triangle>();
      87              :  *
      88              :  * // iteration over all faces
      89              :  *      for(FaceIterator iter = fsel.begin(i);
      90              :  *              iter != fsel.end(i); ++iter){
      91              :  * // ...
      92              :  *      }
      93              :  * \endcode
      94              :  */
      95              : 
      96              : template <class TBaseElem>
      97            0 : class UG_API TElemSelector : public Selector
      98              : {
      99              :         public:
     100              :                 typedef typename geometry_traits<TBaseElem>::iterator iterator;
     101              :                 typedef typename geometry_traits<TBaseElem>::const_iterator const_iterator;
     102              : 
     103              : 
     104              :         public:
     105              :                 TElemSelector() : Selector(SE_NONE)
     106              :                 {
     107              :                         int typId = geometry_traits<TBaseElem>::BASE_OBJECT_ID;
     108              :                         switch(typId){
     109              :                                 case VERTEX: this->enable_element_support(SE_VERTEX); break;
     110              :                                 case EDGE: this->enable_element_support(SE_EDGE); break;
     111              :                                 case FACE: this->enable_element_support(SE_FACE); break;
     112              :                                 case VOLUME: this->enable_element_support(SE_VOLUME); break;
     113              :                                 default: break;
     114              :                         }
     115              :                 }
     116              : 
     117            0 :                 TElemSelector(Grid& grid) : Selector(grid, SE_NONE)
     118              :                 {
     119              :                         int typId = geometry_traits<TBaseElem>::BASE_OBJECT_ID;
     120              :                         switch(typId){
     121            0 :                                 case VERTEX: this->enable_element_support(SE_VERTEX); break;
     122            0 :                                 case EDGE: this->enable_element_support(SE_EDGE); break;
     123              :                                 case FACE: this->enable_element_support(SE_FACE); break;
     124            0 :                                 case VOLUME: this->enable_element_support(SE_VOLUME); break;
     125              :                                 default: break;
     126              :                         }
     127            0 :                 }
     128              : 
     129              :                 using Selector::begin;// support for iteration over Edge, ConstrainedEdge, ...
     130            0 :                 inline iterator begin()                                         {return Selector::begin<TBaseElem>();}
     131              :                 inline const_iterator begin() const                     {return Selector::begin<TBaseElem>();}
     132              : 
     133              :                 using Selector::end;// support for iteration over Edge, ConstrainedEdge, ...
     134              :                 inline iterator end()                                           {return Selector::end<TBaseElem>();}
     135              :                 inline const_iterator end() const                       {return Selector::end<TBaseElem>();}
     136              : 
     137              : };
     138              : 
     139              : ////////////////////////////////////////////////////////////////////////
     140              : //      typedefs of the four element-selectors
     141              : 
     142              : typedef TElemSelector<Vertex>     VertexSelector;
     143              : typedef TElemSelector<Edge>               EdgeSelector;
     144              : typedef TElemSelector<Face>                       FaceSelector;
     145              : typedef TElemSelector<Volume>             VolumeSelector;
     146              : 
     147              : /** \} */
     148              : }//     end of namespace
     149              : 
     150              : #endif
        

Generated by: LCOV version 2.0-1