LCOV - code coverage report
Current view: top level - ugbase/lib_disc/local_finite_element - local_shape_function_set.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 34.5 % 29 10
Test Date: 2025-09-21 23:31:46 Functions: 12.5 % 305 38

            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__LOCAL_FINITE_ELEMENT__LOCAL_SHAPE_FUCNTION_SET__
      34              : #define __H__UG__LIB_DISC__LOCAL_FINITE_ELEMENT__LOCAL_SHAPE_FUCNTION_SET__
      35              : 
      36              : // extern libraries
      37              : #include <cassert>
      38              : #include <map>
      39              : 
      40              : // other ug4 modules
      41              : #include "common/math/ugmath.h"
      42              : 
      43              : // library intern headers
      44              : #include "local_finite_element_id.h"
      45              : #include "lib_disc/local_finite_element/local_dof_set.h"
      46              : 
      47              : namespace ug {
      48              : 
      49              : ////////////////////////////////////////////////////////////////////////////////
      50              : //      Interface for local shape function sets
      51              : ////////////////////////////////////////////////////////////////////////////////
      52              : 
      53              : /// \ingroup lib_disc_local_finite_elements
      54              : /// @{
      55              : 
      56              : /// virtual base class for local shape function sets
      57              : /**
      58              :  * This class is a base class for the supply of local shape functions on finite
      59              :  * elements. The class provides evaluation of the shape functions and the
      60              :  * gradients at arbitrary points in the interior of a reference element.
      61              :  *
      62              :  * \tparam      TDim    Reference Element Dimension
      63              :  * \tparam      TShape  type of Range of Shape Functions
      64              :  * \tparam      TGrad   type of gradient of shape functions
      65              :  */
      66              : template <   int TDim,
      67              :                         typename TShape = number,
      68              :                         typename TGrad = MathVector<TDim> >
      69            0 : class LocalShapeFunctionSet : public DimLocalDoFSet<TDim>
      70              : {
      71              :         public:
      72              :         ///     Dimension, where shape functions are defined
      73              :                 static const int dim = TDim;
      74              : 
      75              :         ///     Domain position type
      76              :                 typedef MathVector<dim> position_type;
      77              : 
      78              :         ///     Shape type
      79              :                 typedef TShape shape_type;
      80              : 
      81              :         ///     Gradient type
      82              :                 typedef TGrad grad_type;
      83              : 
      84              :         public:
      85              :         ///     returns if space constructs continuous functions
      86              :                 virtual bool continuous() const = 0;
      87              : 
      88              :         /// evaluates the shape function
      89              :         /**
      90              :          * This function returns the value of Shape Function i at
      91              :          * an element-local evaluation point.
      92              :          * \param[in]   i               number of DoF
      93              :          * \param[in]   x               Position on reference element (evaluation point)
      94              :          * \return shape function value at point
      95              :          */
      96              :                 virtual shape_type shape(size_t i, const MathVector<dim>& x) const = 0;
      97              : 
      98              :         /// evaluates the shape function
      99              :         /**
     100              :          * This function returns the value of Shape Function i at
     101              :          * an element-local evaluation point.
     102              :          * \param[out]  shape   the shape function
     103              :          * \param[in]   i               number of DoF
     104              :          * \param[in]   x               Position on reference element (evaluation point)
     105              :          */
     106              :                 virtual void shape(shape_type& shape, size_t i, const MathVector<dim>& x) const = 0;
     107              : 
     108              :         /// returns all shape functions evaluated at a point
     109              :         /**
     110              :          * This function returns the values of all Shape Functions at
     111              :          * an element-local evaluation point in an array.
     112              :          * \param[out]  vShape  Vector of Shapes
     113              :          * \param[in]   x               Position on reference element (evaluation point)
     114              :          */
     115              :         ///     \{
     116              :                 virtual void shapes(shape_type* vShape, const MathVector<dim>& x) const = 0;
     117              :                 virtual void shapes(std::vector<shape_type>& vShape, const MathVector<dim>& x) const = 0;
     118              :         ///     \}
     119              : 
     120              :         /// returns all shape functions evaluated at several point
     121              :         /**
     122              :          * This function returns the values of all Shape Functions at
     123              :          * several element-local evaluation point in an array.
     124              :          * \param[out]  vvShape Vector of Shapes
     125              :          * \param[in]   vLocPos Vector of Position on reference element
     126              :          */
     127              :                 virtual void shapes(std::vector<std::vector<shape_type> >& vvShape,
     128              :                                     const std::vector<MathVector<dim> >& vLocPos) const = 0;
     129              : 
     130              :         /// evaluates the gradient of the shape function
     131              :         /** This function returns the gradient of Shape Function i at
     132              :          * an element-local evaluation point.
     133              :          * \param[in]   i               number of DoF
     134              :          * \param[in]   x               Position on reference element (evaluation point)
     135              :          * \return gradient at point
     136              :          */
     137              :                 virtual void grad(grad_type& g, size_t i, const MathVector<dim>& x) const = 0;
     138              : 
     139              :         /// returns all gradients evaluated at a point
     140              :         /**
     141              :          * This function returns the gradients of all Shape Functions at
     142              :          * an element-local evaluation point in an array.
     143              :          * \param[out]  vGrad   Vector of gradients
     144              :          * \param[in]   x               Position on reference element (evaluation point)
     145              :          */
     146              :         ///     \{
     147              :                 virtual void grads(grad_type* vGrad, const MathVector<dim>& x) const = 0;
     148              :                 virtual void grads(std::vector<grad_type>& vGrad, const MathVector<dim>& x) const = 0;
     149              :         ///     \}
     150              : 
     151              :         /// returns all gradients evaluated at a several points
     152              :         /**
     153              :          * This function returns the gradients of all Shape Functions at
     154              :          * several element-local evaluation point in an array.
     155              :          * \param[out]  vvGrad  Vector of gradients
     156              :          * \param[in]   vLocPos Vector of Position on reference element
     157              :          */
     158              :                 virtual void grads(std::vector<std::vector<grad_type> >& vvGrad,
     159              :                                    const std::vector<MathVector<dim> >& vLocPos) const = 0;
     160              : 
     161              :         ///     virtual destructor
     162              :                 virtual ~LocalShapeFunctionSet() {};
     163              : };
     164              : 
     165              : /// @}
     166              : 
     167              : ////////////////////////////////////////////////////////////////////////////////
     168              : //      Common base class for local shape function sets to ease implementation
     169              : ////////////////////////////////////////////////////////////////////////////////
     170              : 
     171              : /// static interface for trial spaces
     172              : template <typename TImpl, int TDim,
     173              :                   typename TShape = number,
     174              :                   typename TGrad = MathVector<TDim> >
     175              : class BaseLSFS
     176              : {
     177              :         public:
     178              :         ///     type of implementation
     179              :                 typedef TImpl ImplType;
     180              : 
     181              :         ///     dimension of reference element
     182              :                 static const int dim = TDim;
     183              : 
     184              :         ///     Shape type
     185              :                 typedef TShape shape_type;
     186              : 
     187              :         ///     Gradient type
     188              :                 typedef TGrad grad_type;
     189              : 
     190              :         //////////////////////////////////////////
     191              :         //      methods implemented by derived class
     192              :         //////////////////////////////////////////
     193              : 
     194              :         public:
     195              :         ///     \copydoc ug::LocalShapeFunctionSet::shape()
     196              :                 inline shape_type shape(size_t i, const MathVector<dim>& x) const
     197              :                 {
     198          200 :                         return getImpl().shape(i, x);
     199              :                 }
     200              : 
     201              :         ///     \copydoc ug::LocalShapeFunctionSet::grad()
     202              :                 inline void grad(grad_type& g, size_t i, const MathVector<dim>& x) const
     203              :                 {
     204         4040 :                          getImpl().grad(g, i, x); return;
     205              :                 }
     206              : 
     207              :         //////////////////////////////////////////
     208              :         //      methods generated generically
     209              :         //////////////////////////////////////////
     210              : 
     211              :         public:
     212              :         ///     \copydoc ug::LocalShapeFunctionSet::shape()
     213            0 :                 inline void shape(shape_type& sh, size_t i, const MathVector<dim>& x) const
     214              :                 {
     215            0 :                         sh = shape(i, x);
     216              :                 }
     217              : 
     218              : 
     219              :         ///     \copydoc ug::LocalShapeFunctionSet::shapes()
     220          760 :                 inline void shapes(shape_type* vShape, const MathVector<dim>& x) const
     221              :                 {
     222        11120 :                         for(size_t sh = 0; sh < getImpl().num_sh(); ++sh)
     223        10720 :                                 vShape[sh] = shape(sh, x);
     224          760 :                 }
     225              : 
     226              :         ///     \copydoc ug::LocalShapeFunctionSet::shapes()
     227            0 :                 inline void shapes(std::vector<shape_type>& vShape, const MathVector<dim>& x) const
     228              :                 {
     229            0 :                         vShape.resize(getImpl().num_sh()); shapes(&vShape[0], x);
     230            0 :                 }
     231              : 
     232              :         ///     \copydoc ug::LocalShapeFunctionSet::shapes()
     233            0 :                 inline void shapes(std::vector<std::vector<shape_type> >& vvShape,
     234              :                                     const std::vector<MathVector<dim> >& vLocPos) const
     235              :                 {
     236            0 :                         vvShape.resize(vLocPos.size());
     237            0 :                         for(size_t ip = 0; ip < vLocPos.size(); ++ip)
     238            0 :                                 shapes(vvShape[ip], vLocPos[ip]);
     239            0 :                 }
     240              : 
     241              :         ///     \copydoc ug::LocalShapeFunctionSet::grads()
     242          380 :                 inline void grads(grad_type* vGrad, const MathVector<dim>& x) const
     243              :                 {
     244         5560 :                         for(size_t sh = 0; sh < getImpl().num_sh(); ++sh)
     245         5180 :                                 grad(vGrad[sh], sh, x);
     246          380 :                 }
     247              : 
     248              :         ///     \copydoc ug::LocalShapeFunctionSet::grads()
     249            0 :                 inline void grads(std::vector<grad_type>& vGrad, const MathVector<dim>& x) const
     250              :                 {
     251            0 :                         vGrad.resize(getImpl().num_sh()); grads(&vGrad[0], x);
     252            0 :                 }
     253              : 
     254              :         ///     \copydoc ug::LocalShapeFunctionSet::grads()
     255            0 :                 inline void grads(std::vector<std::vector<grad_type> >& vvGrad,
     256              :                                    const std::vector<MathVector<dim> >& vLocPos) const
     257              :                 {
     258            0 :                         vvGrad.resize(vLocPos.size());
     259            0 :                         for(size_t ip = 0; ip < vLocPos.size(); ++ip)
     260            0 :                                 grads(vvGrad[ip], vLocPos[ip]);
     261            0 :                 }
     262              : 
     263              :         protected:
     264              :         ///     access to implementation
     265              :                 ImplType& getImpl() {return static_cast<ImplType&>(*this);}
     266              : 
     267              :         ///     const access to implementation
     268              :                 const ImplType& getImpl() const {return static_cast<const ImplType&>(*this);}
     269              : 
     270              : };
     271              : 
     272              : } // namespace ug
     273              : 
     274              : #endif /* __H__UG__LIB_DISC__LOCAL_FINITE_ELEMENT__LOCAL_SHAPE_FUCNTION_SET__ */
        

Generated by: LCOV version 2.0-1