1#ifndef DUNE_FEM_LOCALMASSMATRIX_HH 
    2#define DUNE_FEM_LOCALMASSMATRIX_HH 
   15#include <dune/fem/common/memory.hh> 
   16#include <dune/fem/common/utility.hh> 
   17#include <dune/fem/misc/checkgeomaffinity.hh> 
   18#include <dune/fem/quadrature/cachingquadrature.hh> 
   19#include <dune/fem/space/common/allgeomtypes.hh> 
   20#include <dune/fem/space/common/capabilities.hh> 
   21#include <dune/fem/version.hh> 
   35    template< 
class DiscreteFunctionSpace, 
class VolumeQuadrature, 
bool refElemScaling = true >
 
   42      typedef typename DiscreteFunctionSpaceType :: RangeFieldType ctype;
 
   43      typedef typename DiscreteFunctionSpaceType :: RangeFieldType RangeFieldType;
 
   44      typedef typename DiscreteFunctionSpaceType :: RangeType RangeType;
 
   46      enum { dimRange = DiscreteFunctionSpaceType :: dimRange };
 
   47      enum { localBlockSize = DiscreteFunctionSpaceType :: localBlockSize };
 
   48      enum { dgNumDofs = localBlockSize };
 
   53      typedef typename DiscreteFunctionSpaceType :: GridPartType GridPartType;
 
   55      typedef typename DiscreteFunctionSpaceType :: IndexSetType IndexSetType;
 
   58      typedef typename DiscreteFunctionSpaceType :: BasisFunctionSetType BasisFunctionSetType;
 
   60      typedef typename GridPartType :: GridType GridType;
 
   61      typedef typename DiscreteFunctionSpaceType :: EntityType  EntityType;
 
   62      typedef typename EntityType :: Geometry  Geometry;
 
   64      static const bool hasSingleGeometryType = Dune :: Capabilities :: hasSingleGeometryType< GridType > :: v;
 
   66      typedef VolumeQuadrature VolumeQuadratureType;
 
   81      std::shared_ptr< const DiscreteFunctionSpaceType > spc_;
 
   82      const IndexSetType& indexSet_;
 
   85      const std::function<int(
const int)> volumeQuadratureOrder_;
 
   96      mutable std::vector< RangeType > phi_;
 
   97      mutable std::vector< RangeType > phiMass_;
 
   99      mutable std::vector< std::shared_ptr< VolumeQuadratureType > > volumeQuadratures_;
 
  100      mutable std::mutex mutex_;
 
  102      typedef std::pair< std::unique_ptr< MatrixType >, std::unique_ptr< VectorType > > MatrixPairType;
 
  103      typedef std::map< const int, MatrixPairType > MassMatrixStorageType;
 
  104      typedef std::vector< MassMatrixStorageType > LocalInverseMassMatrixStorageType;
 
  106      mutable LocalInverseMassMatrixStorageType localInverseMassMatrix_;
 
  109      mutable IndexType lastEntityIndex_;
 
  110      mutable unsigned int lastTopologyId_ ;
 
  112      mutable int sequence_;
 
  114      struct NoMassDummyCaller
 
  119        bool hasMass ()
 const { 
return false; }
 
  121        void mass ( 
const EntityType &, 
const VolumeQuadratureType &, 
int, MassFactorType & )
 const 
  126      bool checkDiagonalMatrix( 
const MatrixType& matrix )
 const 
  128        const int rows = matrix.
rows();
 
  129        for( 
int r=0; r<rows; ++r )
 
  131          for( 
int c=0; c<r; ++c ) 
 
  134            if( std::abs(matrix[r][c]) > 1e-12 )
 
  141      template< 
class BasisFunctionSet >
 
  143      getLocalInverseMassMatrix ( 
const EntityType &entity, 
const Geometry &geo,
 
  147        typedef typename MassMatrixStorageType::iterator iterator;
 
  150        auto it = massMap.find( numBasisFct );
 
  151        if( it == massMap.end() )
 
  153          std::pair< iterator, bool > insertPair = massMap.insert( std::make_pair( numBasisFct, MatrixPairType(
nullptr,
nullptr) ) );
 
  154          it = insertPair.first;
 
  155          insertPair.first->second.first.reset( 
new MatrixType( numBasisFct, numBasisFct, 0.0 ));
 
  156          MatrixType& matrix = insertPair.first->second.first.operator *();
 
  159          const VolumeQuadratureType& volQuad = *volQuadPtr;
 
  167            std::cerr << 
"Matrix is singular:" << std::endl << matrix << std::endl;
 
  170          const bool diagonal = checkDiagonalMatrix( matrix );
 
  174            insertPair.first->second.second.reset( 
new VectorType( matrix.
rows() ) );
 
  175            VectorType& diag = insertPair.first->second.second.operator *();
 
  176            const int rows = matrix.
rows();
 
  177            for( 
int row=0; row<rows; ++row )
 
  179              diag[ row ] = matrix[ row ][ row ];
 
  187      template< 
class MassCaller, 
class BasisFunctionSet >
 
  188      MatrixType &getLocalInverseMassMatrixDefault ( MassCaller &caller, 
const EntityType &entity,
 
  191        const int numDofs = basisSet.
size();
 
  196          if( numDofs != 
int( matrix_.
rows() ) )
 
  197            matrix_.
resize( numDofs, numDofs );
 
  199          buildMatrix( caller, entity, geo, basisSet, numDofs, matrix_ );
 
  204        assert( numDofs == 
int( matrix_.
rows() ) );
 
  209      int maxNumDofs ()
 const 
  211        return space().blockMapper().maxNumDofs() * localBlockSize;
 
  217        return volumeQuadratureOrder_( space().order() );
 
  224        return volumeQuadratureOrder_( space().order( entity ) );
 
  235        : spc_( referenceToSharedPtr( spc ) )
 
  236        , indexSet_( space().indexSet() )
 
  237        , geoInfo_( indexSet_ )
 
  238        , volumeQuadratureOrder_ ( volQuadOrderFct )
 
  239        , affine_ ( 
setup() )
 
  240        , rhs_(), row_(), matrix_()
 
  241        , phi_( maxNumDofs() )
 
  242        , phiMass_( maxNumDofs() )
 
  243        , volumeQuadratures_( std::max(20, 4*spc.order()+4) ) 
 
  245        , lastEntityIndex_( -1 )
 
  246        , lastTopologyId_( ~0u )
 
  254        indexSet_( space().indexSet() ),
 
  255        geoInfo_( indexSet_ ),
 
  256        volumeQuadratureOrder_( other.volumeQuadratureOrder_ ),
 
  257        affine_( other.affine_ ),
 
  258        rhs_( other.rhs_ ), row_( other.row_ ), matrix_( other.matrix_ ),
 
  260        phiMass_( other.phiMass_ ),
 
  261        volumeQuadratures_( other.volumeQuadratures_ ),
 
  263        lastEntityIndex_( other.lastEntityIndex_ ),
 
  264        lastTopologyId_( other.lastTopologyId_ ),
 
  265        sequence_( other.sequence_ )
 
  268      std::shared_ptr< VolumeQuadratureType >
 
  269      getVolumeQuadrature( 
const EntityType& entity, 
const int order )
 const 
  271        std::shared_ptr< VolumeQuadratureType > volQuadPtr;
 
  274        if constexpr ( hasSingleGeometryType )
 
  276          assert( order < 
int(volumeQuadratures_.size()) );
 
  278          assert( ! entity.type().isNone() );
 
  279          if( ! volumeQuadratures_[ order ] )
 
  281            std::lock_guard< std::mutex > guard( mutex_ );
 
  283            if( ! volumeQuadratures_[ order ] )
 
  285              volumeQuadratures_[ order ].reset( 
new VolumeQuadrature( entity, order ) );
 
  288          volQuadPtr = volumeQuadratures_[ order ];
 
  294          volQuadPtr.reset( 
new VolumeQuadrature( entity, order ) );
 
  308        if constexpr( refElemScaling )
 
  315          return 1.0 / geo.volume();
 
  319      template< 
class BasisFunctionSet >
 
  328        if constexpr ( quadPointSetId == basePointSetId )
 
  330          const unsigned int numShapeFunctions = bfs.
size() / dimRange;
 
  332          return volQuadPtr->isInterpolationQuadrature(numShapeFunctions);
 
  339      template< 
class MassCaller, 
class BasisFunctionSet, 
class LocalFunction >
 
  342        Geometry geo = entity.geometry();
 
  343        if( ( 
affine() || geo.affine() || checkInterpolationBFS(basisFunctionSet) )
 
  344            && !caller.hasMass() )
 
  352      template< 
class MassCaller, 
class LocalFunction >
 
  359      template< 
class LocalFunction >
 
  362        NoMassDummyCaller caller;
 
  365      template< 
class BasisFunctionSet, 
class LocalFunction >
 
  368        NoMassDummyCaller caller;
 
  374      template< 
class LocalFunction >
 
  381      template< 
class LocalMatrix >
 
  384        const EntityType &entity = localMatrix.rangeEntity();
 
  385        Geometry geo = entity.geometry();
 
  386        if( ( 
affine() || geo.affine() || checkInterpolationBFS(localMatrix.rangeBasisFunctionSet())) )
 
  387          rightMultiplyInverseLocally( entity, geo, localMatrix );
 
  393      template< 
class LocalMatrix >
 
  396        const EntityType &entity = localMatrix.domainEntity();
 
  397        Geometry geo = entity.geometry();
 
  398        if( ( 
affine() || geo.affine() || checkInterpolationBFS(localMatrix.rangeBasisFunctionSet())) )
 
  404      const DiscreteFunctionSpaceType &space ()
 const { 
return *spc_; }
 
  414      template< 
class MassCaller, 
class BasisFunctionSet, 
class LocalFunction >
 
  415      void applyInverseDgOrthoNormalBasis ( MassCaller &caller, 
const EntityType &entity,
 
  416                                            const BasisFunctionSet &basisFunctionSet, LocalFunction &lf )
 const 
  419        assert( dgNumDofs == lf.size() );
 
  427        if( isAffine && !caller.hasMass() )
 
  432          for( 
int l = 0; l < dgNumDofs; ++l )
 
  433            lf[ l ] *= massVolInv;
 
  438          for( 
int l = 0; l < dgNumDofs; ++l )
 
  439            dgRhs_[ l ] = lf[ l ];
 
  441          buildMatrix( caller, entity, geo, basisFunctionSet, dgNumDofs, dgMatrix_ );
 
  442          dgMatrix_.
solve( dgX_, dgRhs_ );
 
  445          for( 
int l = 0; l < dgNumDofs; ++l )
 
  451      template< 
class LocalMatrix >
 
  454        const EntityType &entity = localMatrix.rangeEntity();
 
  455        Geometry geo = entity.geometry();
 
  456        assert( dgNumDofs == localMatrix.columns() );
 
  459        if( 
affine() || geo.affine() )
 
  465          NoMassDummyCaller caller;
 
  466          buildMatrix( caller, entity, geo, localMatrix.rangeBasisFunctionSet(), dgNumDofs, dgMatrix_ );
 
  469          const int rows = localMatrix.rows();
 
  470          for( 
int i = 0; i < rows; ++i )
 
  472            for( 
int j = 0; j < dgNumDofs; ++j )
 
  473              dgRhs_[ j ] = localMatrix.get( i, j );
 
  474            dgMatrix_.
mtv( dgRhs_, dgX_ );
 
  475            for( 
int j = 0; j < dgNumDofs; ++j )
 
  476              localMatrix.set( i, j, dgX_[ j ] );
 
  482      template< 
class LocalMatrix >
 
  485        const EntityType &entity = localMatrix.domainEntity();
 
  486        Geometry geo = entity.geometry();
 
  487        assert( dgNumDofs == localMatrix.columns() );
 
  490        if( 
affine() || geo.affine() )
 
  496          NoMassDummyCaller caller;
 
  497          buildMatrix( caller, entity, geo, localMatrix.domainBasisFunctionSet(), dgNumDofs, dgMatrix_ );
 
  500          const int rows = localMatrix.rows();
 
  501          for( 
int i = 0; i < rows; ++i )
 
  503            for( 
int j = 0; j < dgNumDofs; ++j )
 
  504              dgRhs_[ j ] = localMatrix.get( i, j );
 
  505            dgMatrix_.
mv( dgRhs_, dgX_ );
 
  506            for( 
int j = 0; j < dgNumDofs; ++j )
 
  507              localMatrix.set( i, j, dgX_[ j ] );
 
  516        const int currentSequence   = space().sequence();
 
  517        const unsigned int topologyId = entity.type().id();
 
  518        const IndexType entityIndex = indexSet_.index( entity ) ;
 
  521        if( sequence_ != currentSequence ||
 
  522            lastEntityIndex_ != entityIndex ||
 
  523            lastTopologyId_  != topologyId )
 
  526          lastEntityIndex_ = entityIndex ;
 
  527          sequence_        = currentSequence;
 
  528          lastTopologyId_  = topologyId ;
 
  542      template< 
class MassCaller, 
class BasisFunctionSet, 
class LocalFunction >
 
  548          = getLocalInverseMassMatrixDefault ( caller, entity, geo, basisFunctionSet );
 
  551        const int numDofs = lf.
size();
 
  552        rhs_.resize( numDofs );
 
  553        for( 
int l = 0; l < numDofs; ++l )
 
  557        multiply( numDofs, invMassMatrix, rhs_, lf );
 
  561      template< 
class LocalMatrix >
 
  564        NoMassDummyCaller caller;
 
  566          = getLocalInverseMassMatrixDefault ( caller, entity, geo, localMatrix.rangeBasisFunctionSet() );
 
  568        const int cols = localMatrix.columns();
 
  572        const int rows = localMatrix.rows();
 
  573        for( 
int i = 0; i < rows; ++i )
 
  576          for( 
int j = 0; j < cols; ++j )
 
  577            rhs_[ j ] = localMatrix.get( i, j );
 
  580          invMassMatrix.
mtv( rhs_, row_ );
 
  583          for( 
int j = 0; j < cols; ++j )
 
  584            localMatrix.set( i, j, row_[ j ] );
 
  589      template< 
class LocalMatrix >
 
  592        NoMassDummyCaller caller;
 
  594          = getLocalInverseMassMatrixDefault ( caller, entity, geo, localMatrix.rangeBasisFunctionSet() );
 
  596        const int cols = localMatrix.columns();
 
  600        const int rows = localMatrix.rows();
 
  601        for( 
int i = 0; i < rows; ++i )
 
  604          for( 
int j = 0; j < cols; ++j )
 
  605            rhs_[ j ] = localMatrix.get( j, i );
 
  608          invMassMatrix.
mv( rhs_, row_ );
 
  611          for( 
int j = 0; j < cols; ++j )
 
  612            localMatrix.set( j, i, row_[ j ] );
 
  621      template< 
class BasisFunctionSet, 
class LocalFunction >
 
  625        const int numDofs = lf.
size();
 
  628        MatrixPairType& matrixPair =
 
  629          getLocalInverseMassMatrix( entity, geo, basisFunctionSet, numDofs );
 
  632        if( matrixPair.second )
 
  634          const VectorType& diagonal = *matrixPair.second;
 
  635          assert( 
int(diagonal.size()) == numDofs );
 
  638          const VolumeQuadratureType& volQuad = *volQuadPtr;
 
  640          const int nop = volQuad.nop();
 
  641          assert(nop*dimRange == numDofs);
 
  642          for( 
int l=0, qt = 0; qt < nop; ++qt )
 
  644            const auto intel = geo.integrationElement( volQuad.point(qt) );
 
  645            for (
int r = 0; r < dimRange; ++r, ++l )
 
  647              lf[ l ] *= diagonal[ l ] / intel;
 
  656          rhs_.resize( numDofs );
 
  657          for( 
int l = 0; l < numDofs; ++l )
 
  658            rhs_[ l ] = lf[ l ] * massVolInv;
 
  660          const MatrixType& invMassMatrix = *matrixPair.first;
 
  662          multiply( numDofs, invMassMatrix, rhs_, lf );
 
  666      template <
class LocalMatrix>
 
  668      setupInverseDiagonal( 
const EntityType &entity, 
const Geometry &geo,
 
  669                            const VectorType& refElemDiagonal,
 
  670                            LocalMatrix &localMatrix )
 const 
  672        const int cols = localMatrix.columns();
 
  674        assert( 
int(refElemDiagonal.size()) == cols );
 
  677        const VolumeQuadratureType& volQuad = *volQuadPtr;
 
  679        VectorType& elementDiagonal = rhs_;
 
  680        elementDiagonal.resize( cols );
 
  682        const int nop = volQuad.nop();
 
  683        assert(nop*dimRange == cols);
 
  684        for( 
int l = 0, qt = 0; qt < nop; ++qt )
 
  687          for (
int r = 0; r < dimRange; ++r,++l )
 
  689            elementDiagonal[ l ] = refElemDiagonal[ l ] / intel;
 
  692        return elementDiagonal;
 
  695      template< 
class LocalMatrix >
 
  696      void rightMultiplyInverseLocally ( 
const EntityType &entity, 
const Geometry &geo, LocalMatrix &localMatrix )
 const 
  698        const int cols = localMatrix.columns();
 
  699        MatrixPairType& matrixPair =
 
  700          getLocalInverseMassMatrix( entity, geo, localMatrix.rangeBasisFunctionSet(), cols );
 
  704        if( matrixPair.second )
 
  706          const VectorType& elementDiagonal =
 
  707            setupInverseDiagonal( entity, geo, *matrixPair.second, localMatrix );
 
  710          const int rows = localMatrix.rows();
 
  711          for( 
int i = 0; i < rows; ++i )
 
  715            for( 
int j = 0; j < cols; ++j )
 
  716              row_[ j ] = elementDiagonal[ j ] * localMatrix.get( i, j );
 
  719            for( 
int j = 0; j < cols; ++j )
 
  720              localMatrix.set( i, j, row_[ j ] );
 
  725          const MatrixType &invMassMatrix = *matrixPair.first;
 
  732          const int rows = localMatrix.rows();
 
  733          for( 
int i = 0; i < rows; ++i )
 
  737            for( 
int j = 0; j < cols; ++j )
 
  738              rhs_[ j ] = localMatrix.get( i, j ) * massVolInv;
 
  741            invMassMatrix.mtv( rhs_, row_ );
 
  744            for( 
int j = 0; j < cols; ++j )
 
  745              localMatrix.set( i, j, row_[ j ] );
 
  751      template< 
class LocalMatrix >
 
  754        const int cols = localMatrix.columns();
 
  755        MatrixPairType& matrixPair =
 
  756          getLocalInverseMassMatrix( entity, geo, localMatrix.rangeBasisFunctionSet(), cols );
 
  760        if( matrixPair.second )
 
  763            setupInverseDiagonal( entity, geo, *matrixPair.second, localMatrix );
 
  766          const int rows = localMatrix.rows();
 
  767          for( 
int i = 0; i < rows; ++i )
 
  771            for( 
int j = 0; j < cols; ++j )
 
  772              row_[ j ] = elementDiagonal[ j ] * localMatrix.get( j, i );
 
  775            for( 
int j = 0; j < cols; ++j )
 
  776              localMatrix.set( j, i, row_[ j ] );
 
  781          const MatrixType &invMassMatrix = *matrixPair.first;
 
  788          const int rows = localMatrix.rows();
 
  789          for( 
int i = 0; i < rows; ++i )
 
  792            for( 
int j = 0; j < cols; ++j )
 
  793              rhs_[ j ] = localMatrix.get( j, i ) * massVolInv;
 
  796            invMassMatrix.
mv( rhs_, row_ );
 
  799            for( 
int j = 0; j < cols; ++j )
 
  800              localMatrix.set( j, i, row_[ j ] );
 
  814        const std::vector<Dune::GeometryType>& geomTypes = geoInfo_.
geomTypes(0);
 
  817        if( (geomTypes.size() == 1) && geomTypes[0].isSimplex() )
 
  827      template< 
class MassCaller, 
class Matrix >
 
  829                         const Geometry &geo, 
const BasisFunctionSetType &set,
 
  830                         std::size_t numDofs, 
Matrix &matrix )
 const 
  832        assert( numDofs == set.size() );
 
  839        const VolumeQuadratureType& volQuad = *volQuadPtr;
 
  841        if( caller.hasMass() )
 
  848      template <
class Matrix>
 
  850                       const EntityType& en,
 
  852                       const BasisFunctionSetType& set,
 
  853                       const VolumeQuadratureType& volQuad,
 
  856                       const bool applyIntegrationElement = 
true )
 const 
  858        const int volNop = volQuad.nop();
 
  859        for(
int qp=0; qp<volNop; ++qp)
 
  862          const double intel = ( applyIntegrationElement ) ?
 
  863              ( volQuad.weight(qp) * geo.integrationElement(volQuad.point(qp)) ) : volQuad.weight(qp) ;
 
  866          set.evaluateAll(volQuad[qp], phi_);
 
  868          for(
int m=0; m<numDofs; ++m)
 
  870            const RangeType& phi_m = phi_[m];
 
  871            const ctype val = intel * (phi_m * phi_m);
 
  874            for(
int k=m+1; k<numDofs; ++k)
 
  876              const ctype val = intel * (phi_m * phi_[k]);
 
  885      template <
