20#ifndef DUNE_GRIDGLUE_EXTRACTORS_EXTRACTOR_HH
21#define DUNE_GRIDGLUE_EXTRACTORS_EXTRACTOR_HH
26#include <dune/common/exceptions.hh>
27#include <dune/common/fvector.hh>
28#include <dune/common/version.hh>
29#include <dune/grid/common/geometry.hh>
30#include <dune/grid/common/grid.hh>
31#include <dune/grid/common/mcmgmapper.hh>
32#include <dune/geometry/multilineargeometry.hh>
44template<
typename GV,
int cd>
50 static constexpr auto dimworld = GV::dimensionworld;
51 static constexpr auto dim = GV::dimension;
52 static constexpr auto codim = cd;
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;
70 using CellMapper = MultipleCodimMultipleGeomTypeMapper<GridView>;
89 unsigned int idx : 28;
157 const Dune::GeometryType& geometryType)
256 void getCoords(std::vector<Dune::FieldVector<ctype, dimworld> >& coords)
const
259 for (
unsigned int i = 0; i <
coords_.size(); ++i)
285 void getFaces(std::vector<VertexVector>& faces)
const
288 for (
unsigned int i = 0; i <
subEntities_.size(); ++i) {
290 for (
unsigned int j = 0; j <
subEntities_[i].nCorners(); ++j)
306 typename ElementInfoMap::const_iterator it =
315 first = it->second.idx;
316 count = it->second.faces;
364 DUNE_THROW(Dune::GridError,
"invalid face index");
366 return grid().entity(seed);
380 DUNE_THROW(Dune::GridError,
"invalid coordinate index");
382 return grid().entity(seed);
396template<
typename GV,
int cd>
399 std::vector<Coords> corners(subEntities_[index].nCorners());
400 for (
unsigned int i = 0; i < subEntities_[index].nCorners(); ++i)
401 corners[i] = coords_[subEntities_[index].corners[i].idx].coord;
403 return Geometry(subEntities_[index].geometryType_, corners);
408template<
typename GV,
int cd>
411 std::vector<LocalCoords> corners(subEntities_[index].nCorners());
415 Dune::GeometryType facetype = subEntities_[index].
geometryType_;
418 const auto elmtseed = elmtInfo_.at(face.
parent).p;
419 const auto elmt = grid().entity(elmtseed);
420 const Dune::GeometryType celltype = elmt.type();
421 const auto& re = Dune::ReferenceElements<ctype, dim>::general(celltype);
422 for (
unsigned int i = 0; i < subEntities_[index].nCorners(); ++i)
423 corners[i] = re.position(face.
corners[i].
num,dim);
Definition gridglue.hh:37
Provides codimension-independent methods for grid extraction.
Definition extractor.hh:46
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:206
const Grid & grid() const
Definition extractor.hh:349
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:361
int indexInInside(unsigned int index) const
gets the number face in the parent element
Definition extractor.hh:326
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:409
static constexpr auto dimworld
Definition extractor.hh:50
Dune::MultiLinearGeometry< ctype, dim-codim, dimworld > Geometry
Definition extractor.hh:77
int IndexType
Definition extractor.hh:73
std::vector< CoordinateInfo > coords_
all information about the corner vertices of the extracted
Definition extractor.hh:196
GV::Traits::template Codim< 0 >::Entity Element
Definition extractor.hh:66
const GridView & gridView() const
give access to the Dune::GridView where this Patch belongs to
Definition extractor.hh:344
void getFaces(std::vector< VertexVector > &faces) const
Get the corners of the extracted subentities.
Definition extractor.hh:285
std::vector< unsigned int > VertexVector
Definition extractor.hh:69
const GridView gv_
the grid object to extract the surface from
Definition extractor.hh:191
std::vector< SubEntityInfo > subEntities_
all information about the extracted subEntities
Definition extractor.hh:199
static constexpr int cube_corners
Definition extractor.hh:54
Vertex vertex(unsigned int index) const
gets the vertex for a given coordinate index throws an exception if index not valid
Definition extractor.hh:377
static constexpr auto codim
Definition extractor.hh:52
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:274
MultipleCodimMultipleGeomTypeMapper< GridView > CellMapper
Definition extractor.hh:70
std::map< IndexType, VertexInfo > VertexInfoMap
Definition extractor.hh:186
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:304
Geometry geometry(unsigned int index) const
Get world geometry of the extracted face.
Definition extractor.hh:397
GV GridView
Definition extractor.hh:56
unsigned int nCoords() const
getter for the count of coordinates
Definition extractor.hh:268
GV::Grid::ctype ctype
Definition extractor.hh:59
std::map< IndexType, ElementInfo > ElementInfoMap
Definition extractor.hh:185
Extractor(const GV &gv)
Constructor.
Definition extractor.hh:225
void getCoords(std::vector< Dune::FieldVector< ctype, dimworld > > &coords) const
getter for the coordinates array
Definition extractor.hh:256
CellMapper cellMapper_
Definition extractor.hh:215
Element::EntitySeed ElementSeed
Definition extractor.hh:67
Vertex::EntitySeed VertexSeed
Definition extractor.hh:64
ElementInfoMap elmtInfo_
a map enabling faster access to elements and faces
Definition extractor.hh:213
void clear()
delete everything build up so far and free the memory
Definition extractor.hh:235
static constexpr auto dim
Definition extractor.hh:51
Dune::MultiLinearGeometry< ctype, dim-codim, dim > LocalGeometry
Definition extractor.hh:78
Helpful struct holding one index for the coordinate (vertex) to which it is associated and the elemen...
Definition extractor.hh:88
unsigned int idx
index of the vertex
Definition extractor.hh:89
unsigned int num
element corner
Definition extractor.hh:90
Definition extractor.hh:94
CoordinateInfo(unsigned int index_, IndexType vtxindex_)
Definition extractor.hh:98
unsigned int index
the index of this coordinate (in internal storage scheme) // NEEDED??
Definition extractor.hh:109
CoordinateInfo()
Definition extractor.hh:95
Coords coord
the coordinate
Definition extractor.hh:106
IndexType vtxindex
the index of the parent element (from index set)
Definition extractor.hh:103
simple struct holding a vertex pointer and an index
Definition extractor.hh:116
unsigned int idx
Definition extractor.hh:119
VertexInfo(unsigned int idx_, const Vertex &p_)
Definition extractor.hh:117
VertexSeed p
Definition extractor.hh:120
simple struct holding an element seed and an index
Definition extractor.hh:128
unsigned int idx
the index of this element's first face in the internal list of extracted faces
Definition extractor.hh:133
unsigned int faces
the number of extracted faces for this element
Definition extractor.hh:136
ElementInfo(unsigned int idx_, const Element &p_, unsigned int f_)
Definition extractor.hh:129
ElementSeed p
the entity seed for the element
Definition extractor.hh:139
Holds some information about an element's subentity involved in a coupling.
Definition extractor.hh:147
unsigned int nCorners() const
Definition extractor.hh:161
CornerInfo corners[cube_corners]
the corner indices plus the numbers of the vertices in the parent element
Definition extractor.hh:181
IndexType parent
the index of the parent element (from index set)
Definition extractor.hh:167
SubEntityInfo(IndexType parent_, unsigned int num_in_parent_, const Dune::GeometryType &geometryType)
Definition extractor.hh:156
unsigned int num_in_parent
the number of the face in the parent element
Definition extractor.hh:170
Dune::GeometryType geometryType_
The GeometryType of the subentity.
Definition extractor.hh:173
SubEntityInfo()
Definition extractor.hh:148