18 #ifndef DUNE_GRIDGLUE_EXTRACTORS_EXTRACTOR_HH
19 #define DUNE_GRIDGLUE_EXTRACTORS_EXTRACTOR_HH
24 #include <dune/common/exceptions.hh>
25 #include <dune/common/fvector.hh>
26 #include <dune/common/array.hh>
27 #include <dune/common/version.hh>
28 #include <dune/grid/common/geometry.hh>
29 #include <dune/grid/common/grid.hh>
30 #include <dune/grid/common/mcmgmapper.hh>
31 #if DUNE_VERSION_NEWER(DUNE_GEOMETRY,2,3)
32 #include <dune/geometry/multilineargeometry.hh>
34 #include <dune/geometry/genericgeometry/geometry.hh>
47 template<
typename GV,
int cd>
54 enum {
dim = GV::dimension};
64 typedef typename GV::Grid::ctype
ctype;
65 typedef Dune::FieldVector<ctype, dimworld>
Coords;
68 typedef typename GV::Traits::template Codim<dim>::EntityPointer
VertexPtr;
69 typedef typename GV::Traits::template Codim<dim>::Entity
Vertex;
71 typedef typename GV::Traits::template Codim<0>::EntityPointer
ElementPtr;
72 typedef typename GV::Traits::template Codim<0>::Entity
Element;
73 typedef typename GV::Traits::template Codim<0>::Iterator
ElementIter;
77 typedef Dune::MultipleCodimMultipleGeomTypeMapper<GridView, MCMGElementLayout>
CellMapper;
83 #if DUNE_VERSION_NEWER(DUNE_GEOMETRY,2,3)
166 const Dune::GeometryType& geometryType)
172 #if DUNE_VERSION_NEWER(DUNE_GEOMETRY,2,3)
173 return Dune::ReferenceElements<ctype, dim-codim>::general(
geometryType_).size(
dim-codim);
175 return Dune::GenericReferenceElements<ctype, dim-codim>::general(
geometryType_).size(
dim-codim);
239 : gv_(gv), cellMapper_(gv)
255 std::vector<CoordinateInfo> dummy;
259 std::vector<SubEntityInfo> dummy;
260 subEntities_.swap(dummy);
264 for (
typename VertexInfoMap::iterator it = vtxInfo_.begin();
265 it != vtxInfo_.end(); ++it)
266 if (it->second != NULL)
268 for (
typename ElementInfoMap::iterator it = elmtInfo_.begin();
269 it != elmtInfo_.end(); ++it)
270 if (it->second != NULL)
285 void getCoords(std::vector<Dune::FieldVector<ctype, dimworld> >& coords)
const
287 coords.resize(coords_.size());
288 for (
unsigned int i = 0; i < coords_.size(); ++i)
289 coords[i] = coords_[i].coord;
299 return coords_.size();
305 geometryTypes.resize(subEntities_.size());
306 for (
size_t i=0; i<subEntities_.size(); i++)
307 geometryTypes[i] = subEntities_[i].geometryType_;
314 void getFaces(std::vector<VertexVector>& faces)
const
316 faces.resize(subEntities_.size());
317 for (
unsigned int i = 0; i < subEntities_.size(); ++i) {
318 faces[i].resize(subEntities_[i].nCorners());
319 for (
unsigned int j = 0; j < subEntities_[i].nCorners(); ++j)
320 faces[i][j] = subEntities_[i].corners[j].idx;
335 typename ElementInfoMap::const_iterator it =
336 elmtInfo_.find(cellMapper_.map(e));
337 if (it == elmtInfo_.end())
344 first = it->second->idx;
345 count = it->second->faces;
357 return index < subEntities_.size() ? subEntities_[index].num_in_parent : -1;
384 const ElementPtr&
element(
unsigned int index)
const
386 if (index >= subEntities_.size())
387 DUNE_THROW(Dune::GridError,
"invalid face index");
388 return (elmtInfo_.find(subEntities_[index].parent))->second->p;
398 const VertexPtr&
vertex(
unsigned int index)
const
400 if (index >= coords_.size())
401 DUNE_THROW(Dune::GridError,
"invalid coordinate index");
402 return (vtxInfo_.find(coords_[index].vtxindex))->second->p;
407 Geometry
geometry(
unsigned int index)
const;
415 template<
typename GV,
int cd>
423 template<
typename GV,
int cd>
426 std::vector<Coords> corners(
subEntities_[index].nCorners());
427 for (
unsigned int i = 0; i <
subEntities_[index].nCorners(); ++i)
435 template<
typename GV,
int cd>
438 std::vector<LocalCoords> corners(
subEntities_[index].nCorners());
442 Dune::GeometryType facetype =
subEntities_[index].geometryType_;
445 Dune::GeometryType celltype =
elmtInfo_.find(face.
parent)->second->p->type();
446 #if DUNE_VERSION_NEWER(DUNE_GEOMETRY,2,3)
447 const Dune::ReferenceElement<ctype, dim> & re =
448 Dune::ReferenceElements<ctype, dim>::general(celltype);
450 const Dune::GenericReferenceElement<ctype, dim> & re =
451 Dune::GenericReferenceElements<ctype, dim>::general(celltype);
453 for (
unsigned int i = 0; i <
subEntities_[index].nCorners(); ++i)
463 #endif // DUNE_GRIDGLUE_EXTRACTORS_EXTRACTOR_HH
Definition: extractor.hh:105
Coords coord
the coordinate
Definition: extractor.hh:118
unsigned int idx
Definition: extractor.hh:131
GV::Traits::template Codim< 0 >::Iterator ElementIter
Definition: extractor.hh:73
simple struct holding an entity pointer and an index
Definition: extractor.hh:139
void clear()
delete everything build up so far and free the memory
Definition: extractor.hh:250
Dune::GenericGeometry::BasicGeometry< dim-codim, Dune::GenericGeometry::DefaultGeometryTraits< ctype, dim-codim, dimworld > > Geometry
Definition: extractor.hh:88
ElementPtr p
the entity pointer to the element
Definition: extractor.hh:151
GV::Traits::template Codim< dim >::Entity Vertex
Definition: extractor.hh:69
std::vector< CoordinateInfo > coords_
all information about the corner vertices of the extracted
Definition: extractor.hh:209
std::vector< SubEntityInfo > subEntities_
all information about the extracted subEntities
Definition: extractor.hh:212
IndexType vtxindex
the index of the parent element (from index set)
Definition: extractor.hh:115
unsigned int nCorners() const
Definition: extractor.hh:170
SubEntityInfo(IndexType parent_, unsigned int num_in_parent_, const Dune::GeometryType &geometryType)
Definition: extractor.hh:165
unsigned int idx
the index of this element's first face in the internal list of extracted faces
Definition: extractor.hh:145
void getGeometryTypes(std::vector< Dune::GeometryType > &geometryTypes) const
Get the list of geometry types.
Definition: extractor.hh:303
Dune::GeometryType geometryType_
The GeometryType of the subentity.
Definition: extractor.hh:186
Definition: extractor.hh:55
Holds some information about an element's subentity involved in a coupling.
Definition: extractor.hh:158
std::map< IndexType, ElementInfo * > ElementInfoMap
Definition: extractor.hh:198
Definition: gridglue.hh:34
unsigned int num
element corner
Definition: extractor.hh:102
unsigned int faces
the number of extracted faces for this element
Definition: extractor.hh:148
Dune::FieldVector< ctype, dim > LocalCoords
Definition: extractor.hh:66
SubEntityInfo()
Definition: extractor.hh:160
simple struct holding a vertex pointer and an index
Definition: extractor.hh:127
CoordinateInfo(unsigned int index_, IndexType vtxindex_)
Definition: extractor.hh:110
Definition: extractor.hh:54
bool faceIndices(const Element &e, int &first, int &count) const
gets index of first subentity as well as the total number of subentities that were extracted from thi...
Definition: extractor.hh:333
ElementInfo(unsigned int idx_, ElementPtr p_, unsigned int f_)
Definition: extractor.hh:141
VertexInfo(unsigned int idx_, VertexPtr p_)
Definition: extractor.hh:129
GV::Traits::template Codim< 0 >::EntityPointer ElementPtr
Definition: extractor.hh:71
LocalGeometry geometryLocal(unsigned int index) const
Get geometry of the extracted face in element coordinates.
Definition: extractor.hh:436
unsigned int idx
index of the vertex
Definition: extractor.hh:101
int IndexType
Definition: extractor.hh:79
Dune::GenericGeometry::BasicGeometry< dim-codim, Dune::GenericGeometry::DefaultGeometryTraits< ctype, dim-codim, dim > > LocalGeometry
Definition: extractor.hh:89
Dune::MultipleCodimMultipleGeomTypeMapper< GridView, MCMGElementLayout > CellMapper
Definition: extractor.hh:77
VertexPtr p
Definition: extractor.hh:132
GV GridView
Definition: extractor.hh:62
CornerInfo corners[cube_corners]
the corner indices plus the numbers of the vertices in the parent element
Definition: extractor.hh:194
IndexType parent
the index of the parent element (from index set)
Definition: extractor.hh:180
VertexInfoMap vtxInfo_
a map enabling faster access to vertices and coordinates
Definition: extractor.hh:219
GV::Traits::template Codim< dim >::EntityPointer VertexPtr
Definition: extractor.hh:68
Helpful struct holding one index for the coordinate (vertex) to which it is associated and the elemen...
Definition: extractor.hh:99
const VertexPtr & vertex(unsigned int index) const
gets the vertex for a given coordinate index throws an exception if index not valid ...
Definition: extractor.hh:398
CoordinateInfo()
Definition: extractor.hh:107
Definition: extractor.hh:53
const GridView & gridView() const
tests that a given entry in the extraction set does have local couplings
Definition: extractor.hh:373
GV::Traits::template Codim< 0 >::Entity Element
Definition: extractor.hh:72
void getCoords(std::vector< Dune::FieldVector< ctype, dimworld > > &coords) const
getter for the coordinates array
Definition: extractor.hh:285
Geometry geometry(unsigned int index) const
Get world geometry of the extracted face.
Definition: extractor.hh:424
unsigned int nCoords() const
getter for the count of coordinates
Definition: extractor.hh:297
CellMapper cellMapper_
Definition: extractor.hh:228
int indexInInside(unsigned int index) const
gets the number face in the parent element
Definition: extractor.hh:355
std::vector< unsigned int > VertexVector
Definition: extractor.hh:75
GV::Grid::ctype ctype
Definition: extractor.hh:64
Provides codimension-independent methods for grid extraction.
Definition: extractor.hh:48
void getFaces(std::vector< VertexVector > &faces) const
Get the corners of the extracted subentities.
Definition: extractor.hh:314
Definition: extractor.hh:59
const GridView & gv_
the grid object to extract the surface from
Definition: extractor.hh:204
ElementInfoMap elmtInfo_
a map enabling faster access to elements and faces
Definition: extractor.hh:226
unsigned int index
the index of this coordinate (in internal storage scheme) // NEEDED??
Definition: extractor.hh:121
unsigned int num_in_parent
the number of the face in the parent element
Definition: extractor.hh:183
Extractor(const GV &gv)
Constructor.
Definition: extractor.hh:238
~Extractor()
Destructor frees allocated memory.
Definition: extractor.hh:416
Dune::FieldVector< ctype, dimworld > Coords
Definition: extractor.hh:65
const ElementPtr & element(unsigned int index) const
gets the parent element for a given face index, throws an exception if index not valid ...
Definition: extractor.hh:384
std::map< IndexType, VertexInfo * > VertexInfoMap
Definition: extractor.hh:199