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

            Line data    Source code
       1              : /*
       2              :  * Copyright (c) 2016:  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_geometry
      34              : #define __H__UG_geometry
      35              : 
      36              : #include "common/util/smart_pointer.h"
      37              : #include "common/math/ugmath_types.h"
      38              : #include "lib_grid/algorithms/geom_obj_util/geom_obj_util.h"
      39              : #include "lib_grid/grid/grid.h"
      40              : 
      41              : namespace ug{
      42              : 
      43              : ///     provides a grid and access to the coordinates of the vertices
      44              : /**     The class serves as a base class for wrappers around grid coordinates. It
      45              :  * allows for the implementation of fixed-dim classes which can operate on
      46              :  * coordinates arbitrary dimension.
      47              :  *
      48              :  * Vertex coordinates of the fixed dimension 'dim' can be accessed through the
      49              :  * method 'pos' and can be set through the method 'set_pos'.
      50              :  *
      51              :  * For code that has to operate on the original position attachment, the following
      52              :  * methods are provided: The dimension of the original 'attached'
      53              :  * coordinates can be accessed through 'position_attachment_dim'. The attachement
      54              :  * for those original coordinates can be accessed through 'position_attachment'.
      55              :  *
      56              :  * If 'attachmentDim == position_attachment_dim()', then the return value of
      57              :  * 'position_attachment' must always be castable to
      58              :  * 'Attachment<MathVector<attachmentDim> >'.
      59              :  *
      60              :  * \sa Geometry
      61              :  */
      62              : template <int dim>
      63              : class IGeometry {
      64              : public:
      65              :         typedef MathVector<dim>   vector_t;
      66              : 
      67            0 :         IGeometry (Grid& g) :
      68            0 :                 m_grid(g)
      69              :         {}
      70              : 
      71              :         virtual ~IGeometry ()   {}
      72              : 
      73              :         virtual vector_t pos (Vertex* vrt) const = 0;
      74              :         virtual void set_pos (Vertex* vrt, const vector_t& p) = 0;
      75              : 
      76            0 :         Grid& grid() const  {return m_grid;}
      77              : 
      78              :         virtual int position_attachment_dim() const = 0;
      79              :         virtual const IAttachment& position_attachment() const = 0;
      80              : 
      81              :         virtual vector_t element_center(Vertex* e) const        = 0;
      82              :         virtual vector_t element_center(Edge* e) const          = 0;
      83              :         virtual vector_t element_center(Face* e) const          = 0;
      84              :         virtual vector_t element_center(Volume* e) const        = 0;
      85              : 
      86              : private:
      87              :         Grid&       m_grid;
      88              : };
      89              : 
      90              : 
      91              : typedef IGeometry<1> IGeometry1d;
      92              : typedef IGeometry<2> IGeometry2d;
      93              : typedef IGeometry<3> IGeometry3d;
      94              : 
      95              : typedef SmartPtr<IGeometry1d>     SPIGeometry1d;
      96              : typedef SmartPtr<IGeometry2d>     SPIGeometry2d;
      97              : typedef SmartPtr<IGeometry3d>     SPIGeometry3d;
      98              : 
      99              : 
     100              : ///     provides a grid and access to the coordinates of the vertices
     101              : /**     The dimension of the output coordinates ('dim') may differ from the
     102              :  * dimension of the coordinates which are actually attached to the grid ('attachedDim').
     103              :  */
     104              : template <int dim, int attachmentDim>
     105              : class Geometry : public IGeometry<dim> {
     106              : public:
     107              :         typedef IGeometry<dim>                                    base_t;
     108              :         typedef typename base_t::vector_t               vector_t;
     109              :         typedef MathVector<attachmentDim>         attached_vector_t;
     110              :         typedef Attachment<attached_vector_t>     position_attachment_t;
     111              : 
     112            0 :         Geometry (Grid& g, position_attachment_t a) :
     113              :                 base_t (g),
     114            0 :                 m_aPos(a)
     115              :         {
     116            0 :                 UG_COND_THROW (!g.has_vertex_attachment(a),
     117              :                                            "the specified attachment is not attached to the "
     118              :                                            "vertices of the specified grid.");
     119              :                 m_aaPos.access(g, a);
     120            0 :         }
     121              : 
     122            0 :         virtual vector_t pos (Vertex* vrt) const
     123              :         {
     124            0 :                 return vector_t::from(m_aaPos[vrt]);
     125              :         }
     126              : 
     127            0 :         virtual void set_pos (Vertex* vrt, const vector_t& p)
     128              :         {
     129              :                 m_aaPos[vrt] = attached_vector_t::from(p);
     130            0 :         }
     131              : 
     132            0 :         virtual int position_attachment_dim () const    {return attachmentDim;}
     133            0 :         const IAttachment& position_attachment () const     {return m_aPos;}
     134              : 
     135              : 
     136            0 :         virtual vector_t element_center (Vertex* e) const {
     137            0 :                 return vector_t::from(m_aaPos[e]);
     138              :         }
     139              : 
     140            0 :         virtual vector_t element_center (Edge* e) const {
     141            0 :                 return vector_t::from(CalculateCenter(e, m_aaPos));
     142              :         }
     143              : 
     144            0 :         virtual vector_t element_center (Face* e) const {
     145            0 :                 return vector_t::from(CalculateCenter(e, m_aaPos));
     146              :         }
     147              : 
     148            0 :         virtual vector_t element_center (Volume* e) const {
     149            0 :                 return vector_t::from(CalculateCenter(e, m_aaPos));
     150              :         }
     151              : 
     152              : 
     153              : private:
     154              :         Grid::VertexAttachmentAccessor<position_attachment_t>     m_aaPos;
     155              :         position_attachment_t                                                                   m_aPos;
     156              : };
     157              : 
     158              : 
     159              : 
     160              : ///     Utility method to construct an IGeometry3d for a given grid and position attachment
     161              : template <class TAPos>
     162              : SPIGeometry3d
     163            0 : MakeGeometry3d (Grid& grid, TAPos aPos)
     164              : {
     165            0 :         return make_sp(new Geometry<3, TAPos::ValueType::Size>(grid, aPos));
     166              : }
     167              : }//     end of namespace
     168              : 
     169              : #endif  //__H__UG_geometry
        

Generated by: LCOV version 2.0-1