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

            Line data    Source code
       1              : /*
       2              :  * Copyright (c) 2016:  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              : #ifndef __H__UG_sub_grid
      34              : #define __H__UG_sub_grid
      35              : 
      36              : namespace ug{
      37              : 
      38              : ///     Instances represent a part of a grid.
      39              : /** One can iterate over the objects in a sub-grid and one may check whether
      40              :  * elements are contained in a sub-grid.
      41              :  *
      42              :  * \sa SubGrid
      43              :  */
      44              : class ISubGrid {
      45              : public:
      46              :         virtual ~ISubGrid() {}
      47              : 
      48              :         virtual const GridObjectCollection& goc () const = 0;
      49              :         virtual bool is_contained(Vertex*) const = 0;
      50              :         virtual bool is_contained(Edge*) const = 0;
      51              :         virtual bool is_contained(Face*) const = 0;
      52              :         virtual bool is_contained(Volume*) const = 0;
      53              : };
      54              : 
      55              : 
      56              : ///     specializes ISubGrid for general callback classes.
      57              : /**
      58              :  *\param TCallbackCls   A class that features the following methods
      59              :  *                                              - bool operator() (Vertex* v) const;
      60              :  *                                              - bool operator() (Edge* e) const;
      61              :  *                                              - bool operator() (Face* f) const;
      62              :  *                                              - bool operator() (Volume* v) const;
      63              :  */
      64              : template <class TCallbackCls>
      65            0 : class SubGrid : public ISubGrid{
      66              : public:
      67            0 :         SubGrid(GridObjectCollection goc, const TCallbackCls& cb) :
      68            0 :                 m_goc (goc),
      69            0 :                 m_callbacks (cb)
      70              :         {
      71              :         }
      72              : 
      73            0 :         virtual const GridObjectCollection& goc () const    {return m_goc;}
      74            0 :         virtual bool is_contained (Vertex* e) const                     {return m_callbacks(e);}
      75            0 :         virtual bool is_contained (Edge* e) const                       {return m_callbacks(e);}
      76            0 :         virtual bool is_contained (Face* e) const                       {return m_callbacks(e);}
      77            0 :         virtual bool is_contained (Volume* e) const                     {return m_callbacks(e);}
      78              : 
      79              : private:
      80              :         GridObjectCollection    m_goc;
      81              :         TCallbackCls                    m_callbacks;
      82              : };
      83              : 
      84              : 
      85              : ///     Callbacks that return true if an element is contained in a sub-grid.
      86              : /**     Please make sure that the associated sub-grid exists until the callback-class
      87              :  * was destroyed.*/
      88              : class IsInSubGrid
      89              : {
      90              :         public:
      91              :                 IsInSubGrid(const ISubGrid& subGrid) :
      92              :                         m_subGrid(subGrid)      {}
      93              : 
      94              :                 bool operator() (Vertex* v)     {return callback(v);}
      95              :                 bool operator() (Edge* e)       {return callback(e);}
      96              :                 bool operator() (Face* f)       {return callback(f);}
      97              :                 bool operator() (Volume* v)     {return callback(v);}
      98              : 
      99              :         private:
     100              :                 template <class TElem>
     101              :                 bool callback(TElem* e)         {return m_subGrid.is_contained(e);}
     102              : 
     103              :         private:
     104              :                 const ISubGrid&     m_subGrid;
     105              : };
     106              : 
     107              : 
     108              : ///     Callbacks that return true if an element is not contained in a sub-grid.
     109              : /**     Please make sure that the associated sub-grid exists until the callback-class
     110              :  * was destroyed.*/
     111              : class IsNotInSubGrid
     112              : {
     113              :         public:
     114              :                 IsNotInSubGrid(const ISubGrid& subGrid) :
     115              :                         m_subGrid(subGrid)      {}
     116              : 
     117              :                 bool operator() (Vertex* v)     {return callback(v);}
     118              :                 bool operator() (Edge* e)       {return callback(e);}
     119              :                 bool operator() (Face* f)       {return callback(f);}
     120              :                 bool operator() (Volume* v)     {return callback(v);}
     121              : 
     122              :         private:
     123              :                 template <class TElem>
     124              :                 bool callback(TElem* e)         {return !m_subGrid.is_contained(e);}
     125              : 
     126              :         private:
     127              :                 const ISubGrid&     m_subGrid;
     128              : };
     129              : 
     130              : }//     end of namespace
     131              : 
     132              : #endif  //__H__UG_sub_grid
        

Generated by: LCOV version 2.0-1