class MassCallerType, 
class Matrix>
 
  887                       MassCallerType& caller,
 
  888                       const EntityType& en,
 
  890                       const BasisFunctionSetType& set,
 
  891                       const VolumeQuadratureType& volQuad,
 
  895        typedef typename MassCallerType :: MassFactorType MassFactorType;
 
  898        const int volNop = volQuad.nop();
 
  899        for(
int qp=0; qp<volNop; ++qp)
 
  902          const double intel = volQuad.weight(qp)
 
  903             * geo.integrationElement(volQuad.point(qp));
 
  906          set.evaluateAll( volQuad[qp], phi_);
 
  909          caller.mass( en, volQuad, qp, mass);
 
  912          for(
int m=0; m<numDofs; ++m)
 
  914            mass.mv( phi_[m], phiMass_[m] );
 
  918          for(
int m=0; m<numDofs; ++m)
 
  920            for(
int k=0; k<numDofs; ++k)
 
  922              matrix[m][k] += intel * (phiMass_[m] * phi_[k]);
 
  929      template <
class Matrix, 
class Rhs, 
class X>
 
  930      void multiply( 
const int size,
 
  935        assert( (
int) matrix.rows() == 
size );
 
  936        assert( (
int) matrix.cols() == 
size );
 
  937        assert( (
int) rhs.size() == 
size );
 
  939        for( 
int row = 0; row < 
size; ++ row )
 
  941          RangeFieldType sum = 0;
 
  943          typedef typename Matrix :: const_row_reference  MatRow;
 
  944          MatRow matRow = matrix[ row ];
 
  947          for( 
int col = 0; col < 
size; ++ col )
 
  949            sum += matRow[ col ] * rhs[ col ];
 
  964    template< 
class DiscreteFunctionSpace, 
class VolumeQuadrature >
 
  984    template< 
class DiscreteFunctionSpace, 
class VolumeQuadrature, 
bool refElemScaling = true >
 
  991      typedef typename BaseType :: EntityType  EntityType;
 
  998      template <
class MassCallerType, 
class BasisFunction, 
class LocalFunctionType>
 
 1000                        const EntityType& en,
 
 1001                        const BasisFunction &basisFunction,
 
 1002                        LocalFunctionType& lf)
 const 
 1004        BaseType :: applyInverseDgOrthoNormalBasis( caller, en, basisFunction, lf );
 
 1006      template <
