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

            Line data    Source code
       1              : /*
       2              :  * Copyright (c) 2012-2015:  G-CSC, Goethe University Frankfurt
       3              :  * Author: Andreas Vogel
       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__LIB_GRID__TOOLS__GRID_LEVEL__
      34              : #define __H__UG__LIB_GRID__TOOLS__GRID_LEVEL__
      35              : 
      36              : #include <string>
      37              : #include <iostream>
      38              : 
      39              : namespace ug{
      40              : 
      41              : class GridLevel
      42              : {
      43              :         public:
      44              :         ///     indicates that always top level should be used
      45              :                 enum{TOP = -1};
      46              : 
      47              :         ///     type of view
      48              :                 enum ViewType{LEVEL = 0, SURFACE = 1};
      49              : 
      50              :         public:
      51              :         ///     constructor creation surface grid
      52            0 :                 GridLevel() : m_level(TOP), m_type(SURFACE), m_bWithGhosts(false) {}
      53              : 
      54              :         ///     constructor
      55              :                 GridLevel(int level, ViewType type, bool bWithGhosts = false)
      56            0 :                         : m_level(level), m_type(type), m_bWithGhosts(bWithGhosts)
      57              :                 {}
      58              : 
      59              :         ///     constructor
      60              :                 GridLevel(int level)
      61            0 :                         : m_level(level), m_type(SURFACE), m_bWithGhosts(false)
      62              :                 {}
      63              : 
      64              :         ///     constructor
      65            0 :                 GridLevel(int level, const std::string& type)
      66            0 :                         : m_level(level), m_bWithGhosts(false)
      67              :                 {
      68            0 :                         if(type == "top") {m_type = LEVEL;}
      69            0 :                         else if(type == "surf") {m_type = SURFACE;}
      70            0 :                         else UG_THROW("Grid Level Type not in ['top' | 'surf'].");
      71            0 :                 }
      72              : 
      73              :         ///     returns the level
      74            0 :                 int level() const {return m_level;}
      75              : 
      76              :         ///     returns the type
      77            0 :                 ViewType type() const {return m_type;}
      78              : 
      79              :         ///     returns if ghosts are considered as part of the level
      80            0 :                 bool ghosts() const {return m_bWithGhosts;}
      81              : 
      82              :         ///     returns if top level
      83              :                 bool top() const {return level() == TOP;}
      84              : 
      85              :         ///     returns if type is level
      86              :                 bool is_level() const {return type() == LEVEL;}
      87              : 
      88              :         ///     returns if type is surface
      89              :                 bool is_surface() const {return type() == SURFACE;}
      90              : 
      91              :         ///     operator ==
      92              :                 bool operator==(const GridLevel& rhs) const {
      93            0 :                         return (this->level() == rhs.level() && this->type() == rhs.type()
      94            0 :                                         && this->ghosts() == rhs.ghosts());
      95              :                 }
      96              : 
      97              :         ///     operator !=
      98              :                 bool operator!=(const GridLevel& rhs) const {
      99              :                         return !(this->operator==(rhs));
     100              :                 }
     101              : 
     102              :         ///     operator <
     103              :                 bool operator<(const GridLevel& rhs) const
     104              :                 {
     105            0 :                         if(this->type() != rhs.type()) return this->type() < rhs.type();
     106            0 :                         if(this->ghosts() != rhs.ghosts()) return !this->ghosts();
     107            0 :                         if(this->level() == rhs.level()) return false;
     108            0 :                         if(this->level() == TOP) return false;
     109            0 :                         if(rhs.level() == TOP) return true;
     110            0 :                         return this->level() < rhs.level();
     111              :                 }
     112              : 
     113              :         ///     operator >
     114              :                 bool operator>(const GridLevel& rhs) const
     115              :                 {
     116              :                         if(this->type() != rhs.type()) return this->type() > rhs.type();
     117              :                         if(this->ghosts() != rhs.ghosts()) return this->ghosts();
     118              :                         if(this->level() == rhs.level()) return false;
     119              :                         if(this->level() == TOP) return true;
     120              :                         if(rhs.level() == TOP) return false;
     121              :                         return this->level() > rhs.level();
     122              :                 }
     123              : 
     124              :         ///     operator <=
     125              :                 bool operator<=(const GridLevel& rhs) const
     126              :                 {
     127              :                         return (*this < rhs || *this == rhs);
     128              :                 }
     129              : 
     130              :         ///     operator >=
     131              :                 bool operator>=(const GridLevel& rhs) const
     132              :                 {
     133              :                         return (*this > rhs || *this == rhs);
     134              :                 }
     135              : 
     136              :         protected:
     137              :                 int m_level; ///< the grid level
     138              :                 ViewType m_type;         ///< type (i.e. surface or level view)
     139              :                 bool m_bWithGhosts;     ///< with ghosts (only senseful in parallel)
     140              : };
     141              : 
     142              : /// writes to the output stream
     143              : std::ostream& operator<<(std::ostream& out,       const GridLevel& v);
     144              : 
     145              : /// returns appendix for a grid level
     146              : std::string GridLevelAppendix(const GridLevel& gl, int minfill = 2);
     147              : 
     148              : } // end namespace ug
     149              : 
     150              : #endif /* __H__UG__LIB_GRID__TOOLS__GRID_LEVEL__ */
        

Generated by: LCOV version 2.0-1