LCOV - code coverage report
Current view: top level - ugbase/lib_disc/local_finite_element/nedelec - nedelec.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 58 0
Test Date: 2025-09-21 23:31:46 Functions: 0.0 % 8 0

            Line data    Source code
       1              : /*
       2              :  * Copyright (c) 2013-2015:  G-CSC, Goethe University Frankfurt
       3              :  * Author: Dmitry Logashenko
       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              : /*
      34              :  * This file contains implementations of the local shape function set for
      35              :  * the so-called Nedelec (or Whitney-1) elements.
      36              :  */
      37              : #ifndef __H__UG__LIB_DISC__LOCAL_SHAPE_FUNCTION_SET__NEDELEC__NEDELEC__
      38              : #define __H__UG__LIB_DISC__LOCAL_SHAPE_FUNCTION_SET__NEDELEC__NEDELEC__
      39              : 
      40              : #include "common/util/provider.h"
      41              : #include "../local_dof_set.h"
      42              : #include "lib_disc/common/multi_index.h"
      43              : 
      44              : namespace ug{
      45              : 
      46              : ///////////////////////////////////////////////////////////////////////////////
      47              : // Nedelec Set
      48              : ///////////////////////////////////////////////////////////////////////////////
      49              : 
      50              : /// Nedelec, i.e. the edge local dof set
      51              : template <typename TRefElem>
      52              : class NedelecLDS
      53              : {
      54              :         protected:
      55              :         ///     dimension of reference element
      56              :                 static const int refDim = TRefElem::dim;
      57              : 
      58              :         public:
      59              :         ///     constructor
      60            0 :                 NedelecLDS()
      61              :                 {
      62              :                         if(refDim < 2)
      63              :                         {
      64              :                         //      No dofs if the dimension is less than 2:
      65              :                                 nsh = 0;
      66              :                                 m_vLocalDoF.clear();
      67              :                                 return;
      68              :                         }
      69              : 
      70            0 :                         const TRefElem& rRefElem = Provider<TRefElem>::get();
      71              : 
      72            0 :                         nsh = rRefElem.num(1); // number of the edges
      73              :                 //      set local DoFs (all located at the edges)
      74            0 :                         m_vLocalDoF.resize(nsh);
      75            0 :                         for(size_t i = 0; i < nsh; ++i)
      76            0 :                                 m_vLocalDoF[i] = LocalDoF(1, i, 0);
      77            0 :                 }
      78              : 
      79              :         ///     returns the type of reference element
      80              :                 ReferenceObjectID roid() const {return TRefElem::REFERENCE_OBJECT_ID;}
      81              : 
      82              :         ///     returns the total number of DoFs on the finite element
      83              :                 size_t num_dof() const {return nsh;};
      84              : 
      85              :         ///     returns the number of DoFs on a sub-geometric object type
      86              :                 size_t num_dof(ReferenceObjectID type) const
      87              :                 {
      88            0 :                         if(ReferenceElementDimension(type) == 1) return 1;
      89            0 :                         else return 0;
      90              :                 }
      91              : 
      92              :         ///     returns the dof storage
      93              :                 const LocalDoF& local_dof(size_t dof) const {return m_vLocalDoF[dof];}
      94              : 
      95              :         ///     returns if the local dof position are exact
      96              :                 bool exact_position_available() const {return true;};
      97              : 
      98              :         protected:
      99              :         ///     number of shapes (== number of edges)
     100              :                 size_t nsh;
     101              : 
     102              :         ///     association to elements
     103              :                 std::vector<LocalDoF> m_vLocalDoF;
     104              : };
     105              : 
     106              : /**
     107              :  * Nedelec (or Whitney-1) base function set for a general element:
     108              :  * Not implemented, so this class implements error messages only.
     109              :  * For the Nedelec base functions for triangles and tetrahedra cf. the
     110              :  * specializations below.
     111              :  */
     112              : template <typename TRefElement>
     113              : class NedelecLSFS;
     114              : 
     115              : /// Nedelec (or Whitney-1) base function set for triangles
     116              : template <>
     117              : class NedelecLSFS<ReferenceTriangle>
     118              : : public NedelecLDS<ReferenceTriangle>,
     119              :   public
     120              :         BaseLSFS
     121              :                 <
     122              :                         NedelecLSFS<ReferenceTriangle>,
     123              :                         ReferenceTriangle::dim, ///< dimensionality of the element
     124              :                         MathVector<ReferenceTriangle::dim>, ///< return type of the shape functions
     125              :                         MathMatrix<ReferenceTriangle::dim, ReferenceTriangle::dim> ///< return type of the gradients
     126              :                 >
     127              : {
     128              :         public:
     129              :         ///     Reference Element type
     130              :                 typedef ReferenceTriangle reference_element_type;
     131              : 
     132              :         ///     Order of Shape functions
     133              :                 static const size_t order = 1;
     134              : 
     135              :         ///     Dimension, where shape functions are defined
     136              :                 static const int dim = reference_element_type::dim;
     137              : 
     138              :         private:
     139              :         ///     Base class
     140              :                 typedef BaseLSFS<NedelecLSFS<reference_element_type>, dim, MathVector<dim>,  MathMatrix<dim,dim> > base_type;
     141              : 
     142              :         public:
     143              :         ///     Shape type
     144              :                 typedef base_type::shape_type shape_type;
     145              : 
     146              :         ///     Gradient type
     147              :                 typedef base_type::grad_type grad_type;
     148              : 
     149              :         protected:
     150              :         ///     number of shapes
     151              :                 static const size_t nsh = reference_element_type::numEdges;
     152              : 
     153              :         public:
     154              :         ///     Constructor
     155            0 :                 NedelecLSFS() {};
     156              : 
     157              :         ///     \copydoc ug::LocalShapeFunctionSet::continuous()
     158              :                 inline bool continuous() const {return false;}
     159              : 
     160              :         ///     \copydoc ug::LocalShapeFunctionSet::num_sh()
     161              :                 inline size_t num_sh() const {return nsh;}
     162              : 
     163              :         ///     \copydoc ug::LocalShapeFunctionSet::position()
     164            0 :                 inline bool position(size_t i, MathVector<dim>& pos) const
     165              :                 {
     166            0 :                         switch(i)
     167              :                         {
     168            0 :                                 case 0: pos[0] = 0.5;
     169            0 :                                                 pos[1] = 0.0;
     170            0 :                                                 return true;
     171            0 :                                 case 1: pos[0] = 0.5;
     172            0 :                                                 pos[1] = 0.5;
     173            0 :                                                 return true;
     174            0 :                                 case 2: pos[0] = 0.0;
     175            0 :                                                 pos[1] = 0.5;
     176            0 :                                                 return true;
     177            0 :                                 default: UG_THROW("NedelecLSFS: shape function "<<i<<
     178              :                                                                         " not found. Only "<<nsh<<" shapes present.");
     179              :                         }
     180              :                 }
     181              : 
     182              :         ///     \copydoc ug::LocalShapeFunctionSet::shape()
     183            0 :                 inline MathVector<dim> shape(const size_t i, const MathVector<dim>& x) const
     184              :                 {
     185            0 :                         UG_THROW ("NedelecLSFS: Nedelec shapes cannot be computed in the reference space.");
     186              :                 }
     187              : 
     188              :         ///     \copydoc ug::LocalShapeFunctionSet::grad()
     189            0 :                 inline void grad(MathMatrix<dim,dim>& g, const size_t i, const MathVector<dim>& x) const
     190              :                 {
     191            0 :                         UG_THROW ("NedelecLSFS: Gradients of the Nedelec shapes cannot be computed in the reference space.");
     192              :                 }
     193              : };
     194              : 
     195              : /// Nedelec (or Whitney-1) base function set for tetrahedra
     196              : template <>
     197              : class NedelecLSFS<ReferenceTetrahedron>
     198              : : public NedelecLDS<ReferenceTetrahedron>,
     199              :   public
     200              :         BaseLSFS
     201              :                 <
     202              :                         NedelecLSFS<ReferenceTetrahedron>,
     203              :                         ReferenceTetrahedron::dim, ///< dimensionality of the element
     204              :                         MathVector<ReferenceTetrahedron::dim>, ///< return type of the shape functions
     205              :                         MathMatrix<ReferenceTetrahedron::dim, ReferenceTetrahedron::dim> ///< return type of the gradients
     206              :                 >
     207              : {
     208              :         public:
     209              :         ///     Reference Element type
     210              :                 typedef ReferenceTetrahedron reference_element_type;
     211              : 
     212              :         ///     Order of Shape functions
     213              :                 static const size_t order = 1;
     214              : 
     215              :         ///     Dimension, where shape functions are defined
     216              :                 static const int dim = reference_element_type::dim;
     217              : 
     218              :         private:
     219              :         ///     Base class
     220              :                 typedef BaseLSFS<NedelecLSFS<reference_element_type>, dim, MathVector<dim>,  MathMatrix<dim,dim> > base_type;
     221              : 
     222              :         public:
     223              :         ///     Shape type
     224              :                 typedef base_type::shape_type shape_type;
     225              : 
     226              :         ///     Gradient type
     227              :                 typedef base_type::grad_type grad_type;
     228              : 
     229              :         protected:
     230              :         ///     number of shapes
     231              :                 static const size_t nsh = reference_element_type::numEdges;
     232              : 
     233              :         public:
     234              :         ///     Constructor
     235            0 :                 NedelecLSFS() {};
     236              : 
     237              :         ///     \copydoc ug::LocalShapeFunctionSet::continuous()
     238              :                 inline bool continuous() const {return false;}
     239              : 
     240              :         ///     \copydoc ug::LocalShapeFunctionSet::num_sh()
     241              :                 inline size_t num_sh() const {return nsh;}
     242              : 
     243              :         ///     \copydoc ug::LocalShapeFunctionSet::position()
     244            0 :                 inline bool position(size_t i, MathVector<dim>& pos) const
     245              :                 {
     246            0 :                         switch(i)
     247              :                         {
     248            0 :                                 case 0: pos[0] = 0.5;
     249            0 :                                                 pos[1] = 0.0;
     250            0 :                                                 pos[2] = 0.0;
     251            0 :                                                 return true;
     252            0 :                                 case 1: pos[0] = 0.5;
     253            0 :                                                 pos[1] = 0.5;
     254            0 :                                                 pos[2] = 0.0;
     255            0 :                                                 return true;
     256            0 :                                 case 2: pos[0] = 0.0;
     257            0 :                                                 pos[1] = 0.5;
     258            0 :                                                 pos[2] = 0.0;
     259            0 :                                                 return true;
     260            0 :                                 case 3: pos[0] = 0.0;
     261            0 :                                                 pos[1] = 0.0;
     262            0 :                                                 pos[2] = 0.5;
     263            0 :                                                 return true;
     264            0 :                                 case 4: pos[0] = 0.5;
     265            0 :                                                 pos[1] = 0.0;
     266            0 :                                                 pos[2] = 0.5;
     267            0 :                                                 return true;
     268            0 :                                 case 5: pos[0] = 0.0;
     269            0 :                                                 pos[1] = 0.5;
     270            0 :                                                 pos[2] = 0.5;
     271            0 :                                                 return true;
     272            0 :                                 default: UG_THROW("NedelecLSFS: shape function "<<i<<
     273              :                                                                         " not found. Only "<<nsh<<" shapes present.");
     274              :                         }
     275              :                 }
     276              : 
     277              :         ///     \copydoc ug::LocalShapeFunctionSet::shape()
     278            0 :                 inline MathVector<dim> shape(const size_t i, const MathVector<dim>& x) const
     279              :                 {
     280            0 :                         UG_THROW ("NedelecLSFS: Nedelec shapes cannot be computed in the reference space.");
     281              :                 }
     282              : 
     283              :         ///     \copydoc ug::LocalShapeFunctionSet::grad()
     284            0 :                 inline void grad(MathMatrix<dim,dim>& g, const size_t i, const MathVector<dim>& x) const
     285              :                 {
     286            0 :                         UG_THROW ("NedelecLSFS: Gradients of the Nedelec shapes cannot be computed in the reference space.");
     287              :                 }
     288              : };
     289              : 
     290              : } // namespace ug
     291              : 
     292              : #endif // __H__UG__LIB_DISC__LOCAL_SHAPE_FUNCTION_SET__NEDELEC__NEDELEC__
     293              : 
     294              : /* End of File */
        

Generated by: LCOV version 2.0-1