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

            Line data    Source code
       1              : /*
       2              :  * Copyright (c) 2012-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              : #ifndef __H__UG__bool_marker__
      34              : #define __H__UG__bool_marker__
      35              : 
      36              : #include "lib_grid/grid/grid.h"
      37              : #include "lib_grid/common_attachments.h"
      38              : 
      39              : namespace ug
      40              : {
      41              : 
      42              : /** \ingroup lib_grid_tools
      43              :  *  \{ */
      44              : 
      45              : ///     Allows to mark elements.
      46              : /** This class allows to mark elements of a grid.
      47              :  * The BoolMarker associates a bool with each element.
      48              :  * Note that clearing the marks has a runtime complexity of O(n). If you need
      49              :  * marks for repeatedly called local algorithms you may want to use Grid::mark
      50              :  * instead, which has a clear_marks method with runtime complexity of O(1).
      51              :  *
      52              :  * Note that methods like mark, unmark, is_marked, clear, ... may only be invoked,
      53              :  * if a grid was assigned through either assign_grid or through the constructor.
      54              :  *
      55              :  * Marks can be passed to children, when an element is refined. You have to enable
      56              :  * mark inheritance in order to activate this behavior (use enable_mark_inheritance).
      57              :  * Mark inheritance is enabled by default.
      58              :  *
      59              :  * \todo        Allow to restrict marking to vertices, edges, faces or volumes
      60              :  * \todo        Add is_marked, mark, unmark for GridObject
      61              :  * \todo        Refactor to template \<class T\> Marker.
      62              :  */
      63              : class BoolMarker : public GridObserver
      64              : {
      65              :         public:
      66              :                 BoolMarker();
      67              :                 BoolMarker(Grid& g);
      68              : 
      69              :                 virtual ~BoolMarker();
      70              : 
      71              :         ///     Assign the grid on which the marker shall operate.
      72              :         /**     NULL is a valid argument and sets the marker into an unassigned state.
      73              :          * The marker may only be used, if it is associated with a grid instance.*/
      74              :                 void assign_grid(Grid* g);
      75              :         ///     Assign the grid on which the marker shall operate.
      76              :                 void assign_grid(Grid& g)                                   {assign_grid(&g);}
      77              : 
      78            0 :                 Grid* grid()                                                            {return m_pGrid;}
      79              : 
      80              :         ///     set the mark which is applied when a new element is created
      81              :         /**     By default the default-mark is set to false. Note that the default mark
      82              :          * only has an effect on child elements, if mark-inheritance is disabled.
      83              :          * @param mark  this mark is set to new elements on creation.*/
      84              :                 void set_default_mark(bool mark)                        {m_defaultMark = mark;}
      85              :         ///     returns the default mark.
      86            0 :                 bool default_mark()                                                     {return m_defaultMark;}
      87              : 
      88              :         ///     if enabled, marks are passed from parents on to their children
      89              :         /**     \{ */
      90              :                 void enable_mark_inheritance(bool enable)       {m_markInheritanceEnabled = enable;}
      91            0 :                 bool mark_inheritance_enabeld()                         {return m_markInheritanceEnabled;}
      92              :         /**     \} */
      93              : 
      94              :         /**     restricts mark inheritance so that new elements derive their selection
      95              :          * status only from parents with the same base-type. Disabled by default.
      96              :          *      NOTE: strict inheritance only has an effect if selection inheritance is enabled.
      97              :          *      \{ */
      98              :                 void enable_strict_inheritance(bool enable)     {m_strictInheritanceEnabled = enable;}
      99            0 :                 bool strict_inheritance_enabled()                       {return m_strictInheritanceEnabled;}
     100              :         /**     \} */
     101              : 
     102              : 
     103              :                 bool is_marked(GridObject* e) const;
     104              :                 bool is_marked(Vertex* e) const                 {assert(m_pGrid); return m_aaMarkVRT[e];}
     105              :                 bool is_marked(Edge* e) const                   {assert(m_pGrid); return m_aaMarkEDGE[e];}
     106              :                 bool is_marked(Face* e) const                           {assert(m_pGrid); return m_aaMarkFACE[e];}
     107              :                 bool is_marked(Volume* e) const                         {assert(m_pGrid); return m_aaMarkVOL[e];}
     108              : 
     109              :                 void mark(Vertex* e, bool mark = true)  {assert(m_pGrid); m_aaMarkVRT[e] = mark;}
     110              :                 void mark(Edge* e, bool mark = true)    {assert(m_pGrid); m_aaMarkEDGE[e] = mark;}
     111              :                 void mark(Face* e, bool mark = true)            {assert(m_pGrid); m_aaMarkFACE[e] = mark;}
     112              :                 void mark(Volume* e, bool mark = true)          {assert(m_pGrid); m_aaMarkVOL[e] = mark;}
     113              : 
     114              :                 template <class TIter>
     115            0 :                 void mark(TIter begin, TIter end, bool mark = true)
     116              :                 {
     117            0 :                         for(TIter iter = begin; iter != end; ++iter) BoolMarker::mark(*iter, mark);
     118            0 :                 }
     119              : 
     120              :                 void unmark(Vertex* e)  {mark(e, false);}
     121              :                 void unmark(Edge* e)    {mark(e, false);}
     122              :                 void unmark(Face* e)            {mark(e, false);}
     123              :                 void unmark(Volume* e)          {mark(e, false);}
     124              : 
     125              :                 template <class TIter>
     126            0 :                 void unmark(TIter begin, TIter end)                     {mark(begin, end, false);}
     127              : 
     128              :         ///     Sets all marks to false. O(n).
     129              :                 void clear();
     130              : 
     131              :         ///     derived from GridObserver
     132              :                 virtual void grid_to_be_destroyed(Grid* grid);
     133              : 
     134              :         //      element callbacks
     135              :                 virtual void vertex_created(Grid* grid, Vertex* vrt,
     136              :                                                                         GridObject* pParent = NULL,
     137              :                                                                         bool replacesParent = false);
     138              : 
     139              :                 virtual void edge_created(Grid* grid, Edge* e,
     140              :                                                                         GridObject* pParent = NULL,
     141              :                                                                         bool replacesParent = false);
     142              : 
     143              :                 virtual void face_created(Grid* grid, Face* f,
     144              :                                                                         GridObject* pParent = NULL,
     145              :                                                                         bool replacesParent = false);
     146              : 
     147              :                 virtual void volume_created(Grid* grid, Volume* vol,
     148              :                                                                         GridObject* pParent = NULL,
     149              :                                                                         bool replacesParent = false);
     150              : 
     151              :                 virtual void vertices_to_be_merged(Grid* grid, Vertex* target,
     152              :                                                                                  Vertex* elem1, Vertex* elem2);
     153              : 
     154              :                 virtual void edges_to_be_merged(Grid* grid, Edge* target,
     155              :                                                                                  Edge* elem1, Edge* elem2);
     156              : 
     157              :                 virtual void faces_to_be_merged(Grid* grid, Face* target,
     158              :                                                                                  Face* elem1, Face* elem2);
     159              : 
     160              :                 virtual void volumes_to_be_merged(Grid* grid, Volume* target,
     161              :                                                                                  Volume* elem1, Volume* elem2);
     162              : 
     163              :         protected:
     164              :                 Grid*   m_pGrid;
     165              :                 ABool   m_aBool;
     166              :                 bool    m_defaultMark;
     167              :                 bool    m_markInheritanceEnabled;
     168              :                 bool    m_strictInheritanceEnabled;
     169              :                 Grid::AttachmentAccessor<Vertex, ABool>   m_aaMarkVRT;
     170              :                 Grid::AttachmentAccessor<Edge, ABool>     m_aaMarkEDGE;
     171              :                 Grid::AttachmentAccessor<Face, ABool>             m_aaMarkFACE;
     172              :                 Grid::AttachmentAccessor<Volume, ABool>           m_aaMarkVOL;
     173              : };
     174              : 
     175              : /** \} */
     176              : 
     177              : }//     end of namespace
     178              : 
     179              : #endif
        

Generated by: LCOV version 2.0-1