class MassCallerType, 
class LocalFunctionType>
 
 1008                        const EntityType& en,
 
 1009                        LocalFunctionType& lf)
 const 
 1011        BaseType :: applyInverseDgOrthoNormalBasis( caller, en, lf.basisFunctionSet(), lf );
 
 1015      template <
class LocalFunctionType>
 
 1017                        LocalFunctionType& lf)
 const 
 1019        typename BaseType :: NoMassDummyCaller caller;
 
 1023      template <
class BasisFunction, 
class LocalFunctionType>
 
 1025                        const BasisFunction &basisFunction,
 
 1026                        LocalFunctionType& lf)
 const 
 1028        typename BaseType :: NoMassDummyCaller caller;
 
 1033      template< 
class LocalFunction >
 
 1040      template< 
class LocalMatrix >
 
 1047      template< 
class LocalMatrix >
 
void solve(V1 &x, const V2 &b, bool doPivoting=true) const
Solve system A x = b.
 
void invert(bool doPivoting=true)
Compute inverse.
 
constexpr size_type rows() const
number of rows
Definition: densematrix.hh:714
 
constexpr void mv(const X &x, Y &y) const
y = A x
Definition: densematrix.hh:373
 
constexpr void mtv(const X &x, Y &y) const
y = A^T x
Definition: densematrix.hh:392
 
void resize(size_type r, size_type c, value_type v=value_type())
resize matrix to r × c
Definition: dynmatrix.hh:106
 
Error thrown if operations of a FieldMatrix fail.
Definition: densematrix.hh:131
 
BaseType::IndexType IndexType
index type */
Definition: adaptiveleafindexset.hh:125
 
const std ::vector< GeometryType > & geomTypes(unsigned int codim) const
returns vector with geometry tpyes this index set has indices for
Definition: allgeomtypes.hh:171
 
Interface class for basis function sets.
Definition: basisfunctionset.hh:32
 
const EntityType & entity() const
return entity
 
std::size_t size() const
return size of basis function set
 
interface for local functions
Definition: localfunction.hh:77
 
const EntityType & entity() const
obtain the entity, this local function lives on
Definition: localfunction.hh:305
 
const BasisFunctionSetType & basisFunctionSet() const
obtain the basis function set for this local function
Definition: localfunction.hh:299
 
SizeType size() const
obtain the number of local DoFs
Definition: localfunction.hh:369
 
DG Local Mass Matrix for arbitrary spaces.
Definition: localmassmatrix.hh:987
 
void applyInverse(const EntityType &en, LocalFunctionType &lf) const
apply local dg mass matrix to local function lf without mass factor
Definition: localmassmatrix.hh:1016
 
