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 #if DUNE_VERSION_NEWER(DUNE_GEOMETRY,2,3) 31 #include <dune/geometry/multilineargeometry.hh> 33 #include <dune/geometry/genericgeometry/geometry.hh> 46 template<
typename GV,
int cd>
53 enum {
dim = GV::dimension};
62 typedef typename GridView::Grid
Grid;
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;
72 typedef typename GV::Traits::template Codim<0>::EntityPointer
ElementPtr;
73 typedef typename GV::Traits::template Codim<0>::Entity
Element;
75 typedef typename GV::Traits::template Codim<0>::Iterator
ElementIter;
79 typedef Dune::MultipleCodimMultipleGeomTypeMapper<GridView, MCMGElementLayout>
CellMapper;
85 #if DUNE_VERSION_NEWER(DUNE_GEOMETRY,2,3) 113 : vtxindex(vtxindex_), index(index_)
143 ElementInfo(
unsigned int idx_,
const Element& p_,
unsigned int f_) :
idx(idx_), faces(f_), p(p_.seed())
150 unsigned int faces : 4;
164 geometryType_.makeSimplex(
dim-codim);
168 const Dune::GeometryType& geometryType)
169 : parent(parent_), num_in_parent(num_in_parent_), geometryType_(geometryType)
174 #if DUNE_VERSION_NEWER(DUNE_GEOMETRY,2,3) 175 return Dune::ReferenceElements<ctype, dim-codim>::general(geometryType_).size(
dim-codim);
177 return Dune::GenericReferenceElements<ctype, dim-codim>::general(geometryType_).size(
dim-codim);
185 unsigned int num_in_parent : 3;
241 : gv_(gv), cellMapper_(gv)
257 std::vector<CoordinateInfo> dummy;
261 std::vector<SubEntityInfo> dummy;
262 subEntities_.swap(dummy);
266 for (
typename VertexInfoMap::iterator it = vtxInfo_.begin();
267 it != vtxInfo_.end(); ++it)
268 if (it->second != NULL)
270 for (
typename ElementInfoMap::iterator it = elmtInfo_.begin();
271 it != elmtInfo_.end(); ++it)
272 if (it->second != NULL)
287 void getCoords(std::vector<Dune::FieldVector<ctype, dimworld> >& coords)
const 289 coords.resize(coords_.size());
290 for (
unsigned int i = 0; i < coords_.size(); ++i)
291 coords[i] = coords_[i].coord;
301 return coords_.size();
307 geometryTypes.resize(subEntities_.size());
308 for (
size_t i=0; i<subEntities_.size(); i++)
309 geometryTypes[i] = subEntities_[i].geometryType_;
316 void getFaces(std::vector<VertexVector>& faces)
const 318 faces.resize(subEntities_.size());
319 for (
unsigned int i = 0; i < subEntities_.size(); ++i) {
320 faces[i].resize(subEntities_[i].nCorners());
321 for (
unsigned int j = 0; j < subEntities_[i].nCorners(); ++j)
322 faces[i][j] = subEntities_[i].corners[j].
idx;
337 typename ElementInfoMap::const_iterator it =
338 elmtInfo_.find(cellMapper_.map(e));
339 if (it == elmtInfo_.end())
346 first = it->second->idx;
347 count = it->second->faces;
359 return index < subEntities_.size() ? subEntities_[index].num_in_parent : -1;
391 #if DUNE_VERSION_NEWER(DUNE_GRID, 2, 4) || DOXYGEN 398 if (index >= subEntities_.size())
399 DUNE_THROW(Dune::GridError,
"invalid face index");
400 const ElementSeed seed = (elmtInfo_.find(subEntities_[index].parent))->second->p;
401 #
if DUNE_VERSION_NEWER(DUNE_GRID, 2, 4)
402 return grid().entity(seed);
404 return grid().entityPointer(seed);
415 #if DUNE_VERSION_NEWER(DUNE_GRID, 2, 4) || DOXYGEN 422 if (index >= coords_.size())
423 DUNE_THROW(Dune::GridError,
"invalid coordinate index");
424 const VertexSeed seed = (vtxInfo_.find(coords_[index].vtxindex))->second->p;
425 #
if DUNE_VERSION_NEWER(DUNE_GRID, 2, 4)
426 return grid().entity(seed);
428 return grid().entityPointer(seed);
434 Geometry
geometry(
unsigned int index)
const;
442 template<
typename GV,
int cd>
450 template<
typename GV,
int cd>
453 std::vector<Coords> corners(
subEntities_[index].nCorners());
454 for (
unsigned int i = 0; i <
subEntities_[index].nCorners(); ++i)
462 template<
typename GV,
int cd>
465 std::vector<LocalCoords> corners(
subEntities_[index].nCorners());
469 Dune::GeometryType facetype =
subEntities_[index].geometryType_;
473 #if DUNE_VERSION_NEWER(DUNE_GRID, 2, 4) 474 const auto elmt =
grid().entity(elmtseed);
476 const auto elmtPtr =
grid().entityPointer(elmtseed);
477 const auto& elmt = *elmtPtr;
479 const Dune::GeometryType celltype = elmt.type();
480 #if DUNE_VERSION_NEWER(DUNE_GEOMETRY,2,3) 481 const Dune::ReferenceElement<ctype, dim> & re =
482 Dune::ReferenceElements<ctype, dim>::general(celltype);
484 const Dune::GenericReferenceElement<ctype, dim> & re =
485 Dune::GenericReferenceElements<ctype, dim>::general(celltype);
487 for (
unsigned int i = 0; i <
subEntities_[index].nCorners(); ++i)
497 #endif // DUNE_GRIDGLUE_EXTRACTORS_EXTRACTOR_HH SubEntityInfo(IndexType parent_, unsigned int num_in_parent_, const Dune::GeometryType &geometryType)
Definition: extractor.hh:167
const GridView gv_
the grid object to extract the surface from
Definition: extractor.hh:206
ElementInfo(unsigned int idx_, const Element &p_, unsigned int f_)
Definition: extractor.hh:143
GV::Traits::template Codim< 0 >::Iterator ElementIter
Definition: extractor.hh:75
simple struct holding an element seed and an index
Definition: extractor.hh:141
Element::EntitySeed ElementSeed
Definition: extractor.hh:74
void clear()
delete everything build up so far and free the memory
Definition: extractor.hh:252
Dune::GenericGeometry::BasicGeometry< dim-codim, Dune::GenericGeometry::DefaultGeometryTraits< ctype, dim-codim, dimworld > > Geometry
Definition: extractor.hh:90
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:211
std::vector< SubEntityInfo > subEntities_
all information about the extracted subEntities
Definition: extractor.hh:214
Definition: gridglue.hh:33
void getGeometryTypes(std::vector< Dune::GeometryType > &geometryTypes) const
Get the list of geometry types.
Definition: extractor.hh:305
SubEntityInfo()
Definition: extractor.hh:162
Definition: extractor.hh:54
std::map< IndexType, ElementInfo * > ElementInfoMap
Definition: extractor.hh:200
Coords coord
the coordinate
Definition: extractor.hh:120
IndexType parent
the index of the parent element (from index set)
Definition: extractor.hh:182
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:396
Dune::FieldVector< ctype, dim > LocalCoords
Definition: extractor.hh:66
const Grid & grid() const
Definition: extractor.hh:380
unsigned int index
the index of this coordinate (in internal storage scheme) // NEEDED??
Definition: extractor.hh:123
unsigned int idx
index of the vertex
Definition: extractor.hh:103
ElementSeed p
the entity seed for the element
Definition: extractor.hh:153
Definition: extractor.hh:53
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:335
unsigned int num
element corner
Definition: extractor.hh:104
Definition: extractor.hh:107
unsigned int idx
Definition: extractor.hh:133
GV::Traits::template Codim< 0 >::EntityPointer ElementPtr
Definition: extractor.hh:72
VertexInfo(unsigned int idx_, const Vertex &p_)
Definition: extractor.hh:131
unsigned int nCorners() const
Definition: extractor.hh:172
LocalGeometry geometryLocal(unsigned int index) const
Get geometry of the extracted face in element coordinates.
Definition: extractor.hh:463
Vertex::EntitySeed VertexSeed
Definition: extractor.hh:70
int IndexType
Definition: extractor.hh:81
Dune::GenericGeometry::BasicGeometry< dim-codim, Dune::GenericGeometry::DefaultGeometryTraits< ctype, dim-codim, dim > > LocalGeometry
Definition: extractor.hh:91
Dune::MultipleCodimMultipleGeomTypeMapper< GridView, MCMGElementLayout > CellMapper
Definition: extractor.hh:79
simple struct holding a vertex pointer and an index
Definition: extractor.hh:129
GV GridView
Definition: extractor.hh:61
Helpful struct holding one index for the coordinate (vertex) to which it is associated and the elemen...
Definition: extractor.hh:101
IndexType vtxindex
the index of the parent element (from index set)
Definition: extractor.hh:117
VertexInfoMap vtxInfo_
a map enabling faster access to vertices and coordinates
Definition: extractor.hh:221
GV::Traits::template Codim< dim >::EntityPointer VertexPtr
Definition: extractor.hh:68
CornerInfo corners[cube_corners]
the corner indices plus the numbers of the vertices in the parent element
Definition: extractor.hh:196
VertexSeed p
Definition: extractor.hh:134
Definition: extractor.hh:52
const GridView & gridView() const
tests that a given entry in the extraction set does have local couplings
Definition: extractor.hh:375
GV::Traits::template Codim< 0 >::Entity Element
Definition: extractor.hh:73
void getCoords(std::vector< Dune::FieldVector< ctype, dimworld > > &coords) const
getter for the coordinates array
Definition: extractor.hh:287
Geometry geometry(unsigned int index) const
Get world geometry of the extracted face.
Definition: extractor.hh:451
unsigned int nCoords() const
getter for the count of coordinates
Definition: extractor.hh:299
GridView::Grid Grid
Definition: extractor.hh:62
CellMapper cellMapper_
Definition: extractor.hh:230
Holds some information about an element's subentity involved in a coupling.
Definition: extractor.hh:160
Vertex vertex(unsigned int index) const
gets the vertex for a given coordinate index throws an exception if index not valid ...
Definition: extractor.hh:420
int indexInInside(unsigned int index) const
gets the number face in the parent element
Definition: extractor.hh:357
std::vector< unsigned int > VertexVector
Definition: extractor.hh:77
GV::Grid::ctype ctype
Definition: extractor.hh:64
Provides codimension-independent methods for grid extraction.
Definition: extractor.hh:47
void getFaces(std::vector< VertexVector > &faces) const
Get the corners of the extracted subentities.
Definition: extractor.hh:316
CoordinateInfo()
Definition: extractor.hh:109
Definition: extractor.hh:58
ElementInfoMap elmtInfo_
a map enabling faster access to elements and faces
Definition: extractor.hh:228
Extractor(const GV &gv)
Constructor.
Definition: extractor.hh:240
CoordinateInfo(unsigned int index_, IndexType vtxindex_)
Definition: extractor.hh:112
~Extractor()
Destructor frees allocated memory.
Definition: extractor.hh:443
Dune::GeometryType geometryType_
The GeometryType of the subentity.
Definition: extractor.hh:188
Dune::FieldVector< ctype, dimworld > Coords
Definition: extractor.hh:65
std::map< IndexType, VertexInfo * > VertexInfoMap
Definition: extractor.hh:201