Liebe Gitlab-Nutzer, lieber Gitlab-Nutzer, es ist nun möglich sich mittels des ZIH-Logins/LDAP an unserem Dienst anzumelden. Ein Anmelden über dieses erzeugt ein neues Konto. Das alte Konto ist über den Reiter "Standard" erreichbar. Die Administratoren

Dear Gitlab user, it is now possible to log in to our service using the ZIH login/LDAP. Logging in via this will create a new account. The old account can be accessed via the "Standard" tab. The administrators

Commit 670041db authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

removed some segfaults in traversal

parent f7657c89
......@@ -52,10 +52,10 @@ namespace Dune
struct EntityStackEntry
{
template <class It, class End>
EntityStackEntry(It&& it, End&& end)
: it(std::forward<It>(it))
, end(std::forward<End>(end))
template <class Entity>
explicit EntityStackEntry(Entity&& entity)
: it(entity.hbegin(entity.level()+1))
, end(entity.hend(entity.level()+1))
{}
typename HostEntity::HierarchicIterator it;
......@@ -149,8 +149,8 @@ namespace Dune
std::vector<HostEntity> dereference () const
{
std::vector<HostEntity> multiEntity;
for (auto const& stack : entityStacks_)
multiEntity.push_back(*stack.top().it);
for (std::size_t i = 0; i < entityStacks_.size(); ++i)
multiEntity.push_back(dereference(i));
return multiEntity;
}
......@@ -187,16 +187,12 @@ namespace Dune
++macroIt;
if (macroIt == macroEnd)
return;
auto entity = *macroIt;
entityStack.emplace(entity.hbegin(0), entity.hend(0));
}
// 3. go down in tree until leaf entity
for (auto child = *entityStack.top().it; !entityTest(child);
child = *entityStack.top().it) {
int childLevel = child.level() + 1;
entityStack.emplace(child.hbegin(childLevel), child.hend(childLevel));
for (auto child = dereference(i); !entityTest(child);
child = dereference(i)) {
entityStack.emplace(child);
}
}
......@@ -221,21 +217,19 @@ namespace Dune
if (macroIt == macroEnd)
return;
// 1. push first entry to stack
auto entity = *macroIt;
entityStack.emplace(entity.hbegin(0), entity.hend(0));
// 2. go down in tree until leaf entity
for (auto child = *entityStack.top().it; !entityTest(child);
child = *entityStack.top().it) {
int childLevel = child.level() + 1;
entityStack.emplace(child.hbegin(childLevel), child.hend(childLevel));
for (auto child = dereference(i); !entityTest(child);
child = dereference(i)) {
entityStack.emplace(child);
}
}
HostEntity dereference (std::size_t i) const
{
return *entityStacks_[i].top().it;
if (entityStacks_[i].empty())
return *macroIterators_[i];
else
return *entityStacks_[i].top().it;
}
bool entityTest(HostEntity const& entity)
......@@ -253,8 +247,6 @@ namespace Dune
std::vector<EntityStack> entityStacks_;
std::vector<bool> incrementAllowed_;
int level_ = -1;
double time1 = 0.0, time2 = 0.0, time3 = 0.0, time4 = 0.0;
};
} // end namespace Dune
......
......@@ -17,7 +17,7 @@
#include <dune/multimesh/mmgridfactory.hh>
#include <dune/multimesh/utility/structuredgridfactory.hh>
#define GRID 3
#define GRID 1
using namespace Dune;
......@@ -27,7 +27,7 @@ void printGrid(Grid const& grid)
volatile std::size_t n = 0;
Dune::Timer t;
for (auto const& entities : elements(grid.leafGridView()))
n = std::max(std::size_t(n), std::size_t(grid.grid(0).leafIndexSet().index(entities[0])));
n += grid.grid(0).leafIndexSet().index(entities[0]);
std::cout << n << "\n";
std::cout << "time: " << t.elapsed() << "\n";
}
......@@ -38,7 +38,7 @@ void printGrid2(Grid const& grid)
volatile std::size_t n = 0;
Dune::Timer t;
for (auto const& entity : elements(grid.leafGridView()))
n = std::max(std::size_t(n), std::size_t(grid.leafIndexSet().index(entity)));
n += grid.leafIndexSet().index(entity);
std::cout << n << "\n";
std::cout << "time: " << t.elapsed() << "\n";
}
......@@ -55,10 +55,10 @@ int main(int argc, char** argv)
using HostGrid = YaspGrid<3, EquidistantOffsetCoordinates<double,3>>;
MultiMesh<HostGrid> grid(2, lower_left, bbox, num_elements);
#elif GRID == 2
FieldVector<double,3> lower_left = {-1.5, -1.5, -1.5};
FieldVector<double,3> bbox = {1.5, 1.5, 1.5};
std::array<unsigned int,3> num_elements = {2, 2, 2};
using HostGrid = Dune::ALUGrid<3, 3, Dune::simplex, Dune::conforming>;
FieldVector<double,2> lower_left = {-1.5, -1.5};
FieldVector<double,2> bbox = {1.5, 1.5};
std::array<unsigned int,2> num_elements = {2, 2};
using HostGrid = Dune::ALUGrid<2, 2, Dune::simplex, Dune::conforming>;
using Factory = StructuredGridFactoryWrapper<MultiMesh<HostGrid> >;
GridFactory<MultiMesh<HostGrid> > gridFactory(2);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment