1#ifndef DUNE_FEM_AGGLOMERATIONQUADRATURE_HH 
    2#define DUNE_FEM_AGGLOMERATIONQUADRATURE_HH 
    6#include <dune/fem/misc/threads/threadsafevalue.hh> 
    8#include "quadrature.hh" 
    9#include "elementquadrature.hh" 
   20    template< 
typename Gr
idPartImp, 
class IntegrationPo
intList >
 
   28      enum { codimension = 0 };
 
   31      enum { dimension = GridPartType :: dimension };
 
   34      enum { dimensionworld = GridPartType :: dimensionworld };
 
   37      typedef typename GridPartType :: ctype 
RealType;
 
   43      typedef int QuadratureKeyType;
 
   49      typedef PolyhedronQuadrature< RealType, dimension > PolyhedronQuadratureType;
 
   52      typedef std::stack< std::unique_ptr< PolyhedronQuadratureType > >  PolyhedronQuadratureStorageType;
 
   55      static PolyhedronQuadratureStorageType& quadStorage()
 
   62      static PolyhedronQuadratureType* getObject( 
const GeometryType& type )
 
   64        PolyhedronQuadratureStorageType& storage = quadStorage();
 
   71          PolyhedronQuadratureType* quad = storage.top().release();
 
   79      static void pushObject( 
const PolyhedronQuadratureType* quad )
 
   81        PolyhedronQuadratureType* polyQuad = 
const_cast< PolyhedronQuadratureType* 
> (quad);
 
   82        PolyhedronQuadratureStorageType& storage = quadStorage();
 
   83        if( storage.size() < 20 )
 
   85          storage.emplace( polyQuad );
 
   96        void operator ()(
const IntegrationPointListImpl* quad)
 
   98          const PolyhedronQuadratureType* polyQuad = 
static_cast< const PolyhedronQuadratureType* 
> ( quad );
 
   99          pushObject( polyQuad );
 
  106      template <
int dimw = dimensionworld >
 
  107      static std::enable_if_t<dimension == 2 && dimw == 2, IntegrationPointListType>
 
  110        typedef ElementQuadrature< GridPartImp, 0 > QuadratureType;
 
  115        const auto& elemGeo = entity.geometry();
 
  118        CoordinateType lower = elemGeo.
corner( 0 );
 
  119        CoordinateType upper = lower;
 
  120        const int corners = elemGeo.corners();
 
  121        for( 
int c = 1; c < corners; ++c )
 
  123          const auto& corner = elemGeo.corner( c );
 
  124          for( 
int d=0; d< dimension; ++d )
 
  126            lower[ d ] = std::min( lower[ d ], corner[ d ]);
 
  127            upper[ d ] = std::max( upper[ d ], corner[ d ]);
 
  133        CubeGeometryType cubeGeom( lower, upper );
 
  135        QuadratureType quad( simplexType, quadKey );
 
  137        const int subEntities = entity.subEntities( 1 );
 
  138        const int quadNop = quad.nop();
 
  139        int order = quad.order();
 
  141        PolyhedronQuadratureType& quadImp = *(getObject( entity.type() ));
 
  143        quadImp.reset( order, subEntities * quadNop );
 
  146        const auto& center = entity.geometry().center();
 
  148        for( 
int i = 0; i<subEntities; ++i )
 
  150          const auto subEntity = entity.template subEntity< 1 >( i );
 
  151          const auto& geom = subEntity.geometry();
 
  152          assert( geom.corners() == dimension );
 
  154          for( 
int c = 0; c<dimension; ++c )
 
  156            A[ c ]  = geom.corner( c );
 
  163          double vol =  std::abs(A.determinant()) / elemGeo.volume();
 
  165          CoordinateType point;
 
  166          for( 
int qp = 0; qp < quadNop; ++qp )
 
  169            A.mtv( quad.point( qp ), point );
 
  172            point = cubeGeom.local( point );
 
  175            double weight = quad.weight( qp ) * vol;
 
  177            quadImp.addQuadraturePoint( point, weight );
 
  182        std::shared_ptr< const IntegrationPointListImpl > quadPtr( &quadImp, Deleter() );
 
  186      template <
int dimw = dimensionworld >
 
  187      static std::enable_if_t<dimension != 2 || dimw != 2, IntegrationPointListType>
 
  191        return IntegrationPointListType( {} );
 
A geometry implementation for axis-aligned hypercubes.
 
A geometry implementation for axis-aligned hypercubes.
Definition: axisalignedcubegeometry.hh:50
 
GlobalCoordinate corner(int k) const
Return world coordinates of the k-th corner of the element.
Definition: axisalignedcubegeometry.hh:269
 
Agglomeration is a simple quadrature for polyhedral cells based on sub triangulation
Definition: agglomerationquadrature.hh:22
 
GridPartType::ctype RealType
type for reals (usually double)
Definition: agglomerationquadrature.hh:37
 
GridPartImp GridPartType
type of the grid partition
Definition: agglomerationquadrature.hh:25
 
static std::enable_if_t< dimension==2 &&dimw==2, IntegrationPointListType > computeQuadrature(const EntityType &entity, const QuadratureKeyType &quadKey)
returns quadrature points for polyhedral cells
Definition: agglomerationquadrature.hh:108
 
static IdProvider & instance()
Access to the singleton object.
Definition: idprovider.hh:21
 
actual interface class for integration point lists
Definition: quadrature.hh:158
 
Traits::IntegrationPointListType IntegrationPointListType
type of integration point list implementation
Definition: quadrature.hh:177
 
IntegrationPointListType::CoordinateType CoordinateType
type of coordinate
Definition: quadrature.hh:180
 
ThreadSafeValue realizes thread safety for a given variable by creating an instance of this variable ...
Definition: threadsafevalue.hh:18
 
A dense n x m matrix.
Definition: fmatrix.hh:117
 
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:114
 
constexpr GeometryType simplex(unsigned int dim)
Returns a GeometryType representing a simplex of dimension dim.
Definition: type.hh:453
 
Dune namespace.
Definition: alignedallocator.hh:13
 
Static tag representing a codimension.
Definition: dimension.hh:24