1#warning "dune/fem/operator/projection/hdivprojection.hh is deprecated and will be moved to dune-fem-dg." 
    3#ifndef DUNE_FEM_HDIV_PROJECTION_HH 
    4#define DUNE_FEM_HDIV_PROJECTION_HH 
    8#include <dune/geometry/referenceelements.hh> 
   11#include <dune/fem/operator/common/spaceoperatorif.hh> 
   12#include <dune/fem/operator/matrix/blockmatrix.hh> 
   13#include <dune/fem/quadrature/caching/twistutility.hh> 
   14#include <dune/fem/quadrature/cachingquadrature.hh> 
   15#include <dune/fem/space/combinedspace.hh> 
   16#include <dune/fem/storage/dynamicarray.hh> 
   19#include <dune/fem/space/discontinuousgalerkin.hh> 
   20#include <dune/fem/space/lagrange.hh> 
   28  template< 
int dim, 
class CoordCont >
 
   60    template <
class DiscreteFunctionType>
 
   65      typedef typename DiscreteFunctionSpaceType::RangeType RangeType;
 
   66      typedef typename DiscreteFunctionSpaceType::DomainType DomainType;
 
   67      typedef typename DiscreteFunctionSpaceType::DomainFieldType DomainFieldType;
 
   68      typedef typename DiscreteFunctionSpaceType::RangeFieldType RangeFieldType;
 
   69      typedef typename DiscreteFunctionSpaceType::JacobianRangeType JacobianRangeType;
 
   70      typedef typename DiscreteFunctionSpaceType::GridPartType GridPartType;
 
   77      typedef ElementQuadrature<GridPartType, 1> FaceQuadratureType;
 
   79      typedef typename GridPartType :: GridType GridType;
 
   81        enum { dimFaceRange = 1 };
 
   82        enum { dimDomain = DiscreteFunctionSpaceType::dimDomain };
 
   83        enum { dimFaceDomain = dimDomain - 1 };
 
   84        enum { polOrdN = DiscreteFunctionSpaceType :: polynomialOrder };
 
   89      enum { gradPolOrd = ((polOrdN - 1) < 0) ? 0 : (polOrdN - 1) };
 
   91      template <
class Space> 
struct BubbleM;
 
   93      template <
class FunctionSpaceImp,
 
   96                template <
class> 
class StorageImp,
 
   97                template <
class,
class,
int,
template <
class> 
class> 
class DiscreteFunctionSpaceImp>
 
   98      struct BubbleM <DiscreteFunctionSpaceImp<FunctionSpaceImp,GridPartImp,polOrd,StorageImp> >
 
  100        enum { bubblePModifier = dimDomain - 1 };
 
  103      template <
class FunctionSpaceImp,
 
  106                template <
class> 
class StorageImp>
 
  107      struct BubbleM < LegendreDiscontinuousGalerkinSpace<FunctionSpaceImp,GridPartImp,polOrd,StorageImp> >
 
  109        enum { bubblePModifier = 1 };
 
  112      template <
class DiscreteFunctionSpaceImp,
 
  114                DofStoragePolicy policy>
 
  115      struct BubbleM <CombinedSpace<DiscreteFunctionSpaceImp,N,policy> >
 
  117        enum { bubblePModifier = BubbleM< DiscreteFunctionSpaceImp > :: bubblePModifier };
 
  120      typedef BubbleM <DiscreteFunctionSpaceType> BubbleMType;
 
  122#ifdef USE_TWISTFREE_MAPPER 
  124      enum { bubblePModifier = BubbleMType :: bubblePModifier };
 
  127      enum { bubblePolOrd = (polOrdN + bubblePModifier) };
 
  130#warning "Hdiv-Projection only working for polOrd = 1 (enable higher order Lagrange with -DUSE_TWISTFREE_MAPPER)" 
  133      enum { bubblePModifier = 1 };
 
  136      enum { bubblePolOrd = (polOrdN > 1) ? 2 : (polOrdN + 1) };
 
  139      template <
class Space> 
struct Spaces;
 
  141      template <
class FunctionSpaceImp,
 
  144                template <
class> 
class StorageImp,
 
  145                template <
class,
class,
int,
template <
class> 
class> 
class DiscreteFunctionSpaceImp>
 
  146      struct Spaces<DiscreteFunctionSpaceImp<FunctionSpaceImp,GridPartImp,polOrd,StorageImp> >
 
  150        typedef DiscreteFunctionSpaceImp<ElSpaceType,GridPartImp,gradPolOrd,StorageImp> ElementGradientSpaceType;
 
  152        typedef DiscreteFunctionSpaceImp<FaceSpaceType,GridPartType,polOrdN,StorageImp> FaceDiscreteSpaceType;
 
  158      template <
