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> 49 typedef typename GV::Traits::template Codim<dim>::Entity
Vertex;
50 typedef typename GV::Traits::template Codim<0>::Entity
Element;
51 typedef std::function<bool(const Element&, unsigned int subentity)>
Predicate;
68 std::cout <<
"This is Codim0Extractor on a <" 69 << GV::dimension <<
"," << GV::dimensionworld <<
"> grid!" << std::endl;
79 void update(
const Predicate& predicate);
94 size_t element_index = 0;
95 size_t vertex_index = 0;
99 std::deque<SubEntityInfo> temp_faces;
102 for (
const auto& elmt : elements(this->
gv_, Partitions::interior))
104 const auto geometry = elmt.geometry();
109 if (predicate(elmt,0))
114 unsigned int numCorners = elmt.subEntities(
dim);
115 unsigned int vertex_indices[numCorners];
116 unsigned int vertex_numbers[numCorners];
119 for (
unsigned int i = 0; i < numCorners; ++i)
121 vertex_numbers[i] = i;
124 const Vertex vertex = elmt.template subEntity<dim>(vertex_numbers[i]);
129 typename VertexInfoMap::iterator vimit = this->
vtxInfo_.find(vindex);
135 vertex_indices[i] = vertex_index;
142 vertex_indices[i] = vimit->second.idx;
158 bool elementNormalDirection =
162 std::swap(vertex_indices[0], vertex_indices[1]);
163 std::swap(vertex_numbers[0], vertex_numbers[1]);
169 Dune::FieldVector<ctype, dimworld>
174 ctype normal_sign = v0[0]*v1[1] - v0[1]*v1[0];
175 bool elementNormalDirection = (normal_sign < 0);
178 std::cout <<
"swap\n";
179 if (elmt.type().isCube())
181 for (
int i = 0; i < (1<<
dim); i+=2)
184 std::swap(vertex_indices[i], vertex_indices[i+1]);
185 std::swap(vertex_numbers[i], vertex_numbers[i+1]);
187 }
else if (elmt.type().isSimplex()) {
188 std::swap(vertex_indices[0], vertex_indices[1]);
189 std::swap(vertex_numbers[0], vertex_numbers[1]);
191 DUNE_THROW(Dune::Exception,
"Unexpected Geometrytype");
200 temp_faces.emplace_back(eindex, 0, elmt.type());
202 for (
unsigned int i=0; i<numCorners; i++) {
203 temp_faces.back().corners[i].idx = vertex_indices[i];
205 temp_faces.back().corners[i].num = vertex_numbers[i];
214 copy(temp_faces.begin(), temp_faces.end(), this->
subEntities_.begin());
218 for (
const auto& vinfo : this->
vtxInfo_)
223 current->index = vinfo.second.idx;
225 current->vtxindex = vinfo.first;
228 const auto vtx = this->
grid().entity(vinfo.second.p);
229 current->coord = vtx.geometry().corner(0);
238 #endif // DUNE_GRIDGLUE_EXTRACTORS_CODIM0EXTRACTOR_HH static constexpr auto dim
Definition: extractor.hh:49
Extractor< GV, 0 >::VertexInfo VertexInfo
Definition: codim0extractor.hh:56
Extractor< GV, 0 >::ElementInfo ElementInfo
Definition: codim0extractor.hh:55
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
std::function< bool(const Element &, unsigned int subentity)> Predicate
Definition: codim0extractor.hh:51
Extractor< GV, 0 >::ctype ctype
Definition: codim0extractor.hh:44
const GridView gv_
the grid object to extract the surface from
Definition: extractor.hh:199
Codim0Extractor(const GV &gv, const Predicate &predicate)
Constructor.
Definition: codim0extractor.hh:65
Definition: codim0extractor.hh:37
bool positiveNormalDirection_
Definition: codim0extractor.hh:77
const bool & positiveNormalDirection() const
Definition: codim0extractor.hh:74
Extractor< GV, 0 >::CoordinateInfo CoordinateInfo
Definition: codim0extractor.hh:57
const Grid & grid() const
Definition: extractor.hh:366
VertexInfoMap vtxInfo_
a map enabling faster access to vertices and coordinates
Definition: extractor.hh:214
Extractor< GV, 0 >::IndexType IndexType
Definition: codim0extractor.hh:47
Geometry geometry(unsigned int index) const
Get world geometry of the extracted face.
Definition: extractor.hh:414
Extractor< GV, 0 >::SubEntityInfo SubEntityInfo
Definition: codim0extractor.hh:54
ElementInfoMap elmtInfo_
a map enabling faster access to elements and faces
Definition: extractor.hh:221
bool & positiveNormalDirection()
Definition: codim0extractor.hh:73
GV::Traits::template Codim< dim >::Entity Vertex
Definition: codim0extractor.hh:49
std::vector< SubEntityInfo > subEntities_
all information about the extracted subEntities
Definition: extractor.hh:207
GV::Traits::template Codim< 0 >::Entity Element
Definition: codim0extractor.hh:50
CellMapper cellMapper_
Definition: extractor.hh:223
Extractor< GV, 0 >::VertexInfoMap VertexInfoMap
Definition: codim0extractor.hh:58
Definition: gridglue.hh:35
std::vector< CoordinateInfo > coords_
all information about the corner vertices of the extracted
Definition: extractor.hh:204
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