1#ifndef DUNE_FEM_GRIDWIDTH_HH
2#define DUNE_FEM_GRIDWIDTH_HH
8#include <dune/common/fvector.hh>
9#include <dune/grid/common/capabilities.hh>
14#include <dune/common/binaryfunctions.hh>
22 template <
class Gr
idPartImp,
class MinMax = Min<
double> >
23 class GridWidthProvider;
29 template<
class GridPartType,
class EntityType,
30 class ElemGeoInfoType,
class FaceGeoInfoType >
33 const EntityType& entity,
34 const ElemGeoInfoType &geoInfo,
35 const FaceGeoInfoType &faceGeoInfo )
37 typedef typename GridPartType :: IntersectionIteratorType IntersectionIteratorType;
38 double faceVol = std::numeric_limits<double>::max() ;
39 int indexInInside = -1;
40 double currVol = std::numeric_limits<double>::min() ;
41 double refFaceVol = std::numeric_limits<double>::min() ;
43 const IntersectionIteratorType endit = gridPart.iend( entity );
44 for( IntersectionIteratorType it = gridPart.ibegin( entity );
47 typedef typename IntersectionIteratorType::Intersection Intersection;
48 const Intersection &intersection = *it;
50 typedef typename Intersection::Geometry LocalGeometryType;
51 const LocalGeometryType &interGeo = intersection.geometry();
53 const int localIndex = intersection.indexInInside();
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>
86 return std::numeric_limits< T >::max() ;
95 return std::numeric_limits< T >::min() ;
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) );
129 if( Dune::Capabilities::isCartesian<GridType>::v &&
133 IteratorType it = gridPart.template begin<0> ();
134 if( it != gridPart.template end<0> () )
146 const IteratorType endit = gridPart.template end<0> ();
147 for(IteratorType it = gridPart.template begin<0> ();
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 >
180 typedef GridWidthProvider < GridType, MinMax >
ThisType;
224 assert( check == willCalc );
int sequence() const
return number of sequence, if dofmanagers memory was changed by calling some method like resize,...
Definition: dofmanager.hh:978
double min(const Dune::Fem::Double &v, const double p)
Definition: double.hh:953
Definition: bindguard.hh:11
const CollectiveCommunicationType & comm() const
obtain collective communication object
Definition: gridview2gridpart.hh:193
Definition: misc/capabilities.hh:151
utility functions for calculating the maximum grid width
Definition: gridwidth.hh:179
double gridWidth() const
return characteristic grid width
Definition: gridwidth.hh:211
GridPartType gridPart_
Definition: gridwidth.hh:193
GridWidthProvider(const ThisType &)
int sequence_
Definition: gridwidth.hh:196
SingletonList< const GridType *, ThisType > ProviderType
type of singleton provider
Definition: gridwidth.hh:183
void calcWidths() const
Definition: gridwidth.hh:218
DofManager< GridType > DofManagerType
Definition: gridwidth.hh:186
LeafGridPart< GridType > GridPartType
Definition: gridwidth.hh:188
const GridType & grid_
Definition: gridwidth.hh:190
const DofManagerType & dm_
Definition: gridwidth.hh:191
GridWidthProvider(const GridType *grid)
constructor taking grid part
Definition: gridwidth.hh:201
double width_
Definition: gridwidth.hh:195
utility functions for calculating the maximum grid width
Definition: gridwidth.hh:27
static double maxEdgeWidth(const GridPartType &gridPart, const EntityType &entity, const ElemGeoInfoType &geoInfo, const FaceGeoInfoType &faceGeoInfo)
Definition: gridwidth.hh:32
static double calcGridWidth(const GridPartType &gridPart, const bool communicate, const MinMax &minmax)
calculate minimal grid width as with .
Definition: gridwidth.hh:109
static double calcGridWidth(const GridPartType &gridPart, const bool communicate=true)
Definition: gridwidth.hh:169
Definition: gridwidth.hh:79
static T init()
Definition: gridwidth.hh:84
static T init()
Definition: gridwidth.hh:93
ReferenceVolume and local bary center keeper class.
Definition: allgeomtypes.hh:30
default implementation uses method geomTypes of given index set. Used in DiscreteFunctionSpaces.
Definition: allgeomtypes.hh:99
Definition: dofmanager.hh:761
Singleton list for key/object pairs.
Definition: singletonlist.hh:53