void rightMultiplyInverse(LocalMatrix &localMatrix) const
compute localMatrix * M^-1
Definition: localmassmatrix.hh:1041
 
void applyInverse(MassCallerType &caller, const EntityType &en, const BasisFunction &basisFunction, LocalFunctionType &lf) const
Definition: localmassmatrix.hh:999
 
void applyInverse(LocalFunction &lf) const
apply local dg mass matrix to local function lf without mass factor
Definition: localmassmatrix.hh:1034
 
void leftMultiplyInverse(LocalMatrix &localMatrix) const
compute M^-1 * localMatrix
Definition: localmassmatrix.hh:1048
 
Local Mass Matrix inversion implementation, select the correct method in your implementation.
Definition: localmassmatrix.hh:37
 
void buildMatrixNoMassFactor(const EntityType &en, const Geometry &geo, const BasisFunctionSetType &set, const VolumeQuadratureType &volQuad, const int numDofs, Matrix &matrix, const bool applyIntegrationElement=true) const
build local mass matrix with mass factor
Definition: localmassmatrix.hh:849
 
void applyInverseDefault(MassCaller &caller, const EntityType &entity, const Geometry &geo, const BasisFunctionSet &basisFunctionSet, LocalFunction &lf) const
Definition: localmassmatrix.hh:543
 