class DiscreteFunctionSpaceImp,
 
  160                DofStoragePolicy policy>
 
  161      struct Spaces<CombinedSpace<DiscreteFunctionSpaceImp,N,policy> >
 
  163        typedef typename DiscreteFunctionSpaceImp :: GridPartType GridPartImp;
 
  164        typedef Spaces<DiscreteFunctionSpaceImp> AllSpacesType;
 
  165        typedef typename AllSpacesType :: ElementGradientSpaceType ElementGradientSpaceType;
 
  166        typedef typename AllSpacesType :: ElementDiscreteSpaceType ElementDiscreteSpaceType;
 
  167        typedef typename AllSpacesType :: FaceDiscreteSpaceType    FaceDiscreteSpaceType;
 
  170      typedef Spaces<DiscreteFunctionSpaceType> AllSpacesType;
 
  171      typedef typename AllSpacesType :: ElementGradientSpaceType ElementGradientSpaceType;
 
  172      typedef typename AllSpacesType :: ElementDiscreteSpaceType ElementDiscreteSpaceType;
 
  173      typedef typename AllSpacesType :: FaceDiscreteSpaceType    FaceDiscreteSpaceType;
 
  175      const DiscreteFunctionSpaceType& space_;
 
  176      GridPartType & gridPart_;
 
  177      const FaceDiscreteSpaceType faceSpace_;
 
  178      const ElementDiscreteSpaceType elSpace_;
 
  179      const ElementGradientSpaceType gradSpace_;
 
  183      [[deprecated( 
"Use dune-fem-dg implementation." )]]
 
  186        gridPart_(
space.gridPart()),
 
  187        faceSpace_( gridPart_ ),
 
  188        elSpace_( gridPart_ ),
 
  189        gradSpace_( gridPart_ )
 
  192      [[deprecated( 
"Use dune-fem-dg implementation." )]]
 
  195        gridPart_( org.gridPart_),
 
  196        faceSpace_( gridPart_ ),
 
  197        elSpace_( gridPart_ ),
 
  198        gradSpace_( gridPart_ )
 
  202      const DiscreteFunctionSpaceType& 
space()
 const 
  215        typedef typename GridPartType :: IntersectionIteratorType IntersectionIteratorType;
 
  216        typedef typename IntersectionIteratorType :: Intersection IntersectionType;
 
  217        typedef typename GridType :: template 
Codim<0> :: Entity EntityType;
 
  218        typedef typename GridType :: Traits :: LocalIdSet LocalIdSetType;
 
  220        enum { dim = GridType::dimension };
 
  222        const DiscreteFunctionSpaceType &
space = discFunc.
space();
 
  223        const GridPartType &gridPart = 
space.gridPart();
 
  224        const int polOrd = (polyOrder <0) ? (2 * 
space.order() + 2) : polyOrder;
 
  229        RangeType neighRet (0.0);
 
  232        typedef ElementQuadrature <GridPartType , 1> FaceQuadratureType;
 
  236        const LocalIdSetType &idSet = gridPart.grid().localIdSet();
 
  238        for(
const auto & en : 
space)
 
  242          double localValue = 0.0;
 
  244          IntersectionIteratorType endnit = gridPart.iend(en);
 
  245          for(IntersectionIteratorType nit = gridPart.ibegin(en);
 
  246              nit != endnit; ++nit)
 
  248            const IntersectionType& inter=*nit;
 
  250            if(inter.neighbor() )
 
  252              EntityType nb = inter.outside();
 
  254              if(idSet.id( en ) < idSet.id( nb ))
 
  256                FaceQuadratureType faceQuadInner(gridPart, inter, polOrd, FaceQuadratureType::INSIDE);
 
  257                FaceQuadratureType faceQuadOuter(gridPart, inter, polOrd, FaceQuadratureType::OUTSIDE);
 
  261                const int quadNop = faceQuadInner.nop();
 
  262                for (
int l = 0; l < quadNop ; ++l)
 
  265                    inter.unitOuterNormal(faceQuadInner.localPoint(l));
 
  268                  neighLf.evaluate(faceQuadOuter[l], neighRet);
 
  272                  double val = ret * normal;
 
  273                  val *= faceQuadInner.weight(l);
 
  275                  localValue += std::abs(val);
 
  280          sum += std::abs(localValue);
 
  289      void curl(
const DomainType & arg, DomainType & dest, 
const int d )
 const 
  291        if( DomainType :: dimension == 2 )
 
  298        else if( DomainType :: dimension == 3 )
 
  329      template <
class EntityType,
 
  330                class LocalFunctionType,
 
  334      void bubblePart(
const ElementDiscreteSpaceType& 
space,
 
  336                      const LocalFunctionType & uLF, 
const int startRow ,
 
  338                      MatrixType & matrix, VectorType& rhs )
 const 
  341        typedef typename ElementDiscreteSpaceType :: BaseFunctionSetType BaseFunctionSetType;
 
  342        typedef typename ElementDiscreteSpaceType :: LagrangePointSetType  LagrangePointSetType;
 
  344        typedef typename ElementDiscreteSpaceType :: JacobianRangeType JacobianRangeType;
 
  345        typedef typename ElementDiscreteSpaceType :: DomainType DomainType;
 
  347        enum { dim = GridType::dimension };
 
  349        const LagrangePointSetType& lagrangePointSet = 
