Commit 867d559c authored by Pietro Incardona's avatar Pietro Incardona

Periodic boundary condition working

parent 52a2407a
......@@ -585,7 +585,7 @@ public:
auto key = it.get();
// Apply the boundary conditions
// dec.applyPointBC(v_pos.get(key));
dec.applyPointBC(v_pos.get(key));
size_t p_id = dec.processorIDBC(v_pos.get(key));
......
......@@ -700,8 +700,6 @@ BOOST_AUTO_TEST_CASE( vector_dist_periodic_test_random_walk )
vd.template getPos<s::x>(key)[1] += 0.02 * ud(eg);
vd.template getPos<s::x>(key)[2] += 0.02 * ud(eg);
ct.applyPointBC(vd.template getPos<s::x>(key));
++it;
}
......@@ -717,6 +715,104 @@ BOOST_AUTO_TEST_CASE( vector_dist_periodic_test_random_walk )
}
}
BOOST_AUTO_TEST_CASE( vector_dist_periodic_map )
{
typedef Point<3,float> s;
Box<3,float> box({0.0,0.0,0.0},{1.0,1.0,1.0});
// Boundary conditions
size_t bc[3]={PERIODIC,PERIODIC,PERIODIC};
// ghost
Ghost<3,float> ghost(0.05);
// Distributed vector
vector_dist<3,float, Point_test<float>, CartDecomposition<3,float> > vd(1,box,bc,ghost);
// put particles al 1.0, check that they go to 0.0
auto it = vd.getIterator();
while (it.isNext())
{
auto key = it.get();
vd.template getPos<s::x>(key)[0] = 1.0;
vd.template getPos<s::x>(key)[1] = 1.0;
vd.template getPos<s::x>(key)[2] = 1.0;
++it;
}
vd.map();
auto it2 = vd.getIterator();
while (it2.isNext())
{
auto key = it2.get();
float f = vd.template getPos<s::x>(key)[0];
BOOST_REQUIRE_EQUAL(f, 0.0);
f = vd.template getPos<s::x>(key)[1];
BOOST_REQUIRE_EQUAL(f, 0.0);
f = vd.template getPos<s::x>(key)[2];
BOOST_REQUIRE_EQUAL(f, 0.0);
++it2;
}
}
BOOST_AUTO_TEST_CASE( vector_dist_not_periodic_map )
{
typedef Point<3,float> s;
Box<3,float> box({0.0,0.0,0.0},{1.0,1.0,1.0});
// Boundary conditions
size_t bc[3]={NON_PERIODIC,NON_PERIODIC,NON_PERIODIC};
// ghost
Ghost<3,float> ghost(0.05);
// Distributed vector
vector_dist<3,float, Point_test<float>, CartDecomposition<3,float> > vd(1,box,bc,ghost);
// put particles al 1.0, check that they go to 0.0
auto it = vd.getIterator();
while (it.isNext())
{
auto key = it.get();
vd.template getPos<s::x>(key)[0] = 1.0;
vd.template getPos<s::x>(key)[1] = 1.0;
vd.template getPos<s::x>(key)[2] = 1.0;
++it;
}
vd.map();
auto it2 = vd.getIterator();
while (it2.isNext())
{
auto key = it2.get();
float f = vd.template getPos<s::x>(key)[0];
BOOST_REQUIRE_EQUAL(f, 1.0);
f = vd.template getPos<s::x>(key)[1];
BOOST_REQUIRE_EQUAL(f, 1.0);
f = vd.template getPos<s::x>(key)[2];
BOOST_REQUIRE_EQUAL(f, 1.0);
++it2;
}
}
BOOST_AUTO_TEST_SUITE_END()
#endif /* VECTOR_DIST_UNIT_TEST_HPP_ */
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