void leftMultiplyInverse(LocalMatrix &localMatrix) const
compute M^-1 * localMatrix
Definition: localmassmatrix.hh:394
 
void leftMultiplyInverseLocally(const EntityType &entity, const Geometry &geo, LocalMatrix &localMatrix) const
compute M^-1 * localMatrix
Definition: localmassmatrix.hh:752
 
bool entityHasChanged(const EntityType &entity) const
returns true if the entity has been changed
Definition: localmassmatrix.hh:513
 
LocalMassMatrixImplementation(const DiscreteFunctionSpaceType &spc, int volQuadOrd)
constructor taking space and volume quadrature order
Definition: localmassmatrix.hh:228
 
void applyInverse(MassCaller &caller, const EntityType &entity, const BasisFunctionSet &basisFunctionSet, LocalFunction &lf) const
Definition: localmassmatrix.hh:340
 
bool affine() const
returns true if geometry mapping is affine
Definition: localmassmatrix.hh:301
 
double getAffineMassFactor(const Geometry &geo) const
return mass factor for diagonal mass matrix
Definition: localmassmatrix.hh:304
 
void applyInverseLocally(const EntityType &entity, const Geometry &geo, const BasisFunctionSet &basisFunctionSet, LocalFunction &lf) const
apply local mass matrix to local function lf
Definition: localmassmatrix.hh:622
 
void applyInverse(const EntityType &entity, LocalFunction &lf) const
apply local dg mass matrix to local function lf without mass factor
Definition: localmassmatrix.hh:360
 
void applyInverse(LocalFunction &lf) const
apply local dg mass matrix to local function lf without mass factor
Definition: localmassmatrix.hh:375
 
