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

            Line data    Source code
       1              : /*
       2              :  * Copyright (c) 2009-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__LIB_GRID__GEOMETRIC_OBJECT_COLLECTION__
      34              : #define __H__LIB_GRID__GEOMETRIC_OBJECT_COLLECTION__
      35              : 
      36              : #include <list>
      37              : #include "grid_base_objects.h"
      38              : #include "common/util/section_container.h"
      39              : #include "element_storage.h"
      40              : #include "grid_base_object_traits.h"
      41              : 
      42              : namespace ug
      43              : {
      44              : 
      45              : /// \addtogroup lib_grid_grid
      46              : /// @{
      47              : 
      48              : ////////////////////////////////////////////////////////////////////////
      49              : //      GridObjectCollection
      50              : ///     a helper class that holds a collection of possibly unconnected geometric-objects.
      51              : /**
      52              :  * This class is a simple helper class..
      53              :  * Its purpose is to make it easy to pass a collection of geometric-objects
      54              :  * to a function while maintaining the possibility to iterate over different
      55              :  * sub-types of geometric-objects seperatly.
      56              :  *
      57              :  * In contrary to \sa GridObjectCollection, the
      58              :  * GridObjectCollection allows access to the elements through
      59              :  * different levels.
      60              :  *
      61              :  * Please note that a GridObjectCollection is only valid as long as
      62              :  * the object from which you received the collection still exists.
      63              :  *
      64              :  * A GridObjectCollection can only be queried for iterators and 
      65              :  * element-counts. You may not insert new elements or remove
      66              :  * old ones (at least not directly).
      67              :  *
      68              :  * Classes that you can query for their GridObjectCollection
      69              :  * are for example ug::Grid, ug::MultiGrid, ug::SubsetHandler,
      70              :  * ug::MGSubsetHandler, ug::Selector, ug::MGSelector.
      71              :  *
      72              :  * As long as the object that provides the GridObjectCollection
      73              :  * is still valid, the GridObjectCollection will always hold the current
      74              :  * geometric objects of the source-object (i.e. a grid, a selector or a subset-handler),
      75              :  * as long as new objects are inserted into existing subsets (SubsetHandler) or
      76              :  * existing levels (MultiGrid). Insertion or removal of subsets or levels is
      77              :  * not reflected by the goc and can lead to severe errors.
      78              :  * Make sure to retrieve a new goc if such changes happened.
      79              :  *
      80              :  * Please note that a GridObjectCollection does not necessarily represent
      81              :  * a topological closed part of a grid.
      82              :  * A Collection can for example hold faces without their
      83              :  * associated vertices.
      84              :  *
      85              :  * How to use GridObjectCollection:
      86              :  * Once you retrieved an instance (let's call it goc) you can query it for
      87              :  * iterators like this:
      88              :  * VertexIterator iter = goc.vertices_begin(0);
      89              :  * or if you want to iterate over triangles of level 1 type the following:
      90              :  * TriangleIterator iter = goc.begin<Triangle>(1);
      91              :  *
      92              :  * if you want to get the number of hexahedrons in level 0 you would go like this:
      93              :  * uint numHexas = goc.num<Hexahedron>(0);
      94              :  */
      95            0 : class UG_API GridObjectCollection
      96              : {
      97              :         public:
      98              :         ///     The traits class holds some important types for each element-type
      99              :                 template <class TElem>
     100              :                 struct traits{
     101              :                         typedef typename geometry_traits<TElem>::iterator         iterator;
     102              :                         typedef typename geometry_traits<TElem>::const_iterator   const_iterator;
     103              :                 };
     104              : 
     105              :         ///     initializes the instance with an estimate of the number of levels.
     106              :         /**     The estimate does not have to match exactly. However, if it does
     107              :          *  it makes things faster.*/
     108              :                 GridObjectCollection(size_t levelEstimate = 1);
     109              :                 
     110              :         ///     initializes level 0 with the given sections.
     111              :                 GridObjectCollection(ElementStorage<Vertex>::SectionContainer* vrtCon,
     112              :                                                                 ElementStorage<Edge>::SectionContainer* edgeCon,
     113              :                                                                 ElementStorage<Face>::SectionContainer* faceCon,
     114              :                                                                 ElementStorage<Volume>::SectionContainer* volCon);
     115              : 
     116              :         //      copy constructor.
     117              :                 GridObjectCollection(const GridObjectCollection& mgoc);
     118              :                 
     119              :                 GridObjectCollection& operator =(const GridObjectCollection& mgoc);
     120              :                 
     121              :         ///     only used during creation by the methods that create the collection
     122              :                 void add_level(ElementStorage<Vertex>::SectionContainer* vrtCon,
     123              :                                                 ElementStorage<Edge>::SectionContainer* edgeCon,
     124              :                                                 ElementStorage<Face>::SectionContainer* faceCon,
     125              :                                                 ElementStorage<Volume>::SectionContainer* volCon);
     126              : 
     127              :         ///     returns the number of levels
     128              :                 inline size_t num_levels() const                {return m_levels.size();}
     129              :                 
     130              :         //      Iterators
     131              :         //      begin
     132              :         /**     returns the begin iterator for the specified level.
     133              :          *      If no level is given iterators for level 0 are returned.*/
     134              :                 template <class TGeomObj>
     135              :                 inline
     136              :                 typename geometry_traits<TGeomObj>::iterator
     137              :                 begin(size_t level = 0);
     138              : 
     139              :         //      end
     140              :         /**     returns the end iterator for the specified level.
     141              :          *      If no level is given iterators for level 0 are returned.*/
     142              :                 template <class TGeomObj>
     143              :                 inline
     144              :                 typename geometry_traits<TGeomObj>::iterator
     145              :                 end(size_t level = 0);
     146              : 
     147              :                 inline VertexIterator   vertices_begin(size_t level = 0)        {return begin<Vertex>(level);}
     148              :                 inline VertexIterator   vertices_end(size_t level = 0)          {return end<Vertex>(level);}
     149              :                 inline EdgeIterator             edges_begin(size_t level = 0)           {return begin<Edge>(level);}
     150              :                 inline EdgeIterator             edges_end(size_t level = 0)                     {return end<Edge>(level);}
     151              :                 inline FaceIterator                     faces_begin(size_t level = 0)           {return begin<Face>(level);}
     152              :                 inline FaceIterator                     faces_end(size_t level = 0)                     {return end<Face>(level);}
     153              :                 inline VolumeIterator           volumes_begin(size_t level = 0)         {return begin<Volume>(level);}
     154              :                 inline VolumeIterator           volumes_end(size_t level = 0)           {return end<Volume>(level);}
     155              : 
     156              :         //      const iterators
     157              :         //      begin
     158              :                 template <class TGeomObj>
     159              :                 inline
     160              :                 typename geometry_traits<TGeomObj>::const_iterator
     161              :                 begin(size_t level = 0) const;
     162              : 
     163              :         //      end
     164              :                 template <class TGeomObj>
     165              :                 inline
     166              :                 typename geometry_traits<TGeomObj>::const_iterator
     167              :                 end(size_t level = 0) const;
     168              : 
     169              :                 inline ConstVertexIterator      vertices_begin(size_t level = 0) const  {return begin<Vertex>(level);}
     170              :                 inline ConstVertexIterator      vertices_end(size_t level = 0) const    {return end<Vertex>(level);}
     171              :                 inline ConstEdgeIterator        edges_begin(size_t level = 0) const             {return begin<Edge>(level);}
     172              :                 inline ConstEdgeIterator        edges_end(size_t level = 0) const               {return end<Edge>(level);}
     173              :                 inline ConstFaceIterator                faces_begin(size_t level = 0) const             {return begin<Face>(level);}
     174              :                 inline ConstFaceIterator                faces_end(size_t level = 0) const               {return end<Face>(level);}
     175              :                 inline ConstVolumeIterator              volumes_begin(size_t level = 0) const   {return begin<Volume>(level);}
     176              :                 inline ConstVolumeIterator              volumes_end(size_t level = 0) const             {return end<Volume>(level);}
     177              :                 
     178              :         //      element numbers
     179              :                 template <class TGeomObj>
     180              :                 size_t num() const;
     181              :                 
     182              :                 inline size_t num_vertices() const      {return num<Vertex>();}
     183              :                 inline size_t num_edges() const         {return num<Edge>();}
     184              :                 inline size_t num_faces() const         {return num<Face>();}
     185              :                 inline size_t num_volumes() const       {return num<Volume>();}
     186              :                 
     187              :                 template <class TGeomObj>
     188              :                 inline
     189              :                 size_t num(size_t level) const;
     190              :                 
     191              :                 inline size_t num_vertices(size_t level) const  {return num<Vertex>(level);}
     192              :                 inline size_t num_edges(size_t level) const             {return num<Edge>(level);}
     193              :                 inline size_t num_faces(size_t level) const             {return num<Face>(level);}
     194              :                 inline size_t num_volumes(size_t level) const   {return num<Volume>(level);}
     195              :                 
     196              :         protected:
     197              :                 void assign(const GridObjectCollection& goc);
     198              : 
     199              :                 template <class TGeomObj> inline
     200              :                 const typename ElementStorage<typename geometry_traits<TGeomObj>::grid_base_object>::
     201              :                 SectionContainer* get_container(size_t level) const;
     202              :                 
     203              :                 template <class TGeomObj> inline
     204              :                 typename ElementStorage<typename geometry_traits<TGeomObj>::grid_base_object>::
     205              :                 SectionContainer* get_container(size_t level);
     206              :                                 
     207              :         protected:
     208              :                 struct ContainerCollection{
     209            0 :                         ContainerCollection()   {}
     210              :                         ContainerCollection(ElementStorage<Vertex>::SectionContainer* vrtCon,
     211              :                                                                 ElementStorage<Edge>::SectionContainer* edgeCon,
     212              :                                                                 ElementStorage<Face>::SectionContainer* faceCon,
     213              :                                                                 ElementStorage<Volume>::SectionContainer* volCon);
     214              : 
     215              :                         ElementStorage<Vertex>::SectionContainer* vrtContainer;
     216              :                         ElementStorage<Edge>::SectionContainer*           edgeContainer;
     217              :                         ElementStorage<Face>::SectionContainer*                   faceContainer;
     218              :                         ElementStorage<Volume>::SectionContainer*         volContainer;
     219              :                 };
     220              :                 
     221              :                 typedef std::vector<ContainerCollection> ContainerVec;
     222              :                 //typedef std::vector<GridObjectCollection> GOCVec;
     223              : 
     224              :         protected:
     225              :                 ContainerVec    m_levels;
     226              : };
     227              : 
     228              : /// @}
     229              : }//     end of namespace
     230              : 
     231              : ////////////////////////////////////////////////
     232              : //      include implementation
     233              : #include "grid_object_collection_impl.hpp"
     234              : 
     235              : #endif
        

Generated by: LCOV version 2.0-1