4 #ifndef DUNE_GRID_HIERARCHICSEARCH_HH
5 #define DUNE_GRID_HIERARCHICSEARCH_HH
18 #include <dune/common/classname.hh>
19 #include <dune/common/exceptions.hh>
20 #include <dune/common/fvector.hh>
31 template<
class Gr
id,
class IS>
44 typedef typename Grid::template Codim<0>::Entity Entity;
49 static std::string formatEntityInformation (
const Entity &e ) {
51 std::ostringstream info;
52 info <<
"level=" << e.level() <<
" "
53 <<
"partition=" << e.partitionType() <<
" "
54 <<
"center=(" << geo.center() <<
") "
55 <<
"corners=[(" << geo.corner(0) <<
")";
56 for(
int i = 1; i < geo.corners(); ++i)
57 info <<
" (" << e.geometry().corner(i) <<
")";
72 Entity hFindEntity (
const Entity &entity,
73 const FieldVector<ct,dimw>& global)
const
80 const int childLevel = entity.level()+1 ;
82 const HierarchicIterator end = entity.hend( childLevel );
83 for( HierarchicIterator it = entity.hbegin( childLevel ); it != end; ++it )
88 LocalCoordinate local = geo.local(global);
92 if( indexSet_.contains( child ) )
95 return hFindEntity( child, global );
98 std::ostringstream children;
99 HierarchicIterator it = entity.hbegin( childLevel );
101 children <<
"{" << formatEntityInformation(*it) <<
"}";
102 for( ++it; it != end; ++it )
103 children <<
" {" << formatEntityInformation(*it) <<
"}";
105 DUNE_THROW(Exception,
"{" << className(*
this) <<
"} Unexpected "
106 "internal Error: none of the children of the entity "
107 "{" << formatEntityInformation(entity) <<
"} contains "
108 "coordinate (" << global <<
"). Children are: "
109 "[" << children.str() <<
"].");
126 {
return findEntity<All_Partition>(global); }
135 template<PartitionIteratorType partition>
142 typedef typename LevelGV::template Codim<0>::template Partition<partition>::Iterator LevelIterator;
150 const LevelIterator end = gv.template end<0, partition>();
151 for (LevelIterator it = gv.template begin<0, partition>(); it != end; ++it)
156 LocalCoordinate local = geo.local( global );
160 if( (
int(dim) !=
int(dimw)) && ((geo.
global( local ) - global).two_norm() > 1e-8) )
164 if( indexSet_.contains( entity ) )
167 return hFindEntity( entity, global );
169 DUNE_THROW(
GridError,
"Coordinate " << global <<
" is outside the grid." );
Include standard header files.
Definition: agrid.hh:58
auto referenceElement(const Geometry< mydim, cdim, GridImp, GeometryImp > &geo) -> decltype(referenceElement(geo, geo.impl()))
Definition: common/geometry.hh:417
GridImp::template Codim< cd >::Geometry Geometry
The corresponding geometry type.
Definition: common/entity.hh:98
Base class for exceptions in Dune grid modules.
Definition: exceptions.hh:18
Wrapper class for geometries.
Definition: common/geometry.hh:67
GlobalCoordinate global(const LocalCoordinate &local) const
Evaluate the map .
Definition: common/geometry.hh:165
FieldVector< ctype, mydim > LocalCoordinate
type of local coordinates
Definition: common/geometry.hh:98
Grid abstract base class.
Definition: common/grid.hh:372
GridFamily::Traits::HierarchicIterator HierarchicIterator
A type that is a model of Dune::HierarchicIterator A type of iterator that allows to examine,...
Definition: common/grid.hh:485
GridFamily::Traits::LevelGridView LevelGridView
type of view for level grid
Definition: common/grid.hh:405
@ dimensionworld
The dimension of the world the grid lives in.
Definition: common/grid.hh:392
LevelGridView levelGridView(int level) const
View for a grid level for All_Partition.
Definition: common/grid.hh:587
@ dimension
The dimension of the grid.
Definition: common/grid.hh:386
ct ctype
Define type used for coordinates in grid module.
Definition: common/grid.hh:521
Search an IndexSet for an Entity containing a given point.
Definition: hierarchicsearch.hh:33
Entity findEntity(const FieldVector< ct, dimw > &global) const
Search the IndexSet of this HierarchicSearch for an Entity containing point global.
Definition: hierarchicsearch.hh:125
Entity findEntity(const FieldVector< ct, dimw > &global) const
Search the IndexSet of this HierarchicSearch for an Entity containing point global.
Definition: hierarchicsearch.hh:136
HierarchicSearch(const Grid &g, const IS &is)
Construct a HierarchicSearch object from a Grid and an IndexSet.
Definition: hierarchicsearch.hh:116
Different resources needed by all grid implementations.