6#ifndef DUNE_GRID_HIERARCHICSEARCH_HH
7#define DUNE_GRID_HIERARCHICSEARCH_HH
20#include <dune/common/classname.hh>
21#include <dune/common/exceptions.hh>
22#include <dune/common/fvector.hh>
33 template<
class Gr
id,
class IS>
46 typedef typename Grid::template Codim<0>::Entity Entity;
51 static std::string formatEntityInformation (
const Entity &e ) {
53 std::ostringstream info;
54 info <<
"level=" << e.level() <<
" "
55 <<
"partition=" << e.partitionType() <<
" "
56 <<
"center=(" << geo.center() <<
") "
57 <<
"corners=[(" << geo.corner(0) <<
")";
58 for(
int i = 1; i < geo.corners(); ++i)
59 info <<
" (" << e.geometry().corner(i) <<
")";
74 Entity hFindEntity (
const Entity &entity,
75 const FieldVector<ct,dimw>& global)
const
82 const int childLevel = entity.level()+1 ;
84 const HierarchicIterator end = entity.hend( childLevel );
85 for( HierarchicIterator it = entity.hbegin( childLevel ); it != end; ++it )
90 LocalCoordinate local = geo.local(global);
94 if( indexSet_.contains( child ) )
97 return hFindEntity( child, global );
100 std::ostringstream children;
101 HierarchicIterator it = entity.hbegin( childLevel );
103 children <<
"{" << formatEntityInformation(*it) <<
"}";
104 for( ++it; it != end; ++it )
105 children <<
" {" << formatEntityInformation(*it) <<
"}";
107 DUNE_THROW(Exception,
"{" << className(*
this) <<
"} Unexpected "
108 "internal Error: none of the children of the entity "
109 "{" << formatEntityInformation(entity) <<
"} contains "
110 "coordinate (" << global <<
"). Children are: "
111 "[" << children.str() <<
"].");
128 {
return findEntity<All_Partition>(global); }
137 template<PartitionIteratorType partition>
144 typedef typename LevelGV::template Codim<0>::template Partition<partition>::Iterator LevelIterator;
152 const LevelIterator end = gv.template end<0, partition>();
153 for (LevelIterator it = gv.template begin<0, partition>(); it != end; ++it)
158 LocalCoordinate local = geo.local( global );
162 if( (
int(dim) !=
int(dimw)) && ((geo.
global( local ) - global).two_norm() > 1e-8) )
166 if( indexSet_.contains( entity ) )
169 return hFindEntity( entity, global );
171 DUNE_THROW(
GridError,
"Coordinate " << global <<
" is outside the grid." );
Include standard header files.
Definition: agrid.hh:60
auto referenceElement(const Geometry< mydim, cdim, GridImp, GeometryImp > &geo) -> decltype(referenceElement(geo, geo.impl()))
Definition: common/geometry.hh:558
GridImp::template Codim< cd >::Geometry Geometry
The corresponding geometry type.
Definition: common/entity.hh:100
Base class for exceptions in Dune grid modules.
Definition: exceptions.hh:20
Wrapper class for geometries.
Definition: common/geometry.hh:71
GlobalCoordinate global(const LocalCoordinate &local) const
Evaluate the map .
Definition: common/geometry.hh:228
FieldVector< ctype, mydim > LocalCoordinate
type of local coordinates
Definition: common/geometry.hh:103
Grid abstract base class.
Definition: common/grid.hh:375
static constexpr int dimension
The dimension of the grid.
Definition: common/grid.hh:387
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:482
GridFamily::Traits::LevelGridView LevelGridView
type of view for level grid
Definition: common/grid.hh:402
static constexpr int dimensionworld
The dimension of the world the grid lives in.
Definition: common/grid.hh:390
LevelGridView levelGridView(int level) const
View for a grid level for All_Partition.
Definition: common/grid.hh:598
ct ctype
Define type used for coordinates in grid module.
Definition: common/grid.hh:532
Search an IndexSet for an Entity containing a given point.
Definition: hierarchicsearch.hh:35
Entity findEntity(const FieldVector< ct, dimw > &global) const
Search the IndexSet of this HierarchicSearch for an Entity containing point global.
Definition: hierarchicsearch.hh:127
Entity findEntity(const FieldVector< ct, dimw > &global) const
Search the IndexSet of this HierarchicSearch for an Entity containing point global.
Definition: hierarchicsearch.hh:138
HierarchicSearch(const Grid &g, const IS &is)
Construct a HierarchicSearch object from a Grid and an IndexSet.
Definition: hierarchicsearch.hh:118
Different resources needed by all grid implementations.