LCOV - code coverage report
Current view: top level - ugbase/lib_grid/grid_objects - grid_objects_0d.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 7.9 % 38 3
Test Date: 2025-09-21 23:31:46 Functions: 14.3 % 14 2

            Line data    Source code
       1              : /*
       2              :  * Copyright (c) 2011-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__grid_objects_0d__
      34              : #define __H__UG__grid_objects_0d__
      35              : 
      36              : #include "../grid/grid.h"
      37              : #include "common/math/ugmath.h"
      38              : #include "common/assert.h"
      39              : 
      40              : namespace ug
      41              : {
      42              : ////////////////////////////////////////////////////////////////////////
      43              : ///     These numbers define where in the vertex-section-container a vertex will be stored.
      44              : /**     The order of the constants must not be changed! Algorithms may exist that rely on it.*/
      45              : enum VertexContainerSections
      46              : {
      47              :         CSVRT_NONE = -1,
      48              :         CSVRT_REGULAR_VERTEX = 0,
      49              :         CSVRT_CONSTRAINED_VERTEX = 1
      50              : };
      51              : 
      52              : 
      53              : ////////////////////////////////////////////////////////////////////////
      54              : //      RegularVertex
      55              : ///     A basic vertex-type
      56              : /**
      57              :  * This type represents the most commonly used vertex.
      58              :  *
      59              :  * \ingroup lib_grid_grid_objects
      60              :  */
      61            3 : class UG_API RegularVertex : public Vertex
      62              : {
      63              :         friend class Grid;
      64              :         public:
      65              :                 inline static bool type_match(GridObject* pObj) {return dynamic_cast<RegularVertex*>(pObj) != NULL;}
      66              : 
      67            3 :                 virtual ~RegularVertex()        {}
      68              : 
      69            0 :                 virtual GridObject* create_empty_instance() const       {return new RegularVertex;}
      70              : 
      71            6 :                 virtual int container_section() const   {return CSVRT_REGULAR_VERTEX;}
      72            0 :                 virtual ReferenceObjectID reference_object_id() const {return ROID_VERTEX;}
      73              : };
      74              : 
      75              : template <>
      76              : class geometry_traits<RegularVertex>
      77              : {
      78              :         public:
      79              :                 typedef GenericGridObjectIterator<RegularVertex*, VertexIterator>                 iterator;
      80              :                 typedef ConstGenericGridObjectIterator<RegularVertex*, VertexIterator,
      81              :                                                                                                                 ConstVertexIterator> const_iterator;
      82              : 
      83              :                 typedef Vertex  grid_base_object;
      84              : 
      85              :                 enum
      86              :                 {
      87              :                         CONTAINER_SECTION = CSVRT_REGULAR_VERTEX,
      88              :                         BASE_OBJECT_ID = VERTEX
      89              :                 };
      90              : 
      91              :                 static const ReferenceObjectID REFERENCE_OBJECT_ID = ROID_VERTEX;
      92              : };
      93              : 
      94              : typedef geometry_traits<RegularVertex>::iterator          RegularVertexIterator;
      95              : typedef geometry_traits<RegularVertex>::const_iterator    ConstRegularVertexIterator;
      96              : 
      97              : 
      98              : 
      99              : ////////////////////////////////////////////////////////////////////////
     100              : //      ConstrainedVertex
     101              : ///     A vertex appearing on edges or faces.
     102              : /**
     103              :  * ConstrainedVertices appear during hanging-vertex-refinement.
     104              :  * They should be treated with care, since they are often referenced
     105              :  * by other elements, as e.g. by a ConstrainingEdge.
     106              :  *
     107              :  * \ingroup lib_grid_grid_objects
     108              :  */
     109              : class UG_API ConstrainedVertex : public Vertex
     110              : {
     111              :         friend class Grid;
     112              :         public:
     113              :                 inline static bool type_match(GridObject* pObj) {return dynamic_cast<ConstrainedVertex*>(pObj) != NULL;}
     114              : 
     115            0 :                 ConstrainedVertex()     : m_constrainingObj(NULL), m_parentBaseObjectId(-1)     {}
     116            0 :                 virtual ~ConstrainedVertex()
     117            0 :                 {
     118            0 :                         if(m_constrainingObj)
     119            0 :                                 m_constrainingObj->remove_constraint_link(this);
     120            0 :                 }
     121              : 
     122            0 :                 virtual GridObject* create_empty_instance() const       {return new ConstrainedVertex;}
     123              : 
     124            0 :                 virtual int container_section() const   {return CSVRT_CONSTRAINED_VERTEX;}
     125            0 :                 virtual ReferenceObjectID reference_object_id() const {return ROID_VERTEX;}
     126              : 
     127            0 :                 virtual bool is_constrained() const                     {return true;}
     128              : 
     129            0 :                 virtual void remove_constraint_link(const Edge* e)
     130              :                 {
     131            0 :                         if(m_constrainingObj == static_cast<const GridObject*>(e)){
     132            0 :                                 m_constrainingObj = NULL;
     133              :                         }
     134            0 :                 }
     135              : 
     136            0 :                 virtual void remove_constraint_link(const Face* f)
     137              :                 {
     138            0 :                         if(m_constrainingObj == static_cast<const GridObject*>(f)){
     139            0 :                                 m_constrainingObj = NULL;
     140              :                         }
     141            0 :                 }
     142              : 
     143              :                 inline void set_constraining_object(GridObject* constrObj)
     144              :                 {
     145            0 :                         m_constrainingObj = constrObj;
     146            0 :                         if(constrObj)
     147            0 :                                 m_parentBaseObjectId = constrObj->base_object_id();
     148              :                 }
     149              : 
     150            0 :                 inline GridObject* get_constraining_object()    {return m_constrainingObj;}
     151            0 :                 inline int get_parent_base_object_id()                          {return m_parentBaseObjectId;}
     152            0 :                 inline void set_parent_base_object_id(int id)
     153              :                 {
     154            0 :                         if((m_parentBaseObjectId != -1) && (m_parentBaseObjectId != id)){
     155            0 :                                 UG_THROW("Bad parent base object id specified! The given id"
     156              :                                                 " has to match the id of the constraining object if that"
     157              :                                                 " is present. Call this method only, if no constraining"
     158              :                                                 " object has been set!");
     159              :                         }
     160            0 :                         m_parentBaseObjectId = id;
     161            0 :                 }
     162              : 
     163              :                 inline const vector2& get_local_coordinates() const {return m_localCoord;}
     164            0 :                 inline number get_local_coordinate_1() const            {return m_localCoord.x();}
     165            0 :                 inline number get_local_coordinate_2() const            {return m_localCoord.y();}
     166              : 
     167            0 :                 inline void set_local_coordinates(number x, number y)           {m_localCoord.x() = x; m_localCoord.y() = y;}
     168              :                 inline void set_local_coordinates(const vector2& coords)    {m_localCoord = coords;}
     169            0 :                 inline void set_local_coordinate_1(number coord)                        {m_localCoord.x() = coord;}
     170            0 :                 inline void set_local_coordinate_2(number coord)                        {m_localCoord.y() = coord;}
     171              : 
     172              :         protected:
     173              :                 GridObject*     m_constrainingObj;
     174              :                 vector2         m_localCoord;
     175              :                 int                     m_parentBaseObjectId;
     176              : };
     177              : 
     178              : template <>
     179              : class geometry_traits<ConstrainedVertex>
     180              : {
     181              :         public:
     182              :                 typedef GenericGridObjectIterator<ConstrainedVertex*, VertexIterator>                     iterator;
     183              :                 typedef ConstGenericGridObjectIterator<ConstrainedVertex*, VertexIterator,
     184              :                                                                                                                                 ConstVertexIterator> const_iterator;
     185              : 
     186              :                 typedef Vertex  grid_base_object;
     187              : 
     188              :                 enum
     189              :                 {
     190              :                         CONTAINER_SECTION = CSVRT_CONSTRAINED_VERTEX,
     191              :                         BASE_OBJECT_ID = VERTEX
     192              :                 };
     193              :                 static const ReferenceObjectID REFERENCE_OBJECT_ID = ROID_VERTEX;
     194              : };
     195              : 
     196              : typedef geometry_traits<ConstrainedVertex>::iterator              ConstrainedVertexIterator;
     197              : typedef geometry_traits<ConstrainedVertex>::const_iterator        ConstConstrainedVertexIterator;
     198              : 
     199              : 
     200              : }//     end of namespace
     201              : 
     202              : #endif
        

Generated by: LCOV version 2.0-1