space.lagrangePointSet( en );
 
  350        const BaseFunctionSetType bSet = 
space.baseFunctionSet( en );
 
  351        const int polOrd = 2 * 
space.order(); 
 
  353        const int cols = uLF.numDofs();
 
  354        assert( uRets.size() == (
unsigned int)cols );
 
  356        VolumeQuadratureType quad (en,polOrd);
 
  358        std::vector< JacobianRangeType > valTmpVec( bSet.size() );
 
  363        typedef typename EntityType :: Geometry Geometry ;
 
  364        const Geometry& geo = en.geometry();
 
  367        const int bubbleOffset = (type.isSimplex()) ? 0 : baseFunctionOffset( 0 );
 
  375        const int enDofs = numberOfBubbles( lagrangePointSet.numDofs( 0 ), type ,
 
  377        const int bubbleMod = bubbleModifier( mydim );
 
  379        const int quadNop = quad.nop();
 
  380        for (
int l = 0; l < quadNop ; ++l)
 
  383          const JacobianInverseType& inv = geo.jacobianInverseTransposed( quad.point(l) );
 
  386          const double intel = quad.weight(l) *
 
  387            geo.integrationElement(quad.point(l));
 
  390          uLF.evaluate(quad[l], result);
 
  393          uLF.baseFunctionSet().evaluateAll( quad[l], uRets );
 
  396          bSet.jacobianAll( quad[l], inv, valTmpVec );
 
  399          for( 
int i = 0 ; i<enDofs; i += bubbleMod )
 
  402            int row = startRow + i;
 
  405            const int localBaseFct = ((int) i/bubbleMod) + bubbleOffset;
 
  407            const int baseFct = lagrangePointSet.entityDofNumber( 0, 0, localBaseFct );
 
  410            JacobianRangeType& val = valTmpVec[ baseFct ];
 
  415            for(
int d = 0; d<bubbleMod; ++d )
 
  418              curl(val[0], aVal, d );
 
  420              double r = aVal * result;
 
  425              for(
int j=0; j<cols; ++j)
 
  427                double t = aVal * uRets[ j ];
 
  429                matrix[ row ][ j ] += t;
 
  439      template <
class EntityType, 
class LocalFunctionType, 
class ArrayType,
 
  440                class MatrixType, 
class VectorType>
 
  441      void gradientPart(
const ElementGradientSpaceType & 
space,
 
  443                        const LocalFunctionType & uLF, 
const int startRow ,
 
  444                        ArrayType& uRets, MatrixType& matrix, VectorType& rhs )
 const 
  446        typedef typename ElementGradientSpaceType :: BaseFunctionSetType BaseFunctionSetType;
 
  447        const BaseFunctionSetType bSet = 
space.baseFunctionSet( en );
 
  448        int polOrd = 2 * 
space.order() + 1;
 
  450        const int localRows = gradientBaseFct( bSet );
 
  451        const int cols = uLF.numDofs();
 
  453        VolumeQuadratureType quad (en,polOrd);
 
  458        typedef typename ElementGradientSpaceType :: JacobianRangeType GradJacobianRangeType;
 
  459        std::vector< GradJacobianRangeType > gradTmpVec( bSet.size() );
 
  460        GradJacobianRangeType gradPhi;
 
  462        typedef typename EntityType :: Geometry Geometry ;
 
  463        const Geometry& geo = en.geometry();
 
  469        const int quadNop = quad.nop();
 
  470        for (
int l = 0; l < quadNop ; ++l)
 
  473          const JacobianInverseType& inv = geo.jacobianInverseTransposed( quad.point( l ) );
 
  476          const double intel = quad.weight(l) *
 
  477            geo.integrationElement( quad.point( l ) );
 
  480          uLF.evaluate(quad[l], result);
 
  483          uLF.baseFunctionSet().evaluateAll( quad[l], uRets );
 
  487          bSet.jacobianAll( quad[l], inv, gradTmpVec );
 
  490          for(
int i=0; i<localRows; ++i)
 
  493            const int row = startRow + i;
 
  497            GradJacobianRangeType& gradPhi = gradTmpVec[ baseFunctionOffset( i ) ];
 
  499            const double uDGVal = result * gradPhi[0];
 
  500            rhs[row] += uDGVal * intel;
 
  503            for(
int j=0; j<cols; ++j)
 
  507              const double val = uRets[ j ] * gradPhi[0];
 
  508              matrix[row][j] += val * intel;
 
  514      template <
class FaceBSetType, 
class Gr
idType>
 
  515      struct GetSubBaseFunctionSet
 
  517        template <
class EntityType, 
class SpaceType>
 
  518        static inline FaceBSetType faceBaseSet(
const EntityType& en, 
const SpaceType& 
space)
 
  520          return space.baseFunctionSet( (en.template subEntity<1> (0) )->type() );
 
  524      template <
class FaceBSetType, 
int dim, 
class CoordCont>
 
  525      struct GetSubBaseFunctionSet< FaceBSetType, YaspGrid< dim, CoordCont > >
 
  527        template <
class EntityType, 
class SpaceType>
 
  528        static inline FaceBSetType faceBaseSet(
const EntityType& en, 
const SpaceType& 
space)
 
  535      template <
class FaceBSetType, 
int dim>
 
  536      struct GetSubBaseFunctionSet<FaceBSetType, UGGrid<dim> >
 
  538        template <
class EntityType, 
class SpaceType>
 
  539        static inline FaceBSetType faceBaseSet(
const EntityType& en, 
const SpaceType& 
space)
 
  541          const GeometryType geoType (en.geometry().type().basicType(),dim-1);
 
  542          return space.baseFunctionSet( geoType );
 
  547      enum { gradFuncOffset = 1 };
 
  548      template <
class GradBaseFunctionSet>
 
  549      int gradientBaseFct(
const GradBaseFunctionSet& gradSet)
 const 
  551        return (gradPolOrd <= 0) ? 0 : gradSet.size() - gradFuncOffset;
 
  554      int baseFunctionOffset(
const int i)
 const 
  556        return i + gradFuncOffset;
 
  559      int numberOfBubbles( 
const int bubbles , 
const GeometryType& type,
 
  560                           const int allDofs, 
const int allOther )
 const 
  572          const int numBubble = allDofs - allOther ;
 
  573          return (numBubble > 0) ? numBubble : 0;
 
  577      int bubbleModifier( 
const int dim )
 const 
  580        return (dim - 2) * (dim - 1) + 1;
 
  588        enum { localBlockSize = FunctionSpaceType::localBlockSize };
 
  590        typedef typename FunctionSpaceType::GridType GridType;
 
  591        typedef typename FunctionSpaceType::GridPartType GridPartType;
 
  592        typedef typename FunctionSpaceType::IteratorType Iterator;
 
  597        enum { dim = GridType::dimension };
 
  598        typedef typename GridType :: ctype coordType;
 
  604        if(
space.order() < 1 )
 
  610        const int polOrd = 2 * 
space.order() + 2;
 
  612        typedef typename FaceDiscreteSpaceType :: BaseFunctionSetType FaceBSetType  ;
 
  614        typedef typename ElementGradientSpaceType :: BaseFunctionSetType GradientBaseSetType  ;
 
  618        Iterator start = 
space.begin();
 
  620        if( start == 
space.end() ) 
return;
 
  623        if( 
space.multipleGeometryTypes() )
 
  625          if( 
space.indexSet().geomTypes(0).size() > 1)
 
  627            assert( 
space.indexSet().geomTypes(0).size() == 1 );
 
  628            DUNE_THROW(NotImplemented,
"H-div projection not implemented for hybrid grids");
 
  635        if( startType.isHexahedron() && 
space.order() > 1 )
 
  637          assert( !  startType.isHexahedron() || 
space.order() <= 1 );
 
  638          DUNE_THROW(NotImplemented,
"H-div projection not implemented for p > 1 on hexas! ");
 
  641        const int desiredOrder = 
space.order() + bubblePModifier;
 
  643        if( bubblePolOrd != desiredOrder )
 
  645          assert( bubblePolOrd == desiredOrder );
 
  646          DUNE_THROW(NotImplemented,
"H-div projection not working for " 
  647              << 
space.order() << 
" when LagrangeSpace of order "<< desiredOrder << 
" is missing");
 
  652        const int numDofs = lf.
numDofs();
 
  655        const FaceBSetType faceSet =
 
  656          GetSubBaseFunctionSet<FaceBSetType,GridType>::faceBaseSet( *start , faceSpace_ );
 
  658        const int numFaceDofs = faceSet.size();
 
  660        const GradientBaseSetType gradSet = gradSpace_.baseFunctionSet(*start);
 
  662        const int numGradDofs = gradientBaseFct( gradSet );
 
  667        const int overallFaceDofs = numFaceDofs * refElem.size(1);
 
  670        const int numBubbleDofs = (
space.order() <= 1) ? 0 :
 
  671              numberOfBubbles( elSpace_.lagrangePointSet( *start ).numDofs ( 0 ) , startType,
 
  672                               numDofs, overallFaceDofs + numGradDofs );
 
  674        const int rows = (overallFaceDofs + numGradDofs + numBubbleDofs);
 
  677        const int cols = numDofs;
 
  679        DynamicArray< RangeFieldType > rets(numDofs);
 
  680        DynamicArray< RangeType > uRets(numDofs);
 
  682        typedef FieldMatrix<RangeFieldType,localBlockSize,localBlockSize> FieldMatrixType;
 
  687        typedef FieldVector<RangeFieldType,localBlockSize> VectorType;
 
  688        VectorType fRhs(0.0);
 
  690        assert( numDofs == localBlockSize );
 
  691        if( numDofs != localBlockSize )
 
  693          DUNE_THROW(InvalidStateException,
"wrong sizes ");
 
  697        const bool nonSymetric = (cols != rows);
 
  700        typedef Fem::DenseMatrix<double> MatrixType;
 
  701        MatrixType matrix(rows,cols);
 
  702        typedef typename MatrixType :: RowType RowType;
 
  704        MatrixType fakeMatrix(cols,cols);
 
  705        RowType rhs(rows,0.0);
 
  706        RowType fakeRhs(numDofs,0.0);
 
  709        for(
const auto & en : 
space)
 
  717            for(
int i=0; i<rows; ++i)
 
  723            fillMatrix(gridPart_,en,uDG,
 
  725                       gradSpace_, overallFaceDofs,
 
  726                       elSpace_, rows - numBubbleDofs,
 
  727                       polOrd,numDofs,numFaceDofs,
 
  728                       rets,uRets, matrix,rhs);
 
  731            matrix.multTransposed(rhs, fakeRhs);
 
  732            fakeMatrix.multiply_AT_A(matrix);
 
  735            for(
int i=0; i<numDofs; ++i)
 
  737              fRhs[i] = fakeRhs[i];
 
  738              for(
int j=0; j<numDofs; ++j)
 
  740                inv[i][j] = fakeMatrix[i][j];
 
  751            assert( cols == rows );
 
  753            fillMatrix(gridPart_,en,uDG,
 
  755                       gradSpace_, rows - numBubbleDofs - numGradDofs,
 
  756                       elSpace_, rows - numBubbleDofs,
 
  757                       polOrd,numDofs,numFaceDofs,
 
  758                       rets, uRets, inv,fRhs);
 
  766            luSolve( inv, fRhs );
 
  767            const VectorType& x = fRhs ;
 
  769            for(
int i=0; i<localBlockSize; ++i)
 
  771              veloLF[ i ] = x[ i ];
 
  777      template <
class GridPartType,
 
  783      void fillMatrix(
const GridPartType& gridPart,
 
  784                      const EntityType& en,
 
  786                      const FaceDiscreteSpaceType& faceSpace,
 
  787                      const ElementGradientSpaceType& gradSpace, 
const int startGradDofs,
 
  788                      const ElementDiscreteSpaceType& elSpace, 
const int startBubbleDofs,
 
  789                      const int polOrd, 
const int numDofs, 
const int numFaceDofs,
 
  790                      ArrayType& rets, Array2Type& uRets,
 
  791                      MatrixType& matrix, VectorType& rhs)
 const 
  793        typedef typename GridPartType :: IntersectionIteratorType IntersectionIteratorType;
 
  794        typedef typename IntersectionIteratorType::Intersection IntersectionType;
 
  796        typedef typename FaceDiscreteSpaceType :: BaseFunctionSetType FaceBSetType  ;
 
  797        typedef typename FaceDiscreteSpaceType :: RangeType FaceRangeType;
 
  798        FaceRangeType faceVal;
 
  800        typedef typename DiscreteFunctionSpaceType::RangeType RangeType;
 
  802        RangeType neighRet (0.0);
 
  803        RangeType uPhi (0.0);
 
  806        typedef typename DiscreteFunctionType :: DiscreteFunctionSpaceType
 
  807          :: BaseFunctionSetType BaseFunctionSetType;
 
  813        const BaseFunctionSetType & bSet = uLF.baseFunctionSet();
 
  816        IntersectionIteratorType endnit = gridPart.iend(en);
 
  817        for(IntersectionIteratorType nit = gridPart.ibegin(en);
 
  818            nit != endnit; ++nit)
 
  820          const IntersectionType& inter=*nit;
 
  822          const FaceBSetType &faceSet = faceSpace.baseFunctionSet( inter.type() );
 
  824          const int firstRow = inter.indexInInside() * numFaceDofs;
 
  830            EntityType nb = inter.outside();
 
  838            if( inter.conforming() )
 
  841              FaceQuadratureType faceQuadInner(gridPart, inter, polOrd, FaceQuadratureType::INSIDE);
 
  842              FaceQuadratureType faceQuadOuter(gridPart, inter, polOrd, FaceQuadratureType::OUTSIDE);
 
  844              applyLocalNeighbor(nit,faceQuadInner,faceQuadOuter,
 
  845                                 bSet,faceSet, uLF, uNeighLf,
 
  846                                 firstRow, numFaceDofs,
 
  848                                 ret,neighRet,faceVal,
 
  854              typedef typename FaceQuadratureType ::
 
  855                NonConformingQuadratureType NonConformingQuadratureType;
 
  857              NonConformingQuadratureType faceQuadInner(gridPart, inter, polOrd, FaceQuadratureType::INSIDE);
 
  858              NonConformingQuadratureType faceQuadOuter(gridPart, inter, polOrd, FaceQuadratureType::OUTSIDE);
 
  860              applyLocalNeighbor(nit,faceQuadInner,faceQuadOuter,
 
  861                                 bSet,faceSet, uLF, uNeighLf,
 
  862                                 firstRow, numFaceDofs,
 
  864                                 ret,neighRet,faceVal,
 
  874            FaceQuadratureType faceQuadInner(gridPart, inter, polOrd, FaceQuadratureType::INSIDE);
 
  875            const int quadNop = faceQuadInner.nop();
 
  877            std::vector< RangeType > uPhiVec( numDofs );
 
  878            std::vector< FaceRangeType > faceValVec( numFaceDofs );
 
  880            for (
int l = 0; l < quadNop ; ++l)
 
  882              DomainType unitNormal =
 
  883                inter.integrationOuterNormal(faceQuadInner.localPoint(l));
 
  885              const double faceVol = unitNormal.two_norm();
 
  886              unitNormal *= 1.0/faceVol;
 
  889              const double intel = faceVol * faceQuadInner.weight(l);
 
  892              uLF.evaluate(faceQuadInner[l], ret);
 
  894              RangeFieldType val = ret * unitNormal;
 
  897              bSet.evaluateAll( faceQuadInner[l], uPhiVec );
 
  900              for(
int i=0; i<numDofs; ++i)
 
  902                rets[i]  = uPhiVec[ i ] * unitNormal;
 
  906              faceSet.evaluateAll( faceQuadInner[ l ], faceValVec );
 
  909              for(
int j=0; j<numFaceDofs; ++j, ++row)
 
  911                FaceRangeType& faceVal = faceValVec[ j ];
 
  912                rhs[row] += val*faceVal[0];
 
  914                for(
int i=0; i<numDofs; ++i)
 
  916                  matrix[row][i] += (faceVal[0] * rets[i]);
 
  926          gradientPart(gradSpace, en, uLF, startGradDofs, uRets, matrix, rhs );
 
  930        if( bubblePolOrd - bubblePModifier > 1 )
 
  932          bubblePart(elSpace, en, uLF, startBubbleDofs, uRets, matrix, rhs);
 
  938      template <
class MatrixType>
 
  939      void printMatrix(
const MatrixType& matrix)
 const 
  941        std::cout << 
"Print Matrix \n";
 
  942        for(
size_t row = 0; row < matrix.N(); ++row)
 
  944          std::cout << row << 
": ";
 
  945          for(
size_t col = 0; col< matrix.M(); ++col)
 
  947            if( std::abs(  matrix[row][col] ) < 1e-12 )
 
  950              std::cout << matrix[row][col] << 
" ";
 
  952          std::cout << std::endl;
 
  954        std::cout << 
"Finished print Matrix \n";
 
  957      template <
class IntersectionIteratorType,
 
  958                class QuadratureType,
 
  959                class BaseFunctionSetType,
 
  960                class FaceBaseFunctionSetType,
 
  961                class LocalFunctionType,
 
  967      static void applyLocalNeighbor(
const IntersectionIteratorType& nit,
 
  968                              const QuadratureType& faceQuadInner,
 
  969                              const QuadratureType& faceQuadOuter,
 
  970                              const BaseFunctionSetType& bSet,
 
  971                              const FaceBaseFunctionSetType& faceSet,
 
  972                              const LocalFunctionType& uLF,
 
  973                              const LocalFunctionType& uNeighLf,
 
  975                              const int numFaceDofs,
 
  977                              RangeType& ret, RangeType& neighRet,
 
  978                              FaceRangeType& faceVal,
 
  982        const typename IntersectionIteratorType::Intersection& inter = *nit;
 
  983        const int quadNop = faceQuadInner.nop();
 
  984        const int numDofs = uLF.numDofs();
 
  986        std::vector< RangeType > phiVec( numDofs );
 
  987        std::vector< FaceRangeType > facePhiVec( numFaceDofs );
 
  989        for (
int l = 0; l < quadNop ; ++l)
 
  991          DomainType unitNormal =
 
  992            inter.integrationOuterNormal(faceQuadInner.localPoint(l));
 
  995          const double faceVol = unitNormal.two_norm();
 
  996          unitNormal *= 1.0/faceVol;
 
  999          const double intel = faceVol * faceQuadInner.weight(l);
 
 1002          uLF.evaluate(faceQuadInner[l], ret);
 
 1003          uNeighLf.evaluate(faceQuadOuter[l], neighRet);
 
 1009          RangeFieldType val = ret * unitNormal;
 
 1012          bSet.evaluateAll( faceQuadInner[l], phiVec );
 
 1015          for(
int i=0; i<numDofs; ++i)
 
 1017            rets[i]  = phiVec[ i ] * unitNormal;
 
 1022          faceSet.evaluateAll( faceQuadInner[ l ], facePhiVec );
 
 1025          for(
int j=0; j<numFaceDofs; ++j, ++row )
 
 1027            FaceRangeType& faceVal = facePhiVec[ j ];
 
 1029            rhs[row] += val * faceVal[0];
 
 1031            for(
int i=0; i<numDofs; ++i)
 
 1033              matrix[row][i] += (faceVal[0] * rets[i]);
 
 1048      template <
class AdaptationType>
 
 1050                            AdaptationType& adaptation)
 
 1053        typedef typename GridType :: Traits :: LocalIdSet LocalIdSetType;
 
 1055        enum { dim = GridType :: dimension };
 
 1056        typedef typename GridType :: template 
Codim<0> :: Entity EntityType;
 
 1058        const DiscreteFunctionSpaceType& 
space = velo.
space();
 
 1059        GridPartType & gridPart = 
space.gridPart();
 
 1060        int polOrd = 
space.order() + 1;
 
 1063        const LocalIdSetType& localIdSet = gridPart.grid().localIdSet();
 
 1066        typedef CachingQuadrature<GridPartType,1> FaceQuadratureType;
 
 1068        for(
const auto & en : 
space)
 
 1071          const double enVol = en.
geometry().volume();
 
 1073          typedef typename GridPartType :: IntersectionIteratorType IntersectionIteratorType;
 
 1074          typedef typename IntersectionIteratorType :: Intersection IntersectionType;
 
 1075          IntersectionIteratorType endnit = gridPart.iend(en);
 
 1076          for(IntersectionIteratorType nit = gridPart.ibegin(en);
 
 1077              nit != endnit; ++nit)
 
 1079            const IntersectionType& inter=*nit;
 
 1080            double enError = 0.0;
 
 1082            if(inter.neighbor())
 
 1084              EntityType nb = inter.outside();
 
 1085              const double enVol_nbVol = 0.5 * (enVol + nb.geometry().volume());
 
 1089              const bool interiorEntity = (nb.partitionType() == 
InteriorEntity);
 
 1091              const bool interiorEntity = 
true;
 
 1093              if( (localIdSet.id( en ) < localIdSet.id( nb ))
 
 1095                 || ( ! interiorEntity )
 
 1104                if( inter.conforming() )
 
 1107                  FaceQuadratureType faceQuadInner(gridPart, inter, polOrd, FaceQuadratureType::INSIDE);
 
 1108                  FaceQuadratureType faceQuadOuter(gridPart, inter, polOrd, FaceQuadratureType::OUTSIDE);
 
 1110                  applyLocalNeighEstimator(nit,nb,faceQuadInner,faceQuadOuter,
 
 1111                                     uLF, uNeighLf, enVol_nbVol, interiorEntity,
 
 1112                                     enError, adaptation);
 
 1117                  typedef typename FaceQuadratureType ::
 
 1118                    NonConformingQuadratureType NonConformingQuadratureType;
 
 1120                  NonConformingQuadratureType faceQuadInner(gridPart, inter, polOrd, FaceQuadratureType::INSIDE);
 
 1121                  NonConformingQuadratureType faceQuadOuter(gridPart, inter, polOrd, FaceQuadratureType::OUTSIDE);
 
 1123                  applyLocalNeighEstimator(nit,nb,faceQuadInner,faceQuadOuter,
 
 1124                                     uLF, uNeighLf, enVol_nbVol, interiorEntity,
 
 1125                                     enError, adaptation);
 
 1133              adaptation.addToLocalIndicator( en , enError );
 
 1140      template <
class IntersectionIteratorType,
 
 1142                class QuadratureType,
 
 1143                class LocalFunctionType,
 
 1144                class AdaptationType>
 
 1145      static inline void applyLocalNeighEstimator(
const IntersectionIteratorType& nit,
 
 1146                              const EntityType& nb,
 
 1147                              const QuadratureType& faceQuadInner,
 
 1148                              const QuadratureType& faceQuadOuter,
 
 1149                              const LocalFunctionType& uLF,
 
 1150                              const LocalFunctionType& uNeighLf,
 
 1151                              const double enVol_nbVol,
 
 1152                              const bool interiorEntity,
 
 1154                              AdaptationType& adaptation)
 
 1156        const typename IntersectionIteratorType::Intersection& inter=*nit;
 
 1157        enum { dim = GridType :: dimension };
 
 1160        double nbError = 0.0;
 
 1162        const int quadNop = faceQuadInner.nop();
 
 1163        for (
int l = 0; l < quadNop ; ++l)
 
 1165          DomainType unitNormal =
 
 1166            inter.integrationOuterNormal(faceQuadInner.localPoint(l));
 
 1168          double faceVol = unitNormal.two_norm();
 
 1169          unitNormal *= 1.0/faceVol;
 
 1174            const double power = (1.0/(dim-1));
 
 1175            faceVol = pow(faceVol, 
power);
 
 1179          uLF.evaluate(faceQuadInner[l], jump);
 
 1180          uNeighLf.evaluate(faceQuadOuter[l], neighRet);
 
 1185          const double weight = (enVol_nbVol) * faceQuadInner.weight(l);
 
 1187          double error = weight * SQR(jump * unitNormal);
 
 1188          error = std::abs( error );
 
 1201          adaptation.addToLocalIndicator( nb , nbError );
 
 1210      template <
class MatrixType, 
class VectorType>
 
 1211      void luSolve(MatrixType& a,
 
 1212                   VectorType& x)
 const 
 1214        typedef typename VectorType :: field_type ctype;
 
 1215        enum { n = VectorType :: dimension };
 
 1218        assert( a.N() == a.M() );
 
 1219        assert( a.N() == n );
 
 1224        for(
int i=0; i<n-1; ++i)
 
 1231          for(
int k=i; k<n; ++k)
 
 1233            if ( std::abs(a[k][i]) > max_abs )
 
 1235              max_abs = fabs(a[k][i]);
 
 1243            for(
int j=0; j<n; ++j)
 
 1245              const ctype tmp = a[ p[i] ][j];
 
 1246              a[ p[i] ][j] = a[i][j];
 
 1252          for(
int k=i+1; k<n; ++k)
 
 1254            const ctype lambda = a[k][i] / a[i][i];
 
 1256            for(
int j=i+1; j<n; ++j) a[k][j] -= lambda * a[i][j];
 
 1261        for(
int i=0; i<n-1; ++i)
 
 1263          const ctype tmp = x[ i ];
 
 1264          x[ i ] = x[ p[ i ] ];
 
 1269        for(
int i=0; i<n; ++i)
 
 1272          for(
int j=0; j<i; ++j) 
dot += a[i][j] * x[j];
 
 1277        for(
int i=n-1; i>=0; --i)
 
 1280          for(
int j=i+1; j<n; ++j) 
dot += a[i][j] * x[j];
 
 1281          x[i] = (x[i] - 
dot) / a[i][i];
 
quadrature class supporting base function caching
Definition: cachingquadrature.hh:106
 
BaseType::LocalFunctionType LocalFunctionType
type of local functions
Definition: discretefunction.hh:639
 
void assign(const DiscreteFunctionInterface< DFType > &g)
Definition: discretefunction_inline.hh:132
 
LocalFunctionType localFunction(const EntityType &entity)
obtain a local function for an entity (read-write)
Definition: discretefunction.hh:716
 
FunctionSpaceTraits::RangeType RangeType
Type of range vector (using type of range field) has a Dune::FieldVector type interface.
Definition: functionspaceinterface.hh:71
 
FunctionSpaceTraits::RangeFieldType RangeFieldType
Intrinsic type used for values in the range field (usually a double)
Definition: functionspaceinterface.hh:63
 
A vector valued function space.
Definition: functionspace.hh:60
 
H-div Projection for discontinuous discrete functions. The projection is described in detail in:
Definition: hdivprojection.hh:62
 
void setTime(double)
set time for operators
Definition: hdivprojection.hh:206
 
double timeStepEstimate() const
estimate maximum time step
Definition: hdivprojection.hh:208
 
static double normalJump(const DiscreteFunctionType &discFunc, const int polyOrder=-1)
return sum of jumps of discrete function normal to intersection
Definition: hdivprojection.hh:213
 
const DiscreteFunctionSpaceType & space() const
return reference to space
Definition: hdivprojection.hh:202
 
HdivProjection(const DiscreteFunctionSpaceType &space)
constructor taking space
Definition: hdivprojection.hh:184
 
virtual void operator()(const DiscreteFunctionType &arg, DiscreteFunctionType &dest) const
application operator projection arg to H-div space
Definition: hdivprojection.hh:1041
 
Lagrange discrete function space.
Definition: space.hh:131
 
void evaluate(const PointType &x, RangeType &ret) const
evaluate the local function
Definition: localfunction.hh:320
 
const Geometry & geometry() const
obtain the geometry, this local function lives on
Definition: localfunction.hh:311
 
int numDofs() const
obtain the number of local DoFs
Definition: localfunction.hh:360
 
interface for time evolution operators
Definition: spaceoperatorif.hh:38
 
forward declaration
Definition: discretefunction.hh:51
 
const DiscreteFunctionSpaceType & space() const
obtain a reference to the corresponding DiscreteFunctionSpace
Definition: discretefunction.hh:709
 
TupleDiscreteFunctionSpace< typename DiscreteFunctions::DiscreteFunctionSpaceType ... > DiscreteFunctionSpaceType
type for the discrete function space this function lives in
Definition: discretefunction.hh:69
 
Implementation::JacobianInverseTransposed JacobianInverseTransposed
type of jacobian inverse transposed
Definition: geometry.hh:120
 
static constexpr int coorddimension
dimension of embedding coordinate system
Definition: geometry.hh:97
 
static constexpr int mydimension
geometry dimension
Definition: geometry.hh:94
 
Definition of the DUNE_NO_DEPRECATED_* macros.
 
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:132
 
auto dot(const A &a, const B &b) -> typename std::enable_if< IsNumber< A >::value &&!IsVector< A >::value &&!std::is_same< typename FieldTraits< A >::field_type, typename FieldTraits< A >::real_type > ::value, decltype(conj(a) *b)>::type
computes the dot product for fundamental data types according to Petsc's VectDot function: dot(a,...
Definition: dotproduct.hh:40
 
#define DUNE_THROW(E,...)
Definition: exceptions.hh:314
 
constexpr GeometryType cube(unsigned int dim)
Returns a GeometryType representing a hypercube of dimension dim.
Definition: type.hh:462
 
Dune namespace.
Definition: alignedallocator.hh:13
 
constexpr Base power(Base m, Exponent p)
Power method for integer exponents.
Definition: math.hh:75
 
static const ReferenceElement & general(const GeometryType &type)
get general reference elements
Definition: referenceelements.hh:156