1#ifndef DUNE_FEM_SPACE_COMMON_UNIQUEFACETORIENTATION_HH 
    2#define DUNE_FEM_SPACE_COMMON_UNIQUEFACETORIENTATION_HH 
    7#include <dune/grid/common/rangegenerators.hh> 
    9#include <dune/fem/common/utility.hh> 
   10#include <dune/fem/gridpart/common/capabilities.hh> 
   11#include <dune/fem/space/common/functionspace.hh> 
   12#include <dune/fem/space/finitevolume.hh> 
   13#include <dune/fem/space/mapper/parallel.hh> 
   24    template< 
class Gr
idPart >
 
   25    struct DefaultUniqueFacetOrientation
 
   27      typedef GridPart GridPartType;
 
   28      typedef typename GridPartType::template Codim< 0 >::EntityType EntityType;
 
   30      typedef FunctionSpace< double, int, GridPartType::dimensionworld, 1 >  
FunctionSpaceType;
 
   31      typedef FiniteVolumeSpace< FunctionSpaceType, GridPartType, 0, SimpleStorage > 
SpaceType;
 
   33      typedef ParallelDofMapper< GridPartType, typename SpaceType::BlockMapperType > ParallelMapperType;
 
   34      typedef typename ParallelMapperType :: GlobalKeyType  GlobalKeyType;
 
   36      explicit DefaultUniqueFacetOrientation ( 
const GridPartType &gridPart )
 
   37        : gridPart_( gridPart ),
 
   38          space_( const_cast< GridPartType& > (gridPart_) ),
 
   39          parallelMapper_( gridPart_, space_.blockMapper(), space_.communicationInterface() ),
 
   44      unsigned int operator() ( 
const EntityType &entity )
 const 
   46        if( sequence_ != space_.sequence() )
 
   48          parallelMapper_.update();
 
   49          sequence_ = space_.sequence();
 
   52        unsigned int orientations = 0;
 
   53        for( 
auto intersection : intersections( gridPart(), entity ) )
 
   55          if( intersection.neighbor() && (globallyUniqueIndex( entity ) < globallyUniqueIndex( intersection.outside() )) )
 
   56            orientations |= (1 << intersection.indexInInside());
 
   61      template <
class Entity>
 
   62      GlobalKeyType globallyUniqueIndex( 
const Entity& entity )
 const 
   64        GlobalKeyType index = -1;
 
   65        parallelMapper_.mapEach( entity, [ &index ] ( 
auto local, 
auto global ) { assert( local == 0 ); index = global; } );
 
   69      const GridPartType &gridPart ()
 const { 
return gridPart_; }
 
   72      const GridPartType& gridPart_;
 
   74      mutable ParallelMapperType  parallelMapper_;
 
   75      mutable int sequence_;
 
   83    template< 
class Gr
idPart >
 
   84    struct CartesianUniqueFacetOrientation
 
   86      typedef GridPart GridPartType;
 
   87      typedef typename GridPart::template Codim< 0 >::EntityType EntityType;
 
   89      explicit CartesianUniqueFacetOrientation ( 
const GridPartType &gridPart )
 
   90        : gridPart_( gridPart )
 
   93      unsigned int operator() ( 
const EntityType &entity )
 const 
   95        return orientations( std::make_index_sequence< GridPartType::dimension >() );
 
   98      const GridPartType &gridPart ()
 const { 
return gridPart_; }
 
  101      template< std::size_t... i >
 
  102      static constexpr unsigned int orientations ( std::index_sequence< i... > )
 
  104        return Std::sum( (1u << 2*i)... );
 
  107      const GridPartType &gridPart_;
 
  115    template< 
class Gr
idPart >
 
  116    using UniqueFacetOrientation =
 
  117      typename std::conditional< GridPartCapabilities::isCartesian< GridPart >::v,
 
  118                                 CartesianUniqueFacetOrientation< GridPart>,
 
  119                                 DefaultUniqueFacetOrientation< GridPart > >::type;
 
A vector valued function space.
Definition: functionspace.hh:60
 
Dune namespace.
Definition: alignedallocator.hh:13