LCOV - code coverage report
Current view: top level - ugbase/lib_grid/grid - grid_base_objects.cpp (source / functions) Coverage Total Hit
Test: coverage.info Lines: 4.6 % 108 5
Test Date: 2025-09-21 23:31:46 Functions: 6.1 % 33 2

            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              : #include "grid_base_objects.h"
      34              : #include "grid_util.h"
      35              : 
      36              : namespace ug
      37              : {
      38              : 
      39              : const char* GRID_BASE_OBJECT_SINGULAR_NAMES[] = {"vertex", "edge", "face", "volume"};
      40              : const char* GRID_BASE_OBJECT_PLURAL_NAMES[] = {"vertices", "edges", "faces", "volume"};
      41              : 
      42              : ////////////////////////////////////////////////////////////////////////
      43              : //      implementation of edge
      44            0 : bool Edge::get_opposing_side(Vertex* v, Vertex** vrtOut)
      45              : {
      46            0 :         if(v == m_vertices[0])
      47            0 :                 *vrtOut = m_vertices[1];
      48            0 :         else if(v == m_vertices[1])
      49            0 :                 *vrtOut = m_vertices[0];
      50              :         else
      51              :                 return false;
      52              :         return true;
      53              : }
      54              : 
      55              : ////////////////////////////////////////////////////////////////////////
      56              : //      implementation of edge-descriptor
      57            3 : EdgeDescriptor::EdgeDescriptor()
      58              : {
      59            3 : }
      60              : 
      61            0 : EdgeDescriptor::EdgeDescriptor(const EdgeDescriptor& ed)
      62              : {
      63              :         EdgeVertices::assign_edge_vertices(ed);
      64            0 : }
      65              : 
      66            0 : EdgeDescriptor::EdgeDescriptor(Vertex* vrt1, Vertex* vrt2)
      67              : {
      68            0 :         m_vertices[0] = vrt1;
      69            0 :         m_vertices[1] = vrt2;
      70            0 : }
      71              : 
      72            0 : EdgeDescriptor& EdgeDescriptor::operator = (const EdgeDescriptor& ed)
      73              : {
      74              :         EdgeVertices::assign_edge_vertices(ed);
      75            0 :         return *this;
      76              : }
      77              : 
      78              : 
      79              : ////////////////////////////////////////////////////////////////////////
      80              : //      implementation of face
      81            0 : int Face::get_local_side_index(EdgeVertices* e) const
      82              : {
      83            0 :         EdgeDescriptor ed;
      84            0 :         for(size_t i = 0; i < num_sides(); ++i){
      85            0 :                 edge_desc(i, ed);
      86            0 :                 if(CompareVertices(e, &ed))
      87            0 :                         return (int)i;
      88              :         }
      89              :         return -1;
      90              : }
      91              : 
      92              : 
      93              : ////////////////////////////////////////////////////////////////////////
      94              : //      implementation of face-descriptor
      95            2 : FaceDescriptor::FaceDescriptor() :
      96            2 :         m_numVertices(0)
      97              : {
      98            2 : }
      99              : 
     100            0 : FaceDescriptor::FaceDescriptor(uint numVertices) :
     101            0 :         m_numVertices(numVertices)
     102              : {
     103            0 : }
     104              : 
     105            0 : FaceDescriptor::FaceDescriptor(const FaceDescriptor& fd)
     106              : {
     107            0 :         m_numVertices = fd.m_numVertices;
     108            0 :         for(uint i = 0; i < m_numVertices; ++i)
     109            0 :                 m_vertices[i] = fd.m_vertices[i];
     110            0 : }
     111              : 
     112            0 : FaceDescriptor& FaceDescriptor::operator = (const FaceDescriptor& fd)
     113              : {
     114            0 :         m_numVertices = fd.m_numVertices;
     115            0 :         for(uint i = 0; i < m_numVertices; ++i)
     116            0 :                 m_vertices[i] = fd.m_vertices[i];
     117              : 
     118            0 :         return *this;
     119              : }
     120              : 
     121              : 
     122              : ////////////////////////////////////////////////////////////////////////
     123              : //      implementation of Volume
     124            0 : int Volume::get_local_side_index(FaceVertices* f) const
     125              : {
     126            0 :         FaceDescriptor fd;
     127            0 :         for(size_t i = 0; i < num_sides(); ++i){
     128            0 :                 face_desc(i, fd);
     129            0 :                 if(CompareVertices(f, &fd))
     130            0 :                         return (int)i;
     131              :         }
     132              :         return -1;
     133              : }
     134              : 
     135            0 : void Volume::get_flipped_orientation(VolumeDescriptor& vdOut) const
     136              : {
     137            0 :         throw(int(0));
     138              :         vdOut = *this;
     139              : }
     140              : 
     141              : ////////////////////////////////////////////////////////////////////////
     142              : //      implementation of volume-descriptor
     143            0 : VolumeDescriptor::VolumeDescriptor()
     144              : {
     145            0 : }
     146              : 
     147            0 : VolumeDescriptor::VolumeDescriptor(uint numVertices)
     148              : {
     149              :         set_num_vertices(numVertices);
     150            0 : }
     151              : 
     152            0 : VolumeDescriptor::VolumeDescriptor(const VolumeDescriptor& vd)
     153              : {
     154            0 :         m_numVertices = vd.m_numVertices;
     155            0 :         for(uint i = 0; i < m_numVertices; ++i)
     156            0 :                 m_vertices[i] = vd.m_vertices[i];
     157            0 : }
     158              : 
     159            0 : VolumeDescriptor& VolumeDescriptor::operator = (const VolumeDescriptor& vd)
     160              : {
     161            0 :         m_numVertices = vd.m_numVertices;
     162            0 :         for(uint i = 0; i < m_numVertices; ++i)
     163            0 :                 m_vertices[i] = vd.m_vertices[i];
     164              : 
     165            0 :         return *this;
     166              : }
     167              : 
     168            0 : VolumeDescriptor& VolumeDescriptor::operator = (const VolumeVertices& vv)
     169              : {
     170            0 :         m_numVertices = vv.num_vertices();
     171            0 :         for(uint i = 0; i < m_numVertices; ++i)
     172            0 :                 m_vertices[i] = vv.vertex(i);
     173              : 
     174            0 :         return *this;
     175              : }
     176              : 
     177              : ////////////////////////////////////////////////////////////////////////
     178              : //      inline implementation of hash-keys
     179              : //      this methods are used by the template-specializations of hash_key<...>
     180              : ///     sums the squared hash-values of associated vertices.
     181            0 : static inline unsigned long HashKey(const EdgeVertices* key)
     182              : {
     183            0 :         unsigned long a = key->vertex(0)->get_hash_value();
     184            0 :         unsigned long b = key->vertex(1)->get_hash_value();
     185              : 
     186              :         //return (unsigned long)(a + b);
     187            0 :         return (unsigned long)(a * a + b * b);
     188              :         //if(b > a) return (unsigned long) ((a+b) * (b-a));
     189              :         //else return (unsigned long) ((a+b) * (a-b));
     190              : }
     191              : 
     192              : ///     sums the squared hash-values of associated vertices.
     193            0 : static inline unsigned long HashKey(const FaceVertices* key)
     194              : {
     195              :         unsigned long retVal = 0;
     196            0 :         size_t numVrts = key->num_vertices();
     197            0 :         FaceVertices::ConstVertexArray vrts = key->vertices();
     198              : 
     199            0 :         for(size_t i = 0; i < numVrts; ++i)
     200              :         {
     201            0 :                 unsigned long a = vrts[i]->get_hash_value();
     202            0 :                 retVal += (a*a);
     203              :         }
     204            0 :         return retVal;
     205              : }
     206              : 
     207              : ///     sums the squared hash-values of associated vertices.
     208            0 : static inline unsigned long HashKey(const VolumeVertices* key)
     209              : {
     210              :         unsigned long retVal = 0;
     211            0 :         size_t numVrts = key->num_vertices();
     212            0 :         VolumeVertices::ConstVertexArray vrts = key->vertices();
     213            0 :         for(size_t i = 0; i < numVrts; ++i)
     214              :         {
     215            0 :                 unsigned long a = vrts[i]->get_hash_value();
     216            0 :                 retVal += (a*a);
     217              :         }
     218              : 
     219            0 :         return retVal;
     220              : }
     221              : 
     222              : ////////////////////////////////////////////////////////////////////////
     223              : //      hash-funtions for vertices
     224              : //      returns the hash-value of the vertex.
     225            0 : size_t hash_key(Vertex* key)
     226              : {
     227            0 :         return (unsigned long)key->get_hash_value();
     228              : }
     229              : 
     230              : ////////////////////////////////////////////////////////////////////////
     231              : //      hash-funtions for edges
     232            0 : size_t hash_key(EdgeVertices* key)
     233              : {
     234            0 :         return HashKey(key);
     235              : }
     236              : 
     237            0 : size_t hash_key(const EdgeVertices* key)
     238              : {
     239            0 :         return HashKey(key);
     240              : }
     241              : 
     242            0 : size_t hash_key(Edge* key)
     243              : {
     244            0 :         return HashKey(key);
     245              : }
     246              : 
     247            0 : size_t hash_key(EdgeDescriptor* key)
     248              : {
     249            0 :         return HashKey(key);
     250              : }
     251              : 
     252              : ////////////////////////////////////////////////////////////////////////
     253              : //      hash-funtions for faces
     254            0 : size_t hash_key(FaceVertices* key)
     255              : {
     256            0 :         return HashKey(key);
     257              : }
     258              : 
     259            0 : size_t hash_key(const FaceVertices* key)
     260              : {
     261            0 :         return HashKey(key);
     262              : }
     263              : 
     264            0 : size_t hash_key(Face* key)
     265              : {
     266            0 :         return HashKey(key);
     267              : }
     268              : 
     269            0 : size_t hash_key(FaceDescriptor* key)
     270              : {
     271            0 :         return HashKey(key);
     272              : }
     273              : 
     274              : ////////////////////////////////////////////////////////////////////////
     275              : //      hash-funtions for volumes
     276            0 : size_t hash_key(VolumeVertices* key)
     277              : {
     278            0 :         return HashKey(key);
     279              : }
     280              : 
     281            0 : size_t hash_key(const VolumeVertices* key)
     282              : {
     283            0 :         return HashKey(key);
     284              : }
     285              : 
     286            0 : size_t hash_key(Volume* key)
     287              : {
     288            0 :         return HashKey(key);
     289              : }
     290              : 
     291            0 : size_t hash_key(VolumeDescriptor* key)
     292              : {
     293            0 :         return HashKey(key);
     294              : }
     295              : 
     296              : }//     end of namespace
        

Generated by: LCOV version 2.0-1