1#ifndef DUNE_FEM_GRIDWIDTH_HH 
    2#define DUNE_FEM_GRIDWIDTH_HH 
   10#include <dune/fem/storage/singletonlist.hh> 
   11#include <dune/fem/space/common/allgeomtypes.hh> 
   12#include <dune/fem/gridpart/leafgridpart.hh> 
   13#include <dune/fem/space/common/dofmanager.hh> 
   22    template <
class Gr
idPartImp, 
class MinMax = Min<
double> >
 
   23    class GridWidthProvider;
 
   29      template< 
class GridPartType, 
class EntityType,
 
   30                class ElemGeoInfoType, 
class FaceGeoInfoType >
 
   32      maxEdgeWidth ( 
const GridPartType & gridPart,
 
   33                     const EntityType& entity,
 
   34                     const ElemGeoInfoType &geoInfo,
 
   35                     const FaceGeoInfoType &faceGeoInfo )
 
   37        typedef typename GridPartType :: IntersectionIteratorType IntersectionIteratorType;
 
   39        int indexInInside = -1;
 
   43        const IntersectionIteratorType endit = gridPart.iend( entity );
 
   44        for( IntersectionIteratorType it = gridPart.ibegin( entity );
 
   47          typedef typename IntersectionIteratorType::Intersection 
Intersection;
 
   51          const LocalGeometryType &interGeo = intersection.
geometry();
 
   55          if( indexInInside != localIndex )
 
   57            if( indexInInside >= 0 )
 
   58              faceVol = std::min( faceVol, currVol*refFaceVol );
 
   60            refFaceVol = faceGeoInfo.referenceVolume( intersection.
type() );
 
   61            indexInInside = localIndex;
 
   65          currVol += interGeo.volume();
 
   69        if( indexInInside >= 0 )
 
   70          faceVol = std::min( faceVol, currVol*refFaceVol );
 
   72        const double elemVol = entity.geometry().volume()
 
   73                             * geoInfo.referenceVolume( entity.type() );
 
   74        return elemVol / faceVol;
 
   78      template <
class MinMax>
 
   82      struct MinMaxInit< Min< T > >
 
   91      struct MinMaxInit< Max< T > >
 
  107      template <
class Gr
idPartType, 
class MinMax>
 
  110                            const bool communicate,
 
  114        typedef typename GridPartType :: GridType GridType;
 
  115        typedef typename GridPartType :: template 
Codim<0> :: IteratorType IteratorType;
 
  119        GeomInfoType geoInfo( gridPart.indexSet() );
 
  123        FaceGeometryInformationType faceGeoInfo( geoInfo.geomTypes(1) );
 
  126        double width = MinMaxInit< MinMax > :: init() ;
 
  130           ! Capabilities::isLocallyAdaptive<GridType>::v  )
 
  133          IteratorType it = gridPart.template begin<0> ();
 
  134          if( it != gridPart.template end<0> () )
 
  136            width = minmax( maxEdgeWidth(gridPart,
 
  146          const IteratorType endit = gridPart.template end<0> ();
 
  147          for(IteratorType it = gridPart.template begin<0> ();
 
  150            width = minmax( maxEdgeWidth(gridPart,
 
  162          gridPart.comm().template allreduce<MinMax> ( &w, &width, 1 );
 
  167      template <
class Gr
idPartType>
 
  170                            const bool communicate = 
true)
 
  172        return calcGridWidth ( gridPart, communicate, Min<double>() );
 
  177    template <
class Gr
idType, 
class MinMax >
 
  188      typedef LeafGridPart< GridType > GridPartType;
 
  190      const GridType& grid_;
 
  193      GridPartType gridPart_;
 
  195      mutable double width_;
 
  196      mutable int sequence_;
 
  204        , gridPart_( const_cast<GridType& > (grid_) )
 
  218      void calcWidths()
 const 
  222        int check = (dm_.
sequence() != sequence_) ? 1 : 0;
 
  223        int willCalc = gridPart_.comm().min( check );
 
  224        assert( check == willCalc );
 
  232          assert( width_ > 0 );
 
helper classes to provide unique types for standard functions
 
Definition: dofmanager.hh:786
 
utility functions for calculating the maximum grid width
Definition: gridwidth.hh:179
 
double gridWidth() const
return characteristic grid width
Definition: gridwidth.hh:211
 
SingletonList< const GridType *, ThisType > ProviderType
type of singleton provider
Definition: gridwidth.hh:183
 
GridWidthProvider(const GridType *grid)
constructor taking grid part
Definition: gridwidth.hh:201
 
utility functions for calculating the maximum grid width
Definition: gridwidth.hh:27
 
static double calcGridWidth(const GridPartType &gridPart, const bool communicate, const MinMax &minmax)
calculate minimal grid width as  with .
Definition: gridwidth.hh:109
 
Singleton list for key/object pairs.
Definition: singletonlist.hh:53
 
Intersection of a mesh entity of codimension 0 ("element") with a "neighboring" element or with the d...
Definition: intersection.hh:164
 
Geometry geometry() const
geometrical information about the intersection in global coordinates.
Definition: intersection.hh:328
 
int indexInInside() const
Local index of codim 1 entity in the inside() entity where intersection is contained in.
Definition: intersection.hh:351
 
GeometryType type() const
obtain the type of reference element for this intersection
Definition: intersection.hh:334
 
GridImp::template Codim< 1 >::Geometry Geometry
Codim 1 geometry returned by geometry()
Definition: intersection.hh:195
 
A set of traits classes to store static information about grid implementation.
 
Implements a vector constructed from a given type representing a field and a compile-time given size.
 
int sequence() const
return number of sequence, if dofmanagers memory was changed by calling some method like resize,...
Definition: dofmanager.hh:1007
 
constexpr auto max
Function object that returns the greater of the given values.
Definition: hybridutilities.hh:485
 
constexpr auto min
Function object that returns the smaller of the given values.
Definition: hybridutilities.hh:507
 
Dune namespace.
Definition: alignedallocator.hh:13
 
Specialize with 'true' if the grid is a Cartesian grid. Cartesian grids satisfy the following propert...
Definition: capabilities.hh:48