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/version.hh> 27 #include <dune/grid/common/geometry.hh> 28 #include <dune/grid/common/grid.hh> 29 #include <dune/grid/common/mcmgmapper.hh> 30 #include <dune/geometry/multilineargeometry.hh> 42 template<
typename GV,
int cd>
48 static constexpr
auto dimworld = GV::dimensionworld;
49 static constexpr
auto dim = GV::dimension;
50 static constexpr
auto codim = cd;
55 typedef typename GridView::Grid
Grid;
57 typedef typename GV::Grid::ctype
ctype;
58 typedef Dune::FieldVector<ctype, dimworld>
Coords;
61 typedef typename GV::Traits::template Codim<dim>::Entity
Vertex;
64 typedef typename GV::Traits::template Codim<0>::Entity
Element;
69 #if DUNE_VERSION_NEWER(DUNE_GRID, 2, 6) 70 using CellMapper = MultipleCodimMultipleGeomTypeMapper<GridView>;
72 using CellMapper = MultipleCodimMultipleGeomTypeMapper<GridView, MCMGElementLayout>;
91 unsigned int idx : 28;
101 : vtxindex(vtxindex_), index(index_)
131 ElementInfo(
unsigned int idx_,
const Element& p_,
unsigned int f_) :
idx(idx_), faces(f_), p(p_.seed())
155 #if DUNE_VERSION_NEWER(DUNE_GEOMETRY, 2, 6) 156 : geometryType_(GeometryTypes::simplex(dim-codim))
160 geometryType_.makeSimplex(dim-codim);
165 const Dune::GeometryType& geometryType)
166 : parent(parent_), num_in_parent(num_in_parent_), geometryType_(geometryType)
171 return Dune::ReferenceElements<ctype, dim-codim>::general(geometryType_).size(dim-codim);
235 #if DUNE_VERSION_NEWER(DUNE_GRID, 2, 6)
236 , cellMapper_(gv, mcmgElementLayout())
252 std::vector<CoordinateInfo> dummy;
256 std::vector<SubEntityInfo> dummy;
257 subEntities_.swap(dummy);
273 void getCoords(std::vector<Dune::FieldVector<ctype, dimworld> >& coords)
const 275 coords.resize(coords_.size());
276 for (
unsigned int i = 0; i < coords_.size(); ++i)
277 coords[i] = coords_[i].coord;
287 return coords_.size();
293 geometryTypes.resize(subEntities_.size());
294 for (
size_t i=0; i<subEntities_.size(); i++)
295 geometryTypes[i] = subEntities_[i].geometryType_;
302 void getFaces(std::vector<VertexVector>& faces)
const 304 faces.resize(subEntities_.size());
305 for (
unsigned int i = 0; i < subEntities_.size(); ++i) {
306 faces[i].resize(subEntities_[i].nCorners());
307 for (
unsigned int j = 0; j < subEntities_[i].nCorners(); ++j)
308 faces[i][j] = subEntities_[i].corners[j].
idx;
323 typename ElementInfoMap::const_iterator it =
324 elmtInfo_.find(cellMapper_.map(e));
325 if (it == elmtInfo_.end())
332 first = it->second.idx;
333 count = it->second.faces;
345 return index < subEntities_.size() ? subEntities_[index].num_in_parent : -1;
380 if (index >= subEntities_.size())
381 DUNE_THROW(Dune::GridError,
"invalid face index");
382 const ElementSeed seed = elmtInfo_.at(subEntities_[index].parent).p;
383 return grid().entity(seed);
396 if (index >= coords_.size())
397 DUNE_THROW(Dune::GridError,
"invalid coordinate index");
398 const VertexSeed seed = vtxInfo_.at(coords_[index].vtxindex).p;
399 return grid().entity(seed);
404 Geometry
geometry(
unsigned int index)
const;
413 template<
typename GV,
int cd>
416 std::vector<Coords> corners(
subEntities_[index].nCorners());
417 for (
unsigned int i = 0; i <
subEntities_[index].nCorners(); ++i)
425 template<
typename GV,
int cd>
428 std::vector<LocalCoords> corners(
subEntities_[index].nCorners());
432 Dune::GeometryType facetype =
subEntities_[index].geometryType_;
435 const auto elmtseed =
elmtInfo_.at(face.parent).p;
436 const auto elmt =
grid().entity(elmtseed);
437 const Dune::GeometryType celltype = elmt.type();
438 const auto& re = Dune::ReferenceElements<ctype, dim>::general(celltype);
439 for (
unsigned int i = 0; i <
subEntities_[index].nCorners(); ++i)
440 corners[i] = re.position(face.corners[i].num,dim);
449 #endif // DUNE_GRIDGLUE_EXTRACTORS_EXTRACTOR_HH static constexpr auto dim
Definition: extractor.hh:49
Vertex::EntitySeed VertexSeed
Definition: extractor.hh:62
LocalGeometry geometryLocal(unsigned int index) const
Get geometry of the extracted face in element coordinates.
Definition: extractor.hh:426
Holds some information about an element's subentity involved in a coupling.
Definition: extractor.hh:148
Element::EntitySeed ElementSeed
Definition: extractor.hh:65
unsigned int idx
Definition: extractor.hh:121
CoordinateInfo(unsigned int index_, IndexType vtxindex_)
Definition: extractor.hh:100
Dune::GeometryType geometryType_
The GeometryType of the subentity.
Definition: extractor.hh:181
GV::Grid::ctype ctype
Definition: extractor.hh:57
const GridView & gridView() const
tests that a given entry in the extraction set does have local couplings
Definition: extractor.hh:361
SubEntityInfo(IndexType parent_, unsigned int num_in_parent_, const Dune::GeometryType &geometryType)
Definition: extractor.hh:164
Extractor(const GV &gv)
Constructor.
Definition: extractor.hh:233
Dune::FieldVector< ctype, dim > LocalCoords
Definition: extractor.hh:59
GridView::Grid Grid
Definition: extractor.hh:55
MultipleCodimMultipleGeomTypeMapper< GridView, MCMGElementLayout > CellMapper
Definition: extractor.hh:72
Dune::MultiLinearGeometry< ctype, dim-codim, dimworld > Geometry
Definition: extractor.hh:79
Definition: extractor.hh:95
static constexpr auto codim
Definition: extractor.hh:50
static constexpr int cube_corners
Definition: extractor.hh:52
Vertex vertex(unsigned int index) const
gets the vertex for a given coordinate index throws an exception if index not valid ...
Definition: extractor.hh:394
unsigned int index
the index of this coordinate (in internal storage scheme) // NEEDED??
Definition: extractor.hh:111
GV::Traits::template Codim< dim >::Entity Vertex
Definition: extractor.hh:61
unsigned int faces
the number of extracted faces for this element
Definition: extractor.hh:138
int IndexType
Definition: extractor.hh:75
const GridView gv_
the grid object to extract the surface from
Definition: extractor.hh:199
simple struct holding an element seed and an index
Definition: extractor.hh:129
Helpful struct holding one index for the coordinate (vertex) to which it is associated and the elemen...
Definition: extractor.hh:89
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:378
std::map< IndexType, ElementInfo > ElementInfoMap
Definition: extractor.hh:193
CoordinateInfo()
Definition: extractor.hh:97
VertexSeed p
Definition: extractor.hh:122
static constexpr auto dimworld
Definition: extractor.hh:48
const Grid & grid() const
Definition: extractor.hh:366
VertexInfoMap vtxInfo_
a map enabling faster access to vertices and coordinates
Definition: extractor.hh:214
simple struct holding a vertex pointer and an index
Definition: extractor.hh:117
unsigned int num
element corner
Definition: extractor.hh:92
GV::Traits::template Codim< 0 >::Entity Element
Definition: extractor.hh:64
SubEntityInfo()
Definition: extractor.hh:150
IndexType vtxindex
the index of the parent element (from index set)
Definition: extractor.hh:105
Geometry geometry(unsigned int index) const
Get world geometry of the extracted face.
Definition: extractor.hh:414
int indexInInside(unsigned int index) const
gets the number face in the parent element
Definition: extractor.hh:343
unsigned int nCoords() const
getter for the count of coordinates
Definition: extractor.hh:285
Coords coord
the coordinate
Definition: extractor.hh:108
unsigned int idx
the index of this element's first face in the internal list of extracted faces
Definition: extractor.hh:135
ElementInfoMap elmtInfo_
a map enabling faster access to elements and faces
Definition: extractor.hh:221
Dune::FieldVector< ctype, dimworld > Coords
Definition: extractor.hh:58
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:321
GV GridView
Definition: extractor.hh:54
std::vector< SubEntityInfo > subEntities_
all information about the extracted subEntities
Definition: extractor.hh:207
IndexType parent
the index of the parent element (from index set)
Definition: extractor.hh:175
unsigned int num_in_parent
the number of the face in the parent element
Definition: extractor.hh:178
CellMapper cellMapper_
Definition: extractor.hh:223
VertexInfo(unsigned int idx_, const Vertex &p_)
Definition: extractor.hh:119
unsigned int idx
index of the vertex
Definition: extractor.hh:91
ElementSeed p
the entity seed for the element
Definition: extractor.hh:141
void getFaces(std::vector< VertexVector > &faces) const
Get the corners of the extracted subentities.
Definition: extractor.hh:302
std::vector< unsigned int > VertexVector
Definition: extractor.hh:67
Definition: gridglue.hh:35
Dune::MultiLinearGeometry< ctype, dim-codim, dim > LocalGeometry
Definition: extractor.hh:80
ElementInfo(unsigned int idx_, const Element &p_, unsigned int f_)
Definition: extractor.hh:131
std::map< IndexType, VertexInfo > VertexInfoMap
Definition: extractor.hh:194
void getGeometryTypes(std::vector< Dune::GeometryType > &geometryTypes) const
Get the list of geometry types.
Definition: extractor.hh:291
std::vector< CoordinateInfo > coords_
all information about the corner vertices of the extracted
Definition: extractor.hh:204
void getCoords(std::vector< Dune::FieldVector< ctype, dimworld > > &coords) const
getter for the coordinates array
Definition: extractor.hh:273
unsigned int nCorners() const
Definition: extractor.hh:169
Provides codimension-independent methods for grid extraction.
Definition: extractor.hh:43
void clear()
delete everything build up so far and free the memory
Definition: extractor.hh:247