Go to the documentation of this file.
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 )
86 const Geometry &geo = child.geometry();
88 LocalCoordinate local = geo.local(global);
89 if (ReferenceElements<double, dim>::general( child.type() ).checkInside(local))
92 if( indexSet_.contains( child ) )
93 return std::move( 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)
154 const Geometry &geo = entity.geometry();
156 LocalCoordinate local = geo.local( global );
157 if( !ReferenceElements< double, dim >::general( geo.
type() ).checkInside( local ) )
160 if( (
int(dim) != int(dimw)) && ((geo.
global( local ) - global).two_norm() > 1e-8) )
164 if( indexSet_.contains( entity ) )
165 return std::move( entity );
167 return hFindEntity( entity, global );
169 DUNE_THROW(
GridError,
"Coordinate " << global <<
" is outside the grid." );
179 #endif // DUNE_GRID_HIERARCHICSEARCH_HH
Different resources needed by all grid implementations.
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
Include standard header files.
Definition: agrid.hh:59
HierarchicSearch(const Grid &g, const IS &is)
Construct a HierarchicSearch object from a Grid and an IndexSet.
Definition: hierarchicsearch.hh:116
GridFamily::Traits::LevelGridView LevelGridView
type of view for level grid
Definition: common/grid.hh:406
FieldVector< ctype, mydim > LocalCoordinate
type of local coordinates
Definition: common/geometry.hh:93
GlobalCoordinate global(const LocalCoordinate &local) const
Evaluate the map .
Definition: common/geometry.hh:157
ct ctype
Define type used for coordinates in grid module.
Definition: common/grid.hh:522
Search an IndexSet for an Entity containing a given point.
Definition: hierarchicsearch.hh:32
GridImp::template Codim< cd >::Geometry Geometry
The corresponding geometry type.
Definition: common/entity.hh:97
GeometryType type() const
Return the type of the reference element. The type can be used to access the Dune::ReferenceElement.
Definition: common/geometry.hh:123
Grid abstract base class.
Definition: common/grid.hh:373
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:486
The dimension of the grid.
Definition: common/grid.hh:387
The dimension of the world the grid lives in.
Definition: common/grid.hh:393
Base class for exceptions in Dune grid modules.
Definition: exceptions.hh:16
LevelGridView levelGridView(int level) const
View for a grid level for All_Partition.
Definition: common/grid.hh:588
Wrapper class for geometries.
Definition: common/geometry.hh:65