Skip to content
Snippets Groups Projects
Commit 633a40c1 authored by Jonathan Youett's avatar Jonathan Youett
Browse files

Cleanup using range-based for-loops

parent ce2ed688
No related branches found
No related tags found
No related merge requests found
......@@ -11,6 +11,7 @@
template <class GridView>
void writeBoundary(const BoundaryPatch<GridView>& surface, const std::string& filename)
{
typedef typename GridView::ctype field_type;
enum {dim = GridView::dimension};
const GridView& gv = surface.gridView();
......@@ -58,17 +59,12 @@ void writeBoundary(const BoundaryPatch<GridView>& surface, const std::string& fi
fprintf(fp, "\nVertices %lu\n", surfVertices.count());
typedef typename GridView::template Codim<dim>::Iterator VertexIterator;
VertexIterator vIt = gv.template begin<dim>();
VertexIterator vEndIt = gv.template end<dim>();
Dune::BlockVector<Dune::FieldVector<double, dim> > coords(gv.size(dim));
Dune::BlockVector<Dune::FieldVector<field_type, dim> > coords(gv.size(dim));
// resort the relevant coordinates so they appear ordered by their entities' indices
for (; vIt!=vEndIt; ++vIt)
if (surfVertices[indexSet.index(*vIt)][0])
coords[indexSet.index(*vIt)] = vIt->geometry().corner(0);
for (const auto& v : vertices(gv))
if (surfVertices[indexSet.index(v)][0])
coords[indexSet.index(v)] = v.geometry().corner(0);
// write coordinates
for (size_t i=0; i<coords.size(); i++)
......@@ -94,13 +90,11 @@ void writeBoundary(const BoundaryPatch<GridView>& surface, const std::string& fi
// quadrilaterals need to be transformed to two triangles because
// Amira doesn't know quadrilateral surface :-(((
int numFaces = 0;
// loop over all elements
typename BoundaryPatch<GridView>::iterator it = surface.begin();
typename BoundaryPatch<GridView>::iterator endIt = surface.end();
for (; it!=endIt; ++it) {
// loop over all elements
for (const auto it : surface) {
switch (it->geometry().corners()) {
switch (it.geometry().corners()) {
case 3:
numFaces++;
break;
......@@ -116,25 +110,24 @@ void writeBoundary(const BoundaryPatch<GridView>& surface, const std::string& fi
fprintf(fp, "Triangles %d\n", numFaces);
// loop over all elements
it = surface.begin();
for (const auto it : surface) {
for (; it!=endIt; ++it) {
const auto& inside = it.inside();
const Dune::ReferenceElement<double,dim>& refElement =
Dune::ReferenceElements<double, dim>::general(it->inside()->type());
const auto& refElement = Dune::ReferenceElements<field_type, dim>::general(inside.type());
int n = refElement.size(it->indexInInside(), 1, dim);
int n = refElement.size(it.indexInInside(), 1, dim);
fprintf(fp, " %d %d %d\n",
globalToLocal[indexSet.subIndex(*it->inside(), refElement.subEntity(it->indexInInside(), 1, 0, dim), dim)] + 1,
globalToLocal[indexSet.subIndex(*it->inside(), refElement.subEntity(it->indexInInside(), 1, 1, dim), dim)] + 1,
globalToLocal[indexSet.subIndex(*it->inside(), refElement.subEntity(it->indexInInside(), 1, 2, dim), dim)] + 1);
globalToLocal[indexSet.subIndex(inside, refElement.subEntity(it.indexInInside(), 1, 0, dim), dim)] + 1,
globalToLocal[indexSet.subIndex(inside, refElement.subEntity(it.indexInInside(), 1, 1, dim), dim)] + 1,
globalToLocal[indexSet.subIndex(inside, refElement.subEntity(it.indexInInside(), 1, 2, dim), dim)] + 1);
if (n==4)
fprintf(fp, " %d %d %d\n",
globalToLocal[indexSet.subIndex(*it->inside(), refElement.subEntity(it->indexInInside(), 1, 2, dim), dim)] + 1,
globalToLocal[indexSet.subIndex(*it->inside(), refElement.subEntity(it->indexInInside(), 1, 3, dim), dim)] + 1,
globalToLocal[indexSet.subIndex(*it->inside(), refElement.subEntity(it->indexInInside(), 1, 0, dim), dim)] + 1);
globalToLocal[indexSet.subIndex(inside, refElement.subEntity(it.indexInInside(), 1, 2, dim), dim)] + 1,
globalToLocal[indexSet.subIndex(inside, refElement.subEntity(it.indexInInside(), 1, 3, dim), dim)] + 1,
globalToLocal[indexSet.subIndex(inside, refElement.subEntity(it.indexInInside(), 1, 0, dim), dim)] + 1);
}
......@@ -212,11 +205,8 @@ void writeLineSet(const BoundaryPatch<GridView>& surface, const std::string& fil
fgrid<<"\n";
fgrid<<"@2 \n";
typename BoundaryPatch<GridView>::iterator it = surface.begin();
typename BoundaryPatch<GridView>::iterator itEnd = surface.end();
for (; it != itEnd; ++it) {
auto geom = it->geometry();
for (const auto& it : surface) {
auto geom = it.geometry();
for (int i = 0; i <2; ++i)
fgrid << geom.corner(i) <<" "<<0<<"\n";
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment