18 #ifndef DUNE_GRIDGLUE_EXTRACTORS_CODIM0EXTRACTOR_HH 19 #define DUNE_GRIDGLUE_EXTRACTORS_CODIM0EXTRACTOR_HH 24 #include <dune/common/deprecated.hh> 25 #include <dune/grid/common/mcmgmapper.hh> 47 typedef typename GV::Traits::template Codim<dim>::Entity
Vertex;
48 typedef typename GV::Traits::template Codim<0>::Entity
Element;
49 typedef std::function<bool(const Element&, unsigned int subentity)>
Predicate;
51 static const Dune::PartitionIteratorType
PType = Dune::Interior_Partition;
52 typedef typename GV::Traits::template Codim<0>::template Partition<PType>::Iterator
ElementIter;
66 DUNE_DEPRECATED_MSG(
"Please use a std::function<bool(const Element&, unsigned int)> in favor of the ExtractorPredicate.")
70 std::cout <<
"This is Codim0Extractor on a <" 71 << GV::dimension <<
"," << GV::dimensionworld <<
"> grid!" << std::endl;
72 const auto predicate = [&](
const Element&
element,
unsigned int subentity) ->
bool {
73 return descr.contains(element, subentity);
86 std::cout <<
"This is Codim0Extractor on a <" 87 << GV::dimension <<
"," << GV::dimensionworld <<
"> grid!" << std::endl;
97 void update(
const Predicate& predicate);
101 template<
typename GV>
112 size_t element_index = 0;
113 size_t vertex_index = 0;
117 std::deque<SubEntityInfo> temp_faces;
121 elit != this->gv_.template end<0, PType>(); ++elit)
123 const auto& elmt = *elit;
124 const auto geometry = elmt.geometry();
129 if (predicate(elmt,0))
134 unsigned int numCorners = elmt.subEntities(
dim);
135 unsigned int vertex_indices[numCorners];
136 unsigned int vertex_numbers[numCorners];
139 for (
unsigned int i = 0; i < numCorners; ++i)
141 vertex_numbers[i] = i;
144 const Vertex vertex = elit->template subEntity<dim>(vertex_numbers[i]);
149 typename VertexInfoMap::iterator vimit = this->
vtxInfo_.find(vindex);
155 vertex_indices[i] = vertex_index;
162 vertex_indices[i] = vimit->second->idx;
178 bool elementNormalDirection =
182 std::swap(vertex_indices[0], vertex_indices[1]);
183 std::swap(vertex_numbers[0], vertex_numbers[1]);
189 Dune::FieldVector<ctype, dimworld>
194 ctype normal_sign = v0[0]*v1[1] - v0[1]*v1[0];
195 bool elementNormalDirection = (normal_sign < 0);
198 std::cout <<
"swap\n";
199 if (elmt.type().isCube())
201 for (
int i = 0; i < (1<<
dim); i+=2)
204 std::swap(vertex_indices[i], vertex_indices[i+1]);
205 std::swap(vertex_numbers[i], vertex_numbers[i+1]);
207 }
else if (elmt.type().isSimplex()) {
208 std::swap(vertex_indices[0], vertex_indices[1]);
209 std::swap(vertex_numbers[0], vertex_numbers[1]);
211 DUNE_THROW(Dune::Exception,
"Unexpected Geometrytype");
222 for (
unsigned int i=0; i<numCorners; i++) {
223 temp_faces.back().corners[i].idx = vertex_indices[i];
225 temp_faces.back().corners[i].num = vertex_numbers[i];
234 copy(temp_faces.begin(), temp_faces.end(), this->
subEntities_.begin());
238 typename VertexInfoMap::const_iterator it1 = this->
vtxInfo_.begin();
239 for (; it1 != this->
vtxInfo_.end(); ++it1)
244 current->index = it1->second->idx;
246 current->vtxindex = it1->first;
249 const auto vtx = this->
grid().entity(it1->second->p);
250 current->coord = vtx.geometry().corner(0);
259 #endif // DUNE_GRIDGLUE_EXTRACTORS_CODIM0EXTRACTOR_HH bool & positiveNormalDirection()
Definition: codim0extractor.hh:91
void clear()
delete everything build up so far and free the memory
Definition: extractor.hh:235
GV::Traits::template Codim< 0 >::template Partition< PType >::Iterator ElementIter
Definition: codim0extractor.hh:52
std::vector< CoordinateInfo > coords_
all information about the corner vertices of the extracted
Definition: extractor.hh:194
Codim0Extractor(const GV &gv, const Predicate &predicate)
Constructor.
Definition: codim0extractor.hh:83
std::vector< SubEntityInfo > subEntities_
all information about the extracted subEntities
Definition: extractor.hh:197
VertexInfoMap vtxInfo_
a map enabling faster access to vertices and coordinates
Definition: extractor.hh:204
Base class for subentity-selecting predicates.
Definition: extractorpredicate.hh:30
Base class for predicates selecting the part of a grid to be extracted.
Extractor< GV, 0 >::ElementInfo ElementInfo
Definition: codim0extractor.hh:56
Extractor< GV, 0 >::VertexInfoMap VertexInfoMap
Definition: codim0extractor.hh:59
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
bool positiveNormalDirection_
Definition: codim0extractor.hh:95
GV::Traits::template Codim< dim >::Entity Vertex
Definition: codim0extractor.hh:47
Provides codimension-independent methods for grid extraction.
Definition: extractor.hh:42
ElementInfoMap elmtInfo_
a map enabling faster access to elements and faces
Definition: extractor.hh:211
const bool & positiveNormalDirection() const
Definition: codim0extractor.hh:92
const Grid & grid() const
Definition: extractor.hh:363
CellMapper cellMapper_
Definition: extractor.hh:213
Geometry geometry(unsigned int index) const
Get world geometry of the extracted face.
Definition: extractor.hh:418
Extractor< GV, 0 >::CoordinateInfo CoordinateInfo
Definition: codim0extractor.hh:58
Extractor< GV, 0 >::VertexInfo VertexInfo
Definition: codim0extractor.hh:57
GV::Traits::template Codim< 0 >::Entity Element
Definition: codim0extractor.hh:48
const GridView gv_
the grid object to extract the surface from
Definition: extractor.hh:189
Extractor< GV, 0 >::SubEntityInfo SubEntityInfo
Definition: codim0extractor.hh:55
Definition: codim0extractor.hh:35
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
Extractor< GV, 0 >::IndexType IndexType
Definition: codim0extractor.hh:45
static const Dune::PartitionIteratorType PType
Definition: codim0extractor.hh:51
Definition: extractor.hh:48
std::function< bool(const Element &, unsigned int subentity)> Predicate
Definition: codim0extractor.hh:49
Definition: gridglue.hh:30
Extractor< GV, 0 >::ctype ctype
Definition: codim0extractor.hh:42