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

            Line data    Source code
       1              : /*
       2              :  * Copyright (c) 2012-2016:  G-CSC, Goethe University Frankfurt
       3              :  * Author: Arne Nägel
       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_SHAPE_FUNCTION_SET__MINI__MINI_BUBBLE__
      34              : #define __H__UG__LIB_DISC__LOCAL_SHAPE_FUNCTION_SET__MINI__MINI_BUBBLE__
      35              : 
      36              : #include "../common/lagrange1d.h"
      37              : #include "../local_finite_element_provider.h"
      38              : #include "../local_dof_set.h"
      39              : #include "lib_disc/common/multi_index.h"
      40              : #include "common/util/provider.h"
      41              : #include "common/util/metaprogramming_util.h"
      42              : #include "lib_grid/grid/grid_base_objects.h"
      43              : #include "common/util/provider.h"
      44              : #include "lib_disc/reference_element/reference_element_util.h"
      45              : #include "lib_disc/common/multi_index.h"
      46              : 
      47              : namespace ug{
      48              : 
      49              : /// Lagrange Shape Function Set without virtual functions and fixed order
      50              : template <typename TRefElem>
      51              : class MiniBubbleLSFS;
      52              : 
      53              : 
      54              : /// MiniBubble Set (2D only!)
      55              : template <typename TRefElem>
      56              : class MiniBubbleLDS : public LocalDoFSet
      57              : {
      58              :         protected:
      59              :         ///     dimension of reference element
      60              :                 static const int refDim = TRefElem::dim;
      61              : 
      62              :         public:
      63              :         ///     constructor
      64            0 :                 MiniBubbleLDS()
      65            0 :                 {
      66              :                         // get _the_ reference element
      67            0 :                         const TRefElem& rRefElem = Provider<TRefElem>::get();
      68              : 
      69              :                         if(refDim >= 2)
      70              :                         {
      71              :                                 // face (or volume???)
      72              :                                 //      set local DoFs (located at vertices+bubble)
      73            0 :                                 nsh = rRefElem.num(0)+1;
      74              : 
      75            0 :                                 m_vLocalDoF.resize(nsh);
      76            0 :                                 for(size_t i = 0; i< nsh-1; ++i)
      77            0 :                                         m_vLocalDoF[i] = LocalDoF(0, i, 0);
      78              : 
      79            0 :                                 m_vLocalDoF[nsh-1] = LocalDoF(refDim, nsh-1, 0); // bubble located at element
      80              :                         }
      81              :                         else
      82              :                         {
      83              :                                 // edge or vertex
      84            0 :                                 nsh = refDim+1;
      85            0 :                                 m_vLocalDoF.resize(nsh);
      86            0 :                                 for(size_t i = 0; i< nsh-1; ++i)
      87            0 :                                         m_vLocalDoF[i] = LocalDoF(0, i, 0);
      88              : 
      89              :                         }
      90            0 :                 }
      91              : 
      92              :         ///     returns the type of reference element
      93            0 :                 ReferenceObjectID roid() const {return TRefElem::REFERENCE_OBJECT_ID;}
      94              : 
      95              :         ///     returns the total number of DoFs on the finite element
      96              :                 size_t num_dof() const {return nsh;};
      97              : 
      98              :         ///     returns the number of DoFs on a sub-geometric object type
      99            0 :                 size_t num_dof(ReferenceObjectID type) const
     100              :                 {
     101            0 :                         const int d = ReferenceElementDimension(type);
     102            0 :                         if (d==0) return 1;         // vertices
     103            0 :                         if (d == refDim)   return 1;    // element
     104              :                         return 0;
     105              :                 }
     106              : 
     107              :         ///     returns the dof storage
     108            0 :                 const LocalDoF& local_dof(size_t dof) const {return m_vLocalDoF[dof];}
     109              : 
     110              :         ///     returns if the local dof position are exact
     111              :                 bool exact_position_available() const {return true;};
     112              : 
     113              :         protected:
     114              :         ///     number of shapes
     115              :                 size_t nsh;
     116              : 
     117              :         ///     order
     118              :         ///     size_t p;
     119              : 
     120              :         ///     association to elements
     121              :                 std::vector<LocalDoF> m_vLocalDoF;
     122              : };
     123              : 
     124              : ////////////////////////////////////////////////////////////////////////////////
     125              : //      ReferenceEdge
     126              : //
     127              : //  function space span {1,x}
     128              : //
     129              : ////////////////////////////////////////////////////////////////////////////////
     130              : 
     131              : template <>
     132              : class MiniBubbleLSFS<ReferenceEdge>
     133              : : public MiniBubbleLDS<ReferenceEdge>,
     134              :   public BaseLSFS<MiniBubbleLSFS<ReferenceEdge>, 1>
     135              : {
     136              :         public:
     137              :         ///     Order of Shape functions
     138              :                 static const size_t order = 1;
     139              : 
     140              :         ///     Dimension, where shape functions are defined
     141              :                 static const int dim = 1;
     142              : 
     143              :         /// Number of shape functions
     144              :                 static const size_t nsh = 3;
     145              : 
     146              :         public:
     147              :         ///     Shape type
     148              :                 typedef number shape_type;
     149              : 
     150              :         ///     Gradient type
     151              :                 typedef MathVector<dim> grad_type;
     152              : 
     153              :         ///     Reference Element type
     154              :                 typedef ReferenceEdge reference_element_type;
     155              : 
     156              :         public:
     157              :         ///     Constructor
     158            0 :                 MiniBubbleLSFS(){}
     159              : 
     160              :         ///     \copydoc ug::LocalShapeFunctionSet::continuous()
     161              :                 inline bool continuous() const {return true;}
     162              : 
     163              :         ///     \copydoc ug::LocalShapeFunctionSet::num_sh()
     164            0 :                 inline size_t num_sh() const {return nsh;}
     165              : 
     166              :         ///     \copydoc ug::LocalShapeFunctionSet::position()
     167            0 :                 inline bool position(size_t i, MathVector<dim>& pos) const
     168              :                 {
     169            0 :                         switch(i)
     170              :                         {
     171            0 :                                 case 0: pos[0] = 0;return true;
     172            0 :                                 case 1: pos[0] = 1;return true;
     173            0 :                                 case 2: pos[0] = 0.5;return true; // bubble
     174            0 :                                 default: UG_THROW("MiniBubbleLSFS: shape function "<<i<<
     175              :                                                                         " not found. Only "<<nsh<<" shapes present.");
     176              :                         }
     177              :                 }
     178              : 
     179              :         ///     \copydoc ug::LocalShapeFunctionSet::shape()
     180            0 :                 inline number shape(const size_t i, const MathVector<dim>& x) const
     181              :                 {
     182              :                         // ReferenceEdge::check_position(x);
     183              : 
     184            0 :                         switch(i)
     185              :                         {
     186            0 :                                 case 0: return 1-x[0];
     187            0 :                                 case 1: return x[0];
     188            0 :                                 case 2: return 2.0*x[0]*(1-x[0]);
     189            0 :                                 default: UG_THROW("MiniBubbleLSFS: shape function "<<i<<
     190              :                                                                         " not found. Only "<<nsh<<" shapes present.");
     191              :                         }
     192              :                 }
     193              : 
     194              :         ///     \copydoc ug::LocalShapeFunctionSet::grad()
     195            0 :                 inline void grad(MathVector<dim>& g, const size_t i, const MathVector<dim>& x) const
     196              :                 {
     197              :                         // ReferenceEdge::check_position(x);
     198              : 
     199            0 :                         switch(i)
     200              :                         {
     201              :                                 case 0: g[0] = -1.0;
     202            0 :                                 case 1: g[0] =  1.0;
     203            0 :                                 case 2: g[0] =  2.0-4.0*x[0];
     204            0 :                                 default: UG_THROW("MiniBubbleLSFS: shape function "<<i<<
     205              :                                                                         " not found. Only "<<nsh<<" shapes present.");
     206              :                         }
     207              :                 }
     208              : };
     209              : 
     210              : ////////////////////////////////////////////////////////////////////////////////
     211              : //      ReferenceTriangle
     212              : //
     213              : //  function space span {1,x,y}+bubble
     214              : //
     215              : ////////////////////////////////////////////////////////////////////////////////
     216              : 
     217              : template <>
     218              : class MiniBubbleLSFS<ReferenceTriangle>
     219              : : public MiniBubbleLDS<ReferenceTriangle>,
     220              :   public BaseLSFS<MiniBubbleLSFS<ReferenceTriangle>, 2>
     221              : {
     222              :         public:
     223              :         ///     Order of Shape functions
     224              :                 static const size_t order = 2;
     225              : 
     226              :         ///     Dimension, where shape functions are defined
     227              :                 static const int dim = 2;
     228              : 
     229              :         /// Number of shape functions
     230              :                 static const size_t nsh = 4;
     231              :         public:
     232              :         ///     Shape type
     233              :                 typedef number shape_type;
     234              : 
     235              :         ///     Gradient type
     236              :                 typedef MathVector<dim> grad_type;
     237              : 
     238              :         ///     Reference Element type
     239              :                 typedef ReferenceTriangle reference_element_type;
     240              : 
     241              :         public:
     242              :         ///     Constructor
     243            0 :                 MiniBubbleLSFS(){}
     244              : 
     245              :         ///     \copydoc ug::LocalShapeFunctionSet::continuous()
     246              :                 inline bool continuous() const {return true;}
     247              : 
     248              :         ///     \copydoc ug::LocalShapeFunctionSet::num_sh()
     249            0 :                 inline size_t num_sh() const {return nsh;}
     250              : 
     251              :         ///     \copydoc ug::LocalShapeFunctionSet::position()
     252            0 :                 inline bool position(size_t i, MathVector<dim>& pos) const
     253              :                 {
     254            0 :                         switch(i)
     255              :                         {
     256            0 :                                 case 0: pos[0] = 0.0;
     257            0 :                                                 pos[1] = 0.0; return true;
     258            0 :                                 case 1: pos[0] = 0.1;
     259            0 :                                                 pos[1] = 0.0; return true;
     260            0 :                                 case 2: pos[0] = 0.0;
     261            0 :                                                 pos[1] = 0.1; return true;
     262            0 :                                 case 3: pos[0] = 1.0/3.0;
     263            0 :                                                 pos[1] = 1.0/3.0; return true;
     264            0 :                                 default: UG_THROW("MiniLSFS: shape function "<<i<<
     265              :                                                                         " not found. Only "<<nsh<<" shapes present.");
     266              :                         }
     267              :                 }
     268              : 
     269              :         ///     \copydoc ug::LocalShapeFunctionSet::shape()
     270            0 :                 inline number shape(const size_t i, const MathVector<dim>& x) const
     271              :                 {
     272              :                         // ReferenceTriangle::check_position(x);
     273              : 
     274            0 :                         switch(i)
     275              :                         {
     276            0 :                                 case 0: return (1.0-x[0]-x[1]);
     277            0 :                                 case 1: return x[0];
     278            0 :                                 case 2: return x[1];
     279            0 :                                 case 3: return 27.0*x[0]*x[1]*(1.0-x[0]-x[1]); // bubble
     280            0 :                                 default: UG_THROW("MiniLSFS: shape function "<<i<<
     281              :                                                                         " not found. Only "<<nsh<<" shapes present.");
     282              :                         }
     283              :                 }
     284              : 
     285              :         ///     \copydoc ug::LocalShapeFunctionSet::grad()
     286            0 :                 inline void grad(MathVector<dim>& g, const size_t i, const MathVector<dim>& x) const
     287              :                 {
     288              :                         // ReferenceTriangle::check_position(x);
     289              : 
     290            0 :                         switch(i)
     291              :                         {
     292            0 :                                 case 0: g[0] = -1.0;
     293            0 :                                                 g[1] = -1.0; return;
     294            0 :                                 case 1: g[0] = 1.0;
     295            0 :                                                 g[1] = 0.0; return;
     296            0 :                                 case 2: g[0] = 0.0;
     297            0 :                                                 g[1] = 1.0; return;
     298            0 :                                 case 3: g[0] = 27*x[1]*(1.0-x[1]-2.0*x[0]);
     299            0 :                                                 g[1] = 27*x[0]*(1.0-x[0]-2.0*x[1]);
     300            0 :                                                 std::cout << "MiniGrad: " << g[0] << ","<< g[1] << "at"<< x[0]<< ","<< x[1]<< std::endl;
     301              :                                                 return;
     302            0 :                                 default: UG_THROW("MiniLSFS: shape function "<<i<<
     303              :                                                                         " not found. Only "<<nsh<<" shapes present.");
     304              :                         }
     305              :                 }
     306              : };
     307              : 
     308              : 
     309              : ////////////////////////////////////////////////////////////////////////////////
     310              : //      ReferenceQuadrilateral
     311              : //
     312              : //  function space: span {1,x,y,x^2-y^2} + 2 bubbles
     313              : //  ref: Wen Bai, CMAME 143 (1997), 41-47
     314              : ////////////////////////////////////////////////////////////////////////////////
     315              : 
     316              : template <>
     317              : class MiniBubbleLSFS<ReferenceQuadrilateral>
     318              : : public MiniBubbleLDS<ReferenceQuadrilateral>,
     319              :   public BaseLSFS<MiniBubbleLSFS<ReferenceQuadrilateral>, 2>
     320              : {
     321              :         protected:
     322              :                 static const double SQRT_FIVE;
     323              :                 static const double SQRT_FIVTH;
     324              : 
     325              :         public:
     326              :         ///     Order of Shape functions
     327              :                 static const size_t order = 2;
     328              : 
     329              :         ///     Dimension, where shape functions are defined
     330              :                 static const int dim = 2;
     331              : 
     332              :         /// Number of shape functions
     333              :                 static const size_t nsh = 5;
     334              : 
     335              :         public:
     336              :         ///     Shape type
     337              :                 typedef number shape_type;
     338              : 
     339              :         ///     Gradient type
     340              :                 typedef MathVector<dim> grad_type;
     341              : 
     342              :         ///     Reference Element type
     343              :                 typedef ReferenceQuadrilateral reference_element_type;
     344              : 
     345              :         public:
     346              :         ///     Constructor
     347            0 :                 MiniBubbleLSFS(){}
     348              : 
     349              :         ///     \copydoc ug::LocalShapeFunctionSet::continuous()
     350              :                 inline bool continuous() const {return true;}
     351              : 
     352              :         ///     \copydoc ug::LocalShapeFunctionSet::num_sh()
     353            0 :                 inline size_t num_sh() const {return nsh;}
     354              : 
     355              :         ///     \copydoc ug::LocalShapeFunctionSet::position()
     356            0 :                 inline bool position(size_t i, MathVector<dim>& pos) const
     357              :                 {
     358            0 :                         switch(i)
     359              :                         {
     360            0 :                                 case 0: pos[0] = 0.0;
     361            0 :                                                 pos[1] = 0.0; return true;
     362            0 :                                 case 1: pos[0] = 1.0;
     363            0 :                                                 pos[1] = 0.0; return true;
     364            0 :                                 case 2: pos[0] = 1.0;
     365            0 :                                                 pos[1] = 1.0; return true;
     366            0 :                                 case 3: pos[0] = 0.0;
     367            0 :                                                 pos[1] = 1.0; return true;
     368            0 :                                 case 4: pos[0] = 0.5;
     369            0 :                                                 pos[1] = 0.5; return true;
     370            0 :                                 case 5: pos[0] = SQRT_FIVTH;
     371            0 :                                                 pos[1] = SQRT_FIVTH; return true;
     372              : 
     373            0 :                                 default: UG_THROW("MiniLSFS: shape function "<<i<<
     374              :                                                                         " not found. Only "<<nsh<<" shapes present.");
     375              :                         }
     376              :                 }
     377              : 
     378              :         ///     \copydoc ug::LocalShapeFunctionSet::shape()
     379            0 :                 inline number shape(const size_t i, const MathVector<dim>& x) const
     380              :                 {
     381              :                         // ReferenceQuadrilateral::check_position(x);
     382              : 
     383            0 :                         switch(i)
     384              :                         {
     385            0 :                                 case 0: return (1.0-x[0])*(1.0-x[1]);
     386            0 :                                 case 1: return x[0]*(1.0-x[1]);
     387            0 :                                 case 2: return x[0]*x[1];
     388            0 :                                 case 3: return x[1]*(1.0-x[0]);
     389              : 
     390              :                                 // two bubbles (condensable)
     391            0 :                                 case 4: return x[0]*(1.0-x[0])*x[1]*(1.0-x[1]);
     392            0 :                                 case 5: return (1.0-x[0]*x[0])*(1.0-x[1]*x[1])*(x[0]+x[1])/(0.8*0.8*2.0)*SQRT_FIVTH; // max: sqrt(1/5) = sqrt(5)/5
     393              : 
     394            0 :                                 default: UG_THROW("MiniLSFS: shape function "<<i<<
     395              :                                                                         " not found. Only "<<nsh<<" shapes present.");
     396              :                         }
     397              :                 }
     398              : 
     399              :         ///     \copydoc ug::LocalShapeFunctionSet::grad()
     400            0 :                 inline void grad(MathVector<dim>& g, const size_t i, const MathVector<dim>& x) const
     401              :                 {
     402              :                         // ReferenceQuadrilateral::check_position(x);
     403              : 
     404            0 :                         switch(i)
     405              :                         {
     406            0 :                                 case 0: g[0] = -(1.0-x[1]);
     407            0 :                                                 g[1] = -(1.0-x[0]); return;
     408            0 :                                 case 1: g[0] = (1.0-x[1]);
     409            0 :                                                 g[1] = -(0.0+x[0]); return;
     410            0 :                                 case 2: g[0] = (0.0+x[1]);
     411            0 :                                                 g[1] = (0.0+x[0]); return;
     412            0 :                                 case 3: g[0] = -(0.0+x[1]);
     413            0 :                                                 g[1] = (1.0-x[0]); return;
     414              :                                 // bubble 1
     415            0 :                                 case 4: g[0] = (1.0-2.0*x[0])*x[1]*(1.0-x[1]);
     416            0 :                                                 g[1] = x[0]*(1.0-x[0])*(1.0-2.0*x[1]); return;
     417              :                                 // bubble 2, grad = 3*x^2*(y^2-1) + 2xy*(y^2-1) -(y^2-1) = (y^2-1)*(3*x^2+2xy-1)
     418            0 :                                 case 5: g[0] =(x[1]*x[1]-1.0)*(3.0*x[0]*x[0]+2.0*x[0]*x[1]-1.0)/(0.8*0.8*2.0)*SQRT_FIVTH;
     419            0 :                                                 g[1] =(x[0]*x[0]-1.0)*(3.0*x[1]*x[1]+2.0*x[1]*x[0]-1.0)/(0.8*0.8*2.0)*SQRT_FIVTH; return;
     420              : 
     421            0 :                                 default: UG_THROW("MiniLSFS: shape function "<<i<<
     422              :                                                                         " not found. Only "<<nsh<<" shapes present.");
     423              :                         }
     424              :                 }
     425              : };
     426              : 
     427              : ////////////////////////////////////////////////////////////////////////////////
     428              : //      ReferenceTetrahedron
     429              : //
     430              : //  function space span {1,x,y,z} + bubble
     431              : //
     432              : ////////////////////////////////////////////////////////////////////////////////
     433              : 
     434              : template <>
     435              : class MiniBubbleLSFS<ReferenceTetrahedron>
     436              : : public MiniBubbleLDS<ReferenceTetrahedron>,
     437              :   public BaseLSFS<MiniBubbleLSFS<ReferenceTetrahedron>, 3>
     438              : {
     439              :         public:
     440              :         ///     Order of Shape functions
     441              :                 static const size_t order = 1;
     442              : 
     443              :         ///     Dimension, where shape functions are defined
     444              :                 static const int dim = 3;
     445              : 
     446              :         /// Number of shape functions
     447              :                 static const size_t nsh = 4+1;
     448              : 
     449              :         public:
     450              :         ///     Shape type
     451              :                 typedef number shape_type;
     452              : 
     453              :         ///     Gradient type
     454              :                 typedef MathVector<dim> grad_type;
     455              : 
     456              :         ///     Reference Element type
     457              :                 typedef ReferenceTetrahedron reference_element_type;
     458              : 
     459              :         public:
     460              :         ///     Constructor
     461            0 :                 MiniBubbleLSFS(){}
     462              : 
     463              :         ///     \copydoc ug::LocalShapeFunctionSet::continuous()
     464              :                 inline bool continuous() const {return true;}
     465              : 
     466              :         ///     \copydoc ug::LocalShapeFunctionSet::num_sh()
     467            0 :                 inline size_t num_sh() const {return nsh;}
     468              : 
     469              :         ///     \copydoc ug::LocalShapeFunctionSet::position()
     470            0 :                 inline bool position(size_t i, MathVector<dim>& pos) const
     471              :                 {
     472            0 :                         switch(i)
     473              :                         {
     474            0 :                                         case 0: pos[0] = 0.0; pos[1] = 0.0; pos[2] = 0.0; return true;
     475            0 :                                         case 1: pos[0] = 1.0; pos[1] = 0.0; pos[2] = 0.0; return true;
     476            0 :                                         case 2: pos[0] = 0.0; pos[1] = 1.0; pos[2] = 0.0; return true;
     477            0 :                                         case 3: pos[0] = 0.0; pos[1] = 0.0; pos[2] = 1.0; return true;
     478            0 :                                         case 4: pos[0] = 0.25; pos[1] = 0.25; pos[2] = 0.25; return true;
     479            0 :                                 default: UG_THROW("MiniLSFS: shape function "<<i<<
     480              :                                                                         " not found. Only "<<nsh<<" shapes present.");
     481              :                         }
     482              :                 }
     483              : 
     484              :         ///     \copydoc ug::LocalShapeFunctionSet::shape()
     485            0 :                 inline number shape(const size_t i, const MathVector<dim>& x) const
     486              :                 {
     487              :                         // ReferenceTetrahedron::check_position(x);
     488              :                         //number prod = x[0]*x[1]*x[2];
     489              :                         //number lambda4 = (1.0-x[0]-x[1]-x[2]);
     490              : 
     491            0 :                         switch(i)
     492              :                         {
     493            0 :                                 case 0: return (1.0-x[0]-x[1]-x[2]);
     494            0 :                                 case 1: return x[0];
     495            0 :                                 case 2: return x[1];
     496            0 :                                 case 3: return x[2];
     497            0 :                                 case 4: return x[0]*x[1]*x[2]*(1.0-x[0]-x[1]-x[2]); // bubble
     498            0 :                                 default: UG_THROW("MiniLSFS: shape function "<<i<<
     499              :                                                                         " not found. Only "<<nsh<<" shapes present.");
     500              :                         }
     501              :                 }
     502              : 
     503              :         ///     \copydoc ug::LocalShapeFunctionSet::grad()
     504            0 :                 inline void grad(MathVector<dim>& g, const size_t i, const MathVector<dim>& x) const
     505              :                 {
     506              :                         // ReferenceTetrahedron::check_position(x);
     507            0 :                         number prod = x[0]*x[1]*x[2];
     508            0 :                         number lambda4 = (1.0-x[0]-x[1]-x[2]);
     509              : 
     510            0 :                         switch(i)
     511              :                         {
     512            0 :                                 case 0: g[0] = -1.0;
     513            0 :                                                 g[1] = -1.0;
     514            0 :                                                 g[1] = -1.0; return;
     515            0 :                                 case 1: g[0] =  1.0;
     516            0 :                                                 g[1] =  0.0;
     517            0 :                                                 g[2] =  0.0; return;
     518            0 :                                 case 2: g[0] =  0.0;
     519            0 :                                                 g[1] =  1.0;
     520            0 :                                                 g[2] =  0.0; return;
     521            0 :                                 case 3: g[0] =  0.0;
     522            0 :                                                 g[1] =  0.0;
     523            0 :                                                 g[2] =  1.0; return;
     524            0 :                                 case 4: g[0] = -prod + lambda4*x[1]*x[2];
     525            0 :                                                 g[1] = -prod + lambda4*x[0]*x[2];
     526            0 :                                                 g[2] = -prod + lambda4*x[0]*x[2]; return;
     527              : 
     528            0 :                                 default: UG_THROW("MiniLSFS: shape function "<<i<<
     529              :                                                                         " not found. Only "<<nsh<<" shapes present.");
     530              :                         }
     531              :                 }
     532              : };
     533              : 
     534              : ////////////////////////////////////////////////////////////////////////////////
     535              : //      ReferenceHexahedron
     536              : //
     537              : //  function space span {1,x} \times {1,y} \times {1,z} + bubble
     538              : //
     539              : ////////////////////////////////////////////////////////////////////////////////
     540              : template <>
     541              : class MiniBubbleLSFS<ReferenceHexahedron>
     542              : : public MiniBubbleLDS<ReferenceHexahedron>,
     543              :   public BaseLSFS<MiniBubbleLSFS<ReferenceHexahedron>, 3>
     544              : {
     545              :         public:
     546              :         ///     Order of Shape functions
     547              :                 static const size_t order = 6;
     548              : 
     549              :         ///     Dimension, where shape functions are defined
     550              :                 static const int dim = 3;
     551              : 
     552              :         /// Number of shape functions
     553              :                 static const size_t nsh = 8+1;
     554              : 
     555              :         public:
     556              :         ///     Shape type
     557              :                 typedef number shape_type;
     558              : 
     559              :         ///     Gradient type
     560              :                 typedef MathVector<dim> grad_type;
     561              : 
     562              :         ///     Reference Element type
     563              :                 typedef ReferenceHexahedron reference_element_type;
     564              : 
     565              :         public:
     566              :         ///     Constructor
     567              :                 MiniBubbleLSFS(){}
     568              : 
     569              :         ///     \copydoc ug::LocalShapeFunctionSet::continuous()
     570              :                 inline bool continuous() const {return true;}
     571              : 
     572              :         ///     \copydoc ug::LocalShapeFunctionSet::num_sh()
     573            0 :                 inline size_t num_sh() const {return nsh;}
     574              : 
     575              : 
     576              :         ///     \copydoc ug::LocalShapeFunctionSet::position()
     577              :                 inline bool position(size_t i, MathVector<dim>& pos) const
     578              :                 {
     579              :                         static const DimReferenceElement<3>& refElem
     580              :                                 = ReferenceElementProvider::get<3>(ROID_HEXAHEDRON);
     581              : 
     582              :                         if (i<=7)
     583              :                         {       // corner
     584              :                                 pos = refElem.corner(i); return true;
     585              :                         } else if (i==8)
     586              :                         {       // bubble
     587              :                                 pos[0] = 0.5; pos[1] = 0.5; pos[2] = 0.5; return true;
     588              :                         } else
     589              :                         {
     590              :                                 UG_THROW("MiniLSFS: shape function "<<i<< " not found. Only "<<nsh<<" shapes present.");
     591              :                         }
     592              :                         return false;
     593              :                 }
     594              : 
     595              :         ///     \copydoc ug::LocalShapeFunctionSet::shape()
     596              :                 inline number shape(const size_t i, const MathVector<dim>& x) const
     597              :                 {
     598              : 
     599              :                         switch(i)
     600              :                         {
     601              :                         // corners 0..7
     602              :                         case 0: return((1.0-x[0])*(1.0-x[1])*(1.0-x[2]));
     603              :                         case 1: return((x[0])*(1.0-x[1])*(1.0-x[2]));
     604              :                         case 2: return((x[0])*(x[1])*(1.0-x[2]));
     605              :                         case 3: return((1.0-x[0])*(x[1])*(1.0-x[2]));
     606              :                         case 4: return((1.0-x[0])*(1.0-x[1])*(x[2]));
     607              :                         case 5: return((x[0])*(1.0-x[1])*(x[2]));
     608              :                         case 6: return((x[0])*(x[1])*(x[2]));
     609              :                         case 7: return((1.0-x[0])*(x[1])*(x[2]));
     610              :                         // bubble
     611              :                         case 8: return 64.0*x[0]*(1-x[0])*x[1]*(1-x[1])*x[2]*(1-x[2]);
     612              :                         default: UG_THROW("MiniLSFS: shape function "<<i<<
     613              :                                         " not found. Only "<<nsh<<" shapes present.");
     614              :                         }
     615              : 
     616              :                 }
     617              : 
     618              :         ///     \copydoc ug::LocalShapeFunctionSet::grad()
     619              :                 inline void grad(MathVector<dim>& value, const size_t i, const MathVector<dim>& x) const
     620              :                 {
     621              : 
     622              :                         switch(i)
     623              : 
     624              :                         {
     625              :                         case 0:
     626              :                                 value[0] = -(1.0-x[1])*(1.0-x[2]);
     627              :                                 value[1] = -(1.0-x[0])*(1.0-x[2]);
     628              :                                 value[2] = -(1.0-x[0])*(1.0-x[1]);
     629              :                                 return;
     630              :                         case 1:
     631              :                                 value[0] = (1.0-x[1])*(1.0-x[2]);
     632              :                                 value[1] = -(x[0])*(1.0-x[2]);
     633              :                                 value[2] = -(x[0])*(1.0-x[1]);
     634              :                                 return;
     635              :                         case 2:
     636              :                                 value[0] = (x[1])*(1.0-x[2]);
     637              :                                 value[1] = (x[0])*(1.0-x[2]);
     638              :                                 value[2] = -x[0]*x[1];
     639              :                                 return;
     640              :                         case 3:
     641              :                                 value[0] = -(x[1])*(1.0-x[2]);
     642              :                                 value[1] = (1.0-x[0])*(1.0-x[2]);
     643              :                                 value[2] = -(1.0-x[0])*(x[1]);
     644              :                                 return;
     645              :                         case 4:
     646              :                                 value[0] = -(1.0-x[1])*(x[2]);
     647              :                                 value[1] = -(1.0-x[0])*(x[2]);
     648              :                                 value[2] = (1.0-x[0])*(1.0-x[1]);
     649              :                                 return;
     650              :                         case 5:
     651              :                                 value[0] = (1.0-x[1])*x[2];
     652              :                                 value[1] = -(x[0])*x[2];
     653              :                                 value[2] = (x[0])*(1.0-x[1]);
     654              :                                 return;
     655              :                         case 6:
     656              :                                 value[0] = (x[1])*x[2];
     657              :                                 value[1] = (x[0])*x[2];
     658              :                                 value[2] = x[0]*x[1];
     659              :                                 return;
     660              :                         case 7:
     661              :                                 value[0] = -(x[1])*x[2];
     662              :                                 value[1] = (1.0-x[0])*x[2];
     663              :                                 value[2] = (1.0-x[0])*x[1];
     664              :                                 return;
     665              :                         case 8: // bubble
     666              :                                 value[0] = 64.0*(1.0-2.0*x[0])*x[1]*(1-x[1])*x[2]*(1-x[2]);
     667              :                                 value[1] = 64.0*(1.0-2.0*x[1])*x[0]*(1-x[0])*x[2]*(1-x[2]);
     668              :                                 value[2] = 64.0*(1.0-2.0*x[2])*x[0]*(1-x[0])*x[1]*(1-x[1]);
     669              :                                 return;
     670              : 
     671              :                         default: UG_THROW("MiniLSFS: Invalid shape fct index: "<<i);
     672              :                         }
     673              : 
     674              : 
     675              :                 }
     676              : };
     677              : 
     678              : } //namespace ug
     679              : 
     680              : #endif /* __H__UG__LIB_DISC__LOCAL_SHAPE_FUNCTION_SET__MINI__MINI_BUBBLE__ */
     681              : 
        

Generated by: LCOV version 2.0-1