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/grid/common/geometry.hh>
27 #include <dune/grid/common/grid.hh>
28 #include <dune/grid/common/mcmgmapper.hh>
29 #include <dune/geometry/multilineargeometry.hh>
41 template<
typename GV,
int cd>
48 enum {
dim = GV::dimension};
57 typedef typename GridView::Grid
Grid;
59 typedef typename GV::Grid::ctype
ctype;
60 typedef Dune::FieldVector<ctype, dimworld>
Coords;
63 typedef typename GV::Traits::template Codim<dim>::Entity
Vertex;
66 typedef typename GV::Traits::template Codim<0>::Entity
Element;
68 typedef typename GV::Traits::template Codim<0>::Iterator
ElementIter;
72 typedef Dune::MultipleCodimMultipleGeomTypeMapper<GridView, MCMGElementLayout>
CellMapper;
90 unsigned int idx : 28;
155 const Dune::GeometryType& geometryType)
240 std::vector<CoordinateInfo> dummy;
244 std::vector<SubEntityInfo> dummy;
249 for (
typename VertexInfoMap::iterator it =
vtxInfo_.begin();
251 if (it->second != NULL)
253 for (
typename ElementInfoMap::iterator it =
elmtInfo_.begin();
255 if (it->second != NULL)
270 void getCoords(std::vector<Dune::FieldVector<ctype, dimworld> >& coords)
const
273 for (
unsigned int i = 0; i <
coords_.size(); ++i)
299 void getFaces(std::vector<VertexVector>& faces)
const
302 for (
unsigned int i = 0; i <
subEntities_.size(); ++i) {
304 for (
unsigned int j = 0; j <
subEntities_[i].nCorners(); ++j)
320 typename ElementInfoMap::const_iterator it =
329 first = it->second->idx;
330 count = it->second->faces;
378 DUNE_THROW(Dune::GridError,
"invalid face index");
380 return grid().entity(seed);
394 DUNE_THROW(Dune::GridError,
"invalid coordinate index");
396 return grid().entity(seed);
409 template<
typename GV,
int cd>
417 template<
typename GV,
int cd>
420 std::vector<Coords> corners(subEntities_[index].nCorners());
421 for (
unsigned int i = 0; i < subEntities_[index].nCorners(); ++i)
422 corners[i] = coords_[subEntities_[index].corners[i].idx].coord;
424 return Geometry(subEntities_[index].geometryType_, corners);
429 template<
typename GV,
int cd>
432 std::vector<LocalCoords> corners(subEntities_[index].nCorners());
436 Dune::GeometryType facetype = subEntities_[index].
geometryType_;
439 const auto elmtseed = elmtInfo_.find(face.
parent)->second->p;
440 const auto elmt = grid().entity(elmtseed);
441 const Dune::GeometryType celltype = elmt.type();
442 const Dune::ReferenceElement<ctype, dim> & re =
443 Dune::ReferenceElements<ctype, dim>::general(celltype);
444 for (
unsigned int i = 0; i < subEntities_[index].nCorners(); ++i)
445 corners[i] = re.position(face.
corners[i].
num,dim);
Definition: gridglue.hh:30
Provides codimension-independent methods for grid extraction.
Definition: extractor.hh:43
GV::Traits::template Codim< dim >::Entity Vertex
Definition: extractor.hh:63
VertexInfoMap vtxInfo_
a map enabling faster access to vertices and coordinates
Definition: extractor.hh:204
Element element(unsigned int index) const
gets the parent element for a given face index, throws an exception if index not valid
Definition: extractor.hh:375
int indexInInside(unsigned int index) const
gets the number face in the parent element
Definition: extractor.hh:340
Dune::FieldVector< ctype, dim > LocalCoords
Definition: extractor.hh:61
LocalGeometry geometryLocal(unsigned int index) const
Get geometry of the extracted face in element coordinates.
Definition: extractor.hh:430
@ dim
Definition: extractor.hh:48
const GridView & gridView() const
give access to the Dune::GridView where this Patch belongs to
Definition: extractor.hh:358
Dune::MultiLinearGeometry< ctype, dim-codim, dimworld > Geometry
Definition: extractor.hh:78
int IndexType
Definition: extractor.hh:74
std::vector< CoordinateInfo > coords_
all information about the corner vertices of the extracted
Definition: extractor.hh:194
GV::Traits::template Codim< 0 >::Entity Element
Definition: extractor.hh:66
GV::Traits::template Codim< 0 >::Iterator ElementIter
Definition: extractor.hh:68
@ dimworld
Definition: extractor.hh:47
void getFaces(std::vector< VertexVector > &faces) const
Get the corners of the extracted subentities.
Definition: extractor.hh:299
std::vector< unsigned int > VertexVector
Definition: extractor.hh:70
const GridView gv_
the grid object to extract the surface from
Definition: extractor.hh:189
Dune::MultipleCodimMultipleGeomTypeMapper< GridView, MCMGElementLayout > CellMapper
Definition: extractor.hh:72
std::vector< SubEntityInfo > subEntities_
all information about the extracted subEntities
Definition: extractor.hh:197
Vertex vertex(unsigned int index) const
gets the vertex for a given coordinate index throws an exception if index not valid
Definition: extractor.hh:391
Dune::FieldVector< ctype, dimworld > Coords
Definition: extractor.hh:60
void getGeometryTypes(std::vector< Dune::GeometryType > &geometryTypes) const
Get the list of geometry types.
Definition: extractor.hh:288
GridView::Grid Grid
Definition: extractor.hh:57
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:318
Geometry geometry(unsigned int index) const
Get world geometry of the extracted face.
Definition: extractor.hh:418
GV GridView
Definition: extractor.hh:56
unsigned int nCoords() const
getter for the count of coordinates
Definition: extractor.hh:282
std::map< IndexType, ElementInfo * > ElementInfoMap
Definition: extractor.hh:183
GV::Grid::ctype ctype
Definition: extractor.hh:59
~Extractor()
Destructor frees allocated memory.
Definition: extractor.hh:410
std::map< IndexType, VertexInfo * > VertexInfoMap
Definition: extractor.hh:184
Extractor(const GV &gv)
Constructor.
Definition: extractor.hh:223
@ codim
Definition: extractor.hh:49
void getCoords(std::vector< Dune::FieldVector< ctype, dimworld > > &coords) const
getter for the coordinates array
Definition: extractor.hh:270
CellMapper cellMapper_
Definition: extractor.hh:213
Element::EntitySeed ElementSeed
Definition: extractor.hh:67
const Grid & grid() const
Definition: extractor.hh:363
Vertex::EntitySeed VertexSeed
Definition: extractor.hh:64
ElementInfoMap elmtInfo_
a map enabling faster access to elements and faces
Definition: extractor.hh:211
void clear()
delete everything build up so far and free the memory
Definition: extractor.hh:235
Dune::MultiLinearGeometry< ctype, dim-codim, dim > LocalGeometry
Definition: extractor.hh:79
@ cube_corners
Definition: extractor.hh:53
Helpful struct holding one index for the coordinate (vertex) to which it is associated and the elemen...
Definition: extractor.hh:89
unsigned int idx
index of the vertex
Definition: extractor.hh:90
unsigned int num
element corner
Definition: extractor.hh:91
Definition: extractor.hh:95
CoordinateInfo(unsigned int index_, IndexType vtxindex_)
Definition: extractor.hh:99
unsigned int index
the index of this coordinate (in internal storage scheme) // NEEDED??
Definition: extractor.hh:110
CoordinateInfo()
Definition: extractor.hh:96
Coords coord
the coordinate
Definition: extractor.hh:107
IndexType vtxindex
the index of the parent element (from index set)
Definition: extractor.hh:104
simple struct holding a vertex pointer and an index
Definition: extractor.hh:117
unsigned int idx
Definition: extractor.hh:120
VertexInfo(unsigned int idx_, const Vertex &p_)
Definition: extractor.hh:118
VertexSeed p
Definition: extractor.hh:121
simple struct holding an element seed and an index
Definition: extractor.hh:129
unsigned int idx
the index of this element's first face in the internal list of extracted faces
Definition: extractor.hh:134
unsigned int faces
the number of extracted faces for this element
Definition: extractor.hh:137
ElementInfo(unsigned int idx_, const Element &p_, unsigned int f_)
Definition: extractor.hh:130
ElementSeed p
the entity seed for the element
Definition: extractor.hh:140
Holds some information about an element's subentity involved in a coupling.
Definition: extractor.hh:148
unsigned int nCorners() const
Definition: extractor.hh:159
CornerInfo corners[cube_corners]
the corner indices plus the numbers of the vertices in the parent element
Definition: extractor.hh:179
IndexType parent
the index of the parent element (from index set)
Definition: extractor.hh:165
SubEntityInfo(IndexType parent_, unsigned int num_in_parent_, const Dune::GeometryType &geometryType)
Definition: extractor.hh:154
unsigned int num_in_parent
the number of the face in the parent element
Definition: extractor.hh:168
Dune::GeometryType geometryType_
The GeometryType of the subentity.
Definition: extractor.hh:171
SubEntityInfo()
Definition: extractor.hh:149