void buildMatrix(MassCaller &caller, const EntityType &entity, const Geometry &geo, const BasisFunctionSetType &set, std::size_t numDofs, Matrix &matrix) const
build local mass matrix
Definition: localmassmatrix.hh:828
 
void rightMultiplyInverseDgOrthoNormalBasis(LocalMatrix &localMatrix) const
compute localMatrix * M^-1
Definition: localmassmatrix.hh:452
 
int maxVolumeQuadratureOrder() const
return appropriate quadrature order, default is 2 * order()
Definition: localmassmatrix.hh:215
 
LocalMassMatrixImplementation(const ThisType &other)
copy constructor
Definition: localmassmatrix.hh:252
 
int volumeQuadratureOrder(const EntityType &entity) const
return appropriate quadrature order, default is 2 * order(entity)
Definition: localmassmatrix.hh:222
 
void rightMultiplyInverseDefault(const EntityType &entity, const Geometry &geo, LocalMatrix &localMatrix) const
compute localMatrix * M^-1
Definition: localmassmatrix.hh:562
 
void applyInverse(MassCaller &caller, const EntityType &entity, LocalFunction &lf) const
Definition: localmassmatrix.hh:353
 
void buildMatrixWithMassFactor(MassCallerType &caller, const EntityType &en, const Geometry &geo, const BasisFunctionSetType &set, const VolumeQuadratureType &volQuad, const int numDofs, Matrix &matrix) const
build local mass matrix with mass factor
Definition: localmassmatrix.hh:886
 
void rightMultiplyInverse(LocalMatrix &localMatrix) const
compute localMatrix * M^-1
Definition: localmassmatrix.hh:382
 
void leftMultiplyInverseDefault(const EntityType &entity, const Geometry &geo, LocalMatrix &localMatrix) const
compute M^-1 * localMatrix
Definition: localmassmatrix.hh:590
 
LocalMassMatrixImplementation(const DiscreteFunctionSpaceType &spc, std::function< int(const int)> volQuadOrderFct=[](const int order) { return Capabilities::DefaultQuadrature< DiscreteFunctionSpaceType >::volumeOrder(order);})
constructor taking space and volume quadrature order
Definition: localmassmatrix.hh:233
 
bool setup() const
setup and return affinity
Definition: localmassmatrix.hh:807
 
void leftMultiplyInverseDgOrthoNormalBasis(LocalMatrix &localMatrix) const
compute M^-1 * localMatrix
Definition: localmassmatrix.hh:483
 
Local Mass Matrix for arbitrary spaces.
Definition: localmassmatrix.hh:967
 
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:114
 
Wrapper class for geometries.
Definition: geometry.hh:71
 
Volume integrationElement(const LocalCoordinate &local) const
Return the factor appearing in the integral transformation formula.
Definition: geometry.hh:265
 
bool affine() const
Return true if the geometry mapping is affine and false otherwise.
Definition: geometry.hh:197
 
Compute indices for geometry types, taking the dimension into account.
Definition: typeindex.hh:90
 
static constexpr std::size_t index(const GeometryType >)
Compute the index for the given geometry type over all dimensions.
Definition: typeindex.hh:138
 
static constexpr std::size_t size(std::size_t maxdim)
Compute total number of geometry types up to and including the given dimension.
Definition: typeindex.hh:125
 
A generic dynamic dense matrix.
Definition: matrix.hh:561
 
This file implements a dense matrix with dynamic numbers of rows and columns.
 
Implements a matrix constructed from a given type representing a field and compile-time given number ...
 
Dune namespace.
Definition: alignedallocator.hh:13
 
constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std::integer_sequence< T, II... >)
Return the size of the sequence.
Definition: integersequence.hh:75
 
Specialize with 'true' if the grid is a Cartesian grid. Cartesian grids satisfy the following propert...
Definition: capabilities.hh:48
 
static int volumeOrder(const int k)
return quadrature order for volume quadratures for given polynomial order k
Definition: capabilities.hh:149
 
Helper class to check affinity of the grid's geometries.
Definition: checkgeomaffinity.hh:22
 
selects Obj::pointSetId if available, otherwise defaultValue (default is -1)
Definition: utility.hh:174
 
Helper classes to provide indices for geometrytypes for use in a vector.