LCOV - code coverage report
Current view: top level - ugbase/lib_disc - domain_util_impl.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 % 80 0

            Line data    Source code
       1              : /*
       2              :  * Copyright (c) 2010-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_DISC__DOMAIN_UTIL_GENERAL_IMPL__
      34              : #define __H__UG__LIB_DISC__DOMAIN_UTIL_GENERAL_IMPL__
      35              : 
      36              : #include "domain_util.h"
      37              : 
      38              : #include <string>
      39              : #include <sstream>
      40              : 
      41              : #include "lib_disc/reference_element/reference_element.h"
      42              : 
      43              : namespace ug{
      44              : 
      45              : ////////////////////////////////////////////////////////////////////////////////
      46              : ////////////////////////////////////////////////////////////////////////////////
      47              : // CollectCornerCoordinates
      48              : ////////////////////////////////////////////////////////////////////////////////
      49              : ////////////////////////////////////////////////////////////////////////////////
      50              : 
      51              : //      returns the corner coordinates of a geometric object
      52              : template <typename TElem, typename TAAPos>
      53            0 : void CollectCornerCoordinates(  std::vector<typename TAAPos::ValueType>& vCornerCoordsOut,
      54              :                                                                 TElem* elem, const TAAPos& aaPos, bool clearContainer)
      55              : {
      56            0 :         if(clearContainer)
      57              :                 vCornerCoordsOut.clear();
      58              : 
      59              :         // number of vertices of element
      60              :         const size_t numVertices = NumVertices(elem);
      61              : 
      62              :         // loop vertices
      63            0 :         for(size_t i = 0; i < numVertices; ++i)
      64              :         {
      65              :                 // get element
      66              :                 Vertex* vert = GetVertex(elem, i);
      67              : 
      68              :                 // write corner coordinates
      69            0 :                 vCornerCoordsOut.push_back(aaPos[vert]);
      70              :         }
      71            0 : }
      72              : 
      73              : //      returns the corner coordinates of a geometric object
      74              : template <typename TElem, typename TAAPos>
      75              : void CollectCornerCoordinates(  std::vector<typename TAAPos::ValueType>& vCornerCoordsOut,
      76              :                                                                 const TElem& elem, const TAAPos& aaPos, bool clearContainer)
      77              : {
      78              : //      cast constness away
      79              :         TElem* pElem = const_cast<TElem*>(&elem);
      80              : 
      81              : //      forward
      82            0 :         return CollectCornerCoordinates(vCornerCoordsOut, pElem, aaPos, clearContainer);
      83              : }
      84              : 
      85              : ///     returns the corner coordinates of a geometric object
      86              : template <typename TElem, typename TDomain>
      87              : void CollectCornerCoordinates(  std::vector<typename TDomain::position_type>& vCornerCoordsOut,
      88              :                                                                 const TElem& elem, const TDomain& domain, bool clearContainer)
      89              : {
      90              :         // get position accessor
      91              :         const typename TDomain::position_accessor_type& aaPos = domain.position_accessor();
      92              : 
      93            0 :         CollectCornerCoordinates(vCornerCoordsOut, elem, aaPos, clearContainer);
      94            0 : }
      95              : 
      96              : ///     returns the corner coordinates of a geometric object
      97              : template <typename TDomain>
      98            0 : void CollectCornerCoordinates(int base_object_id,
      99              :                         std::vector<typename TDomain::position_type>& vCornerCoordsOut,
     100              :                         GridObject& elem, const TDomain& domain, bool clearContainer)
     101              : {
     102            0 :         switch(base_object_id)
     103              :         {
     104            0 :                 case VERTEX: CollectCornerCoordinates<Vertex, TDomain>(vCornerCoordsOut, *dynamic_cast< Vertex*>(&elem), domain, clearContainer); return;
     105            0 :                 case EDGE: CollectCornerCoordinates<Edge, TDomain>(vCornerCoordsOut, *dynamic_cast< Edge*>(&elem), domain, clearContainer); return;
     106            0 :                 case FACE: CollectCornerCoordinates<Face, TDomain>(vCornerCoordsOut, *dynamic_cast< Face*>(&elem), domain, clearContainer); return;
     107            0 :                 case VOLUME: CollectCornerCoordinates<Volume, TDomain>(vCornerCoordsOut, *dynamic_cast< Volume*>(&elem), domain, clearContainer); return;
     108            0 :                 default: UG_THROW("CollectCornerCoordinates, base_object_id " << base_object_id << "unknown.");
     109              :         }
     110              : }
     111              : 
     112              : ///     returns the corner coordinates of a geometric object
     113              : template <typename TElem, typename TDomain>
     114            0 : void FillCornerCoordinates(     typename TDomain::position_type vCornerCoordsOut[],
     115              :                                 const TElem& elem, const TDomain& domain)
     116              : {
     117              :         // get position accessor
     118              :         const typename TDomain::position_accessor_type& aaPos = domain.position_accessor();
     119              : 
     120            0 :         const Vertex* const* vVertex = const_cast<TElem*>(&elem)->vertices();
     121              : 
     122              :         // write corner coordinates
     123            0 :         for(size_t i = 0; i < TElem::NUM_VERTICES; ++i)
     124            0 :                 vCornerCoordsOut[i] = aaPos[vVertex[i]];
     125            0 : }
     126              : 
     127              : 
     128              : ///     returns the coordinates of a vertex (specialization)
     129              : template <typename TDomain>
     130              : void FillCornerCoordinates(     typename TDomain::position_type vCornerCoordsOut[],
     131              :                                 const RegularVertex& vtx, const TDomain& domain)
     132              : {
     133              :         // get position accessor
     134              :         const typename TDomain::position_accessor_type& aaPos = domain.position_accessor();
     135              : 
     136              :         // write vertex coordinates
     137              :         vCornerCoordsOut[0] = aaPos[&vtx];
     138              : }
     139              : 
     140              : ////////////////////////////////////////////////////////////////////////
     141              : ///     returns the size of a geometric object
     142              : template <typename TElem, typename TPosition>
     143              : number ElementSize(const TElem& elem, const Grid::VertexAttachmentAccessor<Attachment<TPosition> >& aaPos)
     144              : {
     145              :         // corner coords
     146              :         std::vector<TPosition> vCornerCoords;
     147              : 
     148              :         // load corner coords
     149              :         CollectCornerCoordinates(vCornerCoords, elem, aaPos);
     150              : 
     151              :         // get reference element type
     152              :         typedef typename reference_element_traits<TElem>::reference_element_type TRefElem;
     153              : 
     154              :         // dimension of Positions
     155              :         static const int dim = TPosition::Size;
     156              : 
     157              :         // return Element Size
     158              :         return ElementSize<TRefElem, dim>(&vCornerCoords[0]);
     159              : }
     160              : 
     161              : ///     returns the size of a geometric object
     162              : template <typename TElem, typename TDomain>
     163              : number ElementSize(const TElem& elem, const TDomain& domain)
     164              : {
     165              :         // get position accessor
     166              :         const typename TDomain::position_accessor_type& aaPos = domain.position_accessor();
     167              : 
     168              :         return ElementSize(elem, aaPos);
     169              : }
     170              : 
     171              : ////////////////////////////////////////////////////////////////////////
     172              : //      ElementDiameter
     173              : ////////////////////////////////////////////////////////////////////////
     174              : 
     175              : template <typename TElem, typename TDomain>
     176              : number ElementDiameterSq(TElem& elem, TDomain& domain)
     177              : {
     178              :         return ElementDiameterSq(*domain.grid(), domain.position_accessor(), &elem);
     179              : }
     180              : 
     181              : template <typename TElem, typename TDomain>
     182              : number ElementDiameter(TElem& elem, TDomain& domain)
     183              : {
     184              :         return ElementDiameter(*domain.grid(), domain.position_accessor(), &elem);
     185              : }
     186              : 
     187              : } // end namespace ug
     188              : 
     189              : #endif /* __H__UG__LIB_DISC__DOMAIN_UTIL_GENERAL_IMPL__ */
        

Generated by: LCOV version 2.0-1