Commit 7a4509bc authored by Pietro Incardona's avatar Pietro Incardona

Fixing grid 1D

parent e5756fb2
...@@ -9,8 +9,9 @@ All notable changes to this project will be documented in this file. ...@@ -9,8 +9,9 @@ All notable changes to this project will be documented in this file.
### Fixed ### Fixed
- Installation PETSC installation fail in case of preinstalled MPI - Installation PETSC installation fail in case of preinstalled MPI
- Miss-compilation of SUITESPARSE on gcc-6.2
- vector_dist with negative domain (Now supported) - vector_dist with negative domain (Now supported)
- Grid 1D fixing - Grid 1D has been fixed
### Changed ### Changed
......
...@@ -43,7 +43,7 @@ else ...@@ -43,7 +43,7 @@ else
sed -i "/INSTALL_LIB\s=\s\/usr\/local\/lib/c\INSTALL_LIB = $1\/SUITESPARSE\/lib" SuiteSparse_config/SuiteSparse_config.mk sed -i "/INSTALL_LIB\s=\s\/usr\/local\/lib/c\INSTALL_LIB = $1\/SUITESPARSE\/lib" SuiteSparse_config/SuiteSparse_config.mk
sed -i "/INSTALL_INCLUDE\s=\s\/usr\/local\/include/c\INSTALL_INCLUDE = $1\/SUITESPARSE\/include" SuiteSparse_config/SuiteSparse_config.mk sed -i "/INSTALL_INCLUDE\s=\s\/usr\/local\/include/c\INSTALL_INCLUDE = $1\/SUITESPARSE\/include" SuiteSparse_config/SuiteSparse_config.mk
sed -i "/\sLAPACK\s=\s-llapack/c\LAPACK = " SuiteSparse_config/SuiteSparse_config.mk sed -i "/\sLAPACK\s=\s-llapack/c\LAPACK = " SuiteSparse_config/SuiteSparse_config.mk
sed -i "/\sBLAS\s=\s\-lopenblas/c\BLAS = -L$1/OPENBLAS/lib -lopenblas" SuiteSparse_config/SuiteSparse_config.mk sed -i "/\sBLAS\s=\s\-lopenblas/c\BLAS = -L$1/OPENBLAS/lib -lopenblas -lpthread" SuiteSparse_config/SuiteSparse_config.mk
fi fi
......
This diff is collapsed.
...@@ -57,7 +57,6 @@ BOOST_AUTO_TEST_CASE( CartDecomposition_non_periodic_test) ...@@ -57,7 +57,6 @@ BOOST_AUTO_TEST_CASE( CartDecomposition_non_periodic_test)
// Vcluster // Vcluster
Vcluster & vcl = create_vcluster(); Vcluster & vcl = create_vcluster();
//! [Create CartDecomposition]
CartDecomposition<3, float> dec(vcl); CartDecomposition<3, float> dec(vcl);
// Physical domain // Physical domain
...@@ -83,8 +82,6 @@ BOOST_AUTO_TEST_CASE( CartDecomposition_non_periodic_test) ...@@ -83,8 +82,6 @@ BOOST_AUTO_TEST_CASE( CartDecomposition_non_periodic_test)
dec.setParameters(div,box,bc,g); dec.setParameters(div,box,bc,g);
dec.decompose(); dec.decompose();
//! [Create CartDecomposition]
// For each calculated ghost box // For each calculated ghost box
for (size_t i = 0; i < dec.getNIGhostBox(); i++) for (size_t i = 0; i < dec.getNIGhostBox(); i++)
{ {
...@@ -244,7 +241,6 @@ BOOST_AUTO_TEST_CASE( CartDecomposition_ext_non_periodic_test) ...@@ -244,7 +241,6 @@ BOOST_AUTO_TEST_CASE( CartDecomposition_ext_non_periodic_test)
// Vcluster // Vcluster
Vcluster & vcl = create_vcluster(); Vcluster & vcl = create_vcluster();
//! [Create CartDecomposition]
CartDecomposition<3,float> dec(vcl); CartDecomposition<3,float> dec(vcl);
// Physical domain // Physical domain
......
...@@ -93,9 +93,9 @@ BOOST_AUTO_TEST_CASE( nn_processor_np_test) ...@@ -93,9 +93,9 @@ BOOST_AUTO_TEST_CASE( nn_processor_np_test)
if (v_cl.getProcessUnitID() == 0) if (v_cl.getProcessUnitID() == 0)
{ {
BOOST_REQUIRE_EQUAL(nnp.getNRealSubdomains(1),1); BOOST_REQUIRE_EQUAL(nnp.getNRealSubdomains(1),1ul);
BOOST_REQUIRE_EQUAL(nnp.getNRealSubdomains(2),1); BOOST_REQUIRE_EQUAL(nnp.getNRealSubdomains(2),1ul);
BOOST_REQUIRE_EQUAL(nnp.getNRealSubdomains(3),1); BOOST_REQUIRE_EQUAL(nnp.getNRealSubdomains(3),1ul);
const openfpm::vector< ::Box<2,float> > & nsubs1 = nnp.getNearSubdomains(1); const openfpm::vector< ::Box<2,float> > & nsubs1 = nnp.getNearSubdomains(1);
const openfpm::vector< ::Box<2,float> > & nsubs2 = nnp.getNearSubdomains(2); const openfpm::vector< ::Box<2,float> > & nsubs2 = nnp.getNearSubdomains(2);
...@@ -120,9 +120,9 @@ BOOST_AUTO_TEST_CASE( nn_processor_np_test) ...@@ -120,9 +120,9 @@ BOOST_AUTO_TEST_CASE( nn_processor_np_test)
} }
else if (v_cl.getProcessUnitID() == 1) else if (v_cl.getProcessUnitID() == 1)
{ {
BOOST_REQUIRE_EQUAL(nnp.getNRealSubdomains(0),1); BOOST_REQUIRE_EQUAL(nnp.getNRealSubdomains(0),1ul);
BOOST_REQUIRE_EQUAL(nnp.getNRealSubdomains(2),1); BOOST_REQUIRE_EQUAL(nnp.getNRealSubdomains(2),1ul);
BOOST_REQUIRE_EQUAL(nnp.getNRealSubdomains(3),1); BOOST_REQUIRE_EQUAL(nnp.getNRealSubdomains(3),1ul);
const openfpm::vector< ::Box<2,float> > & nsubs1 = nnp.getNearSubdomains(0); const openfpm::vector< ::Box<2,float> > & nsubs1 = nnp.getNearSubdomains(0);
const openfpm::vector< ::Box<2,float> > & nsubs2 = nnp.getNearSubdomains(2); const openfpm::vector< ::Box<2,float> > & nsubs2 = nnp.getNearSubdomains(2);
...@@ -147,9 +147,9 @@ BOOST_AUTO_TEST_CASE( nn_processor_np_test) ...@@ -147,9 +147,9 @@ BOOST_AUTO_TEST_CASE( nn_processor_np_test)
} }
else if (v_cl.getProcessUnitID() == 2) else if (v_cl.getProcessUnitID() == 2)
{ {
BOOST_REQUIRE_EQUAL(nnp.getNRealSubdomains(1),1); BOOST_REQUIRE_EQUAL(nnp.getNRealSubdomains(1),1ul);
BOOST_REQUIRE_EQUAL(nnp.getNRealSubdomains(0),1); BOOST_REQUIRE_EQUAL(nnp.getNRealSubdomains(0),1ul);
BOOST_REQUIRE_EQUAL(nnp.getNRealSubdomains(3),1); BOOST_REQUIRE_EQUAL(nnp.getNRealSubdomains(3),1ul);
const openfpm::vector< ::Box<2,float> > & nsubs1 = nnp.getNearSubdomains(1); const openfpm::vector< ::Box<2,float> > & nsubs1 = nnp.getNearSubdomains(1);
const openfpm::vector< ::Box<2,float> > & nsubs2 = nnp.getNearSubdomains(0); const openfpm::vector< ::Box<2,float> > & nsubs2 = nnp.getNearSubdomains(0);
...@@ -173,9 +173,9 @@ BOOST_AUTO_TEST_CASE( nn_processor_np_test) ...@@ -173,9 +173,9 @@ BOOST_AUTO_TEST_CASE( nn_processor_np_test)
} }
else if (v_cl.getProcessUnitID() == 3) else if (v_cl.getProcessUnitID() == 3)
{ {
BOOST_REQUIRE_EQUAL(nnp.getNRealSubdomains(0),1); BOOST_REQUIRE_EQUAL(nnp.getNRealSubdomains(0),1ul);
BOOST_REQUIRE_EQUAL(nnp.getNRealSubdomains(1),1); BOOST_REQUIRE_EQUAL(nnp.getNRealSubdomains(1),1ul);
BOOST_REQUIRE_EQUAL(nnp.getNRealSubdomains(2),1); BOOST_REQUIRE_EQUAL(nnp.getNRealSubdomains(2),1ul);
const openfpm::vector< ::Box<2,float> > & nsubs1 = nnp.getNearSubdomains(0); const openfpm::vector< ::Box<2,float> > & nsubs1 = nnp.getNearSubdomains(0);
const openfpm::vector< ::Box<2,float> > & nsubs2 = nnp.getNearSubdomains(1); const openfpm::vector< ::Box<2,float> > & nsubs2 = nnp.getNearSubdomains(1);
...@@ -250,9 +250,9 @@ BOOST_AUTO_TEST_CASE( nn_processor_box_periodic_test) ...@@ -250,9 +250,9 @@ BOOST_AUTO_TEST_CASE( nn_processor_box_periodic_test)
if (v_cl.getProcessUnitID() == 0) if (v_cl.getProcessUnitID() == 0)
{ {
BOOST_REQUIRE_EQUAL(nnp.getNearSubdomains(1).size(),4); BOOST_REQUIRE_EQUAL(nnp.getNearSubdomains(1).size(),4ul);
BOOST_REQUIRE_EQUAL(nnp.getNearSubdomains(2).size(),4); BOOST_REQUIRE_EQUAL(nnp.getNearSubdomains(2).size(),4ul);
BOOST_REQUIRE_EQUAL(nnp.getNearSubdomains(3).size(),4); BOOST_REQUIRE_EQUAL(nnp.getNearSubdomains(3).size(),4ul);
openfpm::vector<Box<2,float>> bv; openfpm::vector<Box<2,float>> bv;
...@@ -286,9 +286,9 @@ BOOST_AUTO_TEST_CASE( nn_processor_box_periodic_test) ...@@ -286,9 +286,9 @@ BOOST_AUTO_TEST_CASE( nn_processor_box_periodic_test)
} }
else if (v_cl.getProcessUnitID() == 1) else if (v_cl.getProcessUnitID() == 1)
{ {
BOOST_REQUIRE_EQUAL(nnp.getNearSubdomains(0).size(),4); BOOST_REQUIRE_EQUAL(nnp.getNearSubdomains(0).size(),4ul);
BOOST_REQUIRE_EQUAL(nnp.getNearSubdomains(2).size(),4); BOOST_REQUIRE_EQUAL(nnp.getNearSubdomains(2).size(),4ul);
BOOST_REQUIRE_EQUAL(nnp.getNearSubdomains(3).size(),4); BOOST_REQUIRE_EQUAL(nnp.getNearSubdomains(3).size(),4ul);
openfpm::vector<Box<2,float>> bv; openfpm::vector<Box<2,float>> bv;
...@@ -322,9 +322,9 @@ BOOST_AUTO_TEST_CASE( nn_processor_box_periodic_test) ...@@ -322,9 +322,9 @@ BOOST_AUTO_TEST_CASE( nn_processor_box_periodic_test)
} }
else if (v_cl.getProcessUnitID() == 2) else if (v_cl.getProcessUnitID() == 2)
{ {
BOOST_REQUIRE_EQUAL(nnp.getNearSubdomains(0).size(),4); BOOST_REQUIRE_EQUAL(nnp.getNearSubdomains(0).size(),4ul);
BOOST_REQUIRE_EQUAL(nnp.getNearSubdomains(1).size(),4); BOOST_REQUIRE_EQUAL(nnp.getNearSubdomains(1).size(),4ul);
BOOST_REQUIRE_EQUAL(nnp.getNearSubdomains(3).size(),4); BOOST_REQUIRE_EQUAL(nnp.getNearSubdomains(3).size(),4ul);
openfpm::vector<Box<2,float>> bv; openfpm::vector<Box<2,float>> bv;
...@@ -358,9 +358,9 @@ BOOST_AUTO_TEST_CASE( nn_processor_box_periodic_test) ...@@ -358,9 +358,9 @@ BOOST_AUTO_TEST_CASE( nn_processor_box_periodic_test)
} }
else if (v_cl.getProcessUnitID() == 3) else if (v_cl.getProcessUnitID() == 3)
{ {
BOOST_REQUIRE_EQUAL(nnp.getNearSubdomains(0).size(),4); BOOST_REQUIRE_EQUAL(nnp.getNearSubdomains(0).size(),4ul);
BOOST_REQUIRE_EQUAL(nnp.getNearSubdomains(1).size(),4); BOOST_REQUIRE_EQUAL(nnp.getNearSubdomains(1).size(),4ul);
BOOST_REQUIRE_EQUAL(nnp.getNearSubdomains(2).size(),4); BOOST_REQUIRE_EQUAL(nnp.getNearSubdomains(2).size(),4ul);
openfpm::vector<Box<2,float>> bv; openfpm::vector<Box<2,float>> bv;
......
...@@ -116,9 +116,11 @@ class grid_dist_iterator<dim,device_grid,FREE> ...@@ -116,9 +116,11 @@ class grid_dist_iterator<dim,device_grid,FREE>
/*! \brief Constructor of the distributed grid iterator /*! \brief Constructor of the distributed grid iterator
* *
* \param gk std::vector of the local grid * \param gk std::vector of the local grid
* \param gdb_ext set of local subdomains
* \param stop end point
* *
*/ */
grid_dist_iterator(const openfpm::vector<device_grid> & gk, const openfpm::vector<GBoxes<device_grid::dims>> & gdb_ext, grid_key_dx<dim> stop) grid_dist_iterator(const openfpm::vector<device_grid> & gk, const openfpm::vector<GBoxes<device_grid::dims>> & gdb_ext, const grid_key_dx<dim> & stop)
:g_c(0),gList(gk),gdb_ext(gdb_ext),stop(stop) :g_c(0),gList(gk),gdb_ext(gdb_ext),stop(stop)
{ {
// Initialize the current iterator // Initialize the current iterator
......
...@@ -390,11 +390,131 @@ void Test2D(const Box<2,float> & domain, long int k) ...@@ -390,11 +390,131 @@ void Test2D(const Box<2,float> & domain, long int k)
// In this case the boundary condition are non periodic // In this case the boundary condition are non periodic
if (g_dist.isInside(key_g)) if (g_dist.isInside(key_g))
{ {
match &= (g_dist.template get<0>(key),info.LinId(key_g)); match &= (g_dist.template get<0>(key) == info.LinId(key_g))?true:false;
} }
++domg; ++domg;
} }
BOOST_REQUIRE_EQUAL(match,true);
}
}
void Test1D(const Box<1,float> & domain, long int k)
{
Vcluster & v_cl = create_vcluster();
long int big_step = k / 30;
big_step = (big_step == 0)?1:big_step;
long int small_step = 21;
if (v_cl.getProcessingUnits() > 48)
return;
print_test( "Testing 1D grid k<=",k);
// 1D test
for ( ; k >= 2 ; k-= (k > 2*big_step)?big_step:small_step )
{
BOOST_TEST_CHECKPOINT( "Testing 1D grid k=" << k );
//! [Create and access a distributed grid]
// grid size
size_t sz[1];
sz[0] = k;
float factor = pow(create_vcluster().getProcessingUnits()/2.0f,1.0f);
// Ghost
Ghost<1,float> g(0.01 / factor);
// Distributed grid with id decomposition
grid_dist_id<1, float, scalar<float>> g_dist(sz,domain,g);
// check the consistency of the decomposition
bool val = g_dist.getDecomposition().check_consistency();
BOOST_REQUIRE_EQUAL(val,true);
// Grid sm
grid_sm<1,void> info(sz);
// get the domain iterator
size_t count = 0;
auto dom = g_dist.getDomainIterator();
while (dom.isNext())
{
auto key = dom.get();
auto key_g = g_dist.getGKey(key);
g_dist.template get<0>(key) = info.LinId(key_g);
// Count the point
count++;
++dom;
}
//! [Create and access a distributed grid]
// Get the virtual cluster machine
Vcluster & vcl = g_dist.getVC();
// reduce
vcl.sum(count);
vcl.execute();
// Check
BOOST_REQUIRE_EQUAL(count,(size_t)k);
auto dom2 = g_dist.getDomainIterator();
grid_key_dx<1> start = dom2.getStart();
grid_key_dx<1> stop = dom2.getStop();
BOOST_REQUIRE_EQUAL((long int)stop.get(0),(long int)g_dist.size(0)-1);
BOOST_REQUIRE_EQUAL(start.get(0),0);
bool match = true;
// check that the grid store the correct information
while (dom2.isNext())
{
auto key = dom2.get();
auto key_g = g_dist.getGKey(key);
match &= (g_dist.template get<0>(key) == info.LinId(key_g))?true:false;
++dom2;
}
BOOST_REQUIRE_EQUAL(match,true);
g_dist.template ghost_get<0>();
// check that the communication is correctly completed
auto domg = g_dist.getDomainGhostIterator();
// check that the grid with the ghost past store the correct information
while (domg.isNext())
{
auto key = domg.get();
auto key_g = g_dist.getGKey(key);
// In this case the boundary condition are non periodic
if (g_dist.isInside(key_g))
{
match &= (g_dist.template get<0>(key) == info.LinId(key_g))?true:false;
}
++domg;
}
BOOST_REQUIRE_EQUAL(match,true);
} }
} }
...@@ -1770,6 +1890,16 @@ BOOST_AUTO_TEST_CASE( grid_dist_id_copy ) ...@@ -1770,6 +1890,16 @@ BOOST_AUTO_TEST_CASE( grid_dist_id_copy )
Test_grid_copy(domain3,k); Test_grid_copy(domain3,k);
} }
BOOST_AUTO_TEST_CASE( grid_1d_test )
{
// Domain
Box<1,float> domain1({-1.0},{1.0});
long int k = 32*32*32*create_vcluster().getProcessingUnits();
Test1D(domain1,k);
}
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()
#endif #endif
...@@ -1191,8 +1191,13 @@ BOOST_AUTO_TEST_CASE( vector_dist_cell_verlet_test ) ...@@ -1191,8 +1191,13 @@ BOOST_AUTO_TEST_CASE( vector_dist_cell_verlet_test )
// Boundary conditions // Boundary conditions
size_t bc[3]={PERIODIC,PERIODIC,PERIODIC}; size_t bc[3]={PERIODIC,PERIODIC,PERIODIC};
float spacing = 1.0/Ng;
float first_dist = spacing;
float second_dist = sqrt(2.0*spacing*spacing);
float third_dist = sqrt(3.0 * spacing*spacing);
// ghost // ghost
Ghost<3,float> ghost(1.0/(Ng-2)); Ghost<3,float> ghost(third_dist*1.1);
// Distributed vector // Distributed vector
vector_dist<3,float, Point_test<float>, CartDecomposition<3,float> > vd(0,box,bc,ghost); vector_dist<3,float, Point_test<float>, CartDecomposition<3,float> > vd(0,box,bc,ghost);
...@@ -1229,14 +1234,11 @@ BOOST_AUTO_TEST_CASE( vector_dist_cell_verlet_test ) ...@@ -1229,14 +1234,11 @@ BOOST_AUTO_TEST_CASE( vector_dist_cell_verlet_test )
vd.ghost_get<0>(); vd.ghost_get<0>();
vd.write("Debug_output");
// calculate the distance of the first, second and third neighborhood particle // calculate the distance of the first, second and third neighborhood particle
// Consider that they are on a regular grid // Consider that they are on a regular grid
float spacing = it.getSpacing(0);
float first_dist = spacing;
float second_dist = sqrt(2.0*spacing*spacing);
float third_dist = sqrt(3.0 * spacing*spacing);
// add a 5% to dist // add a 5% to dist
first_dist += first_dist * 0.05; first_dist += first_dist * 0.05;
...@@ -1249,6 +1251,8 @@ BOOST_AUTO_TEST_CASE( vector_dist_cell_verlet_test ) ...@@ -1249,6 +1251,8 @@ BOOST_AUTO_TEST_CASE( vector_dist_cell_verlet_test )
bool correct = true; bool correct = true;
BOOST_REQUIRE_EQUAL(vd.size_local(),verlet.size());
// for each particle // for each particle
for (size_t i = 0 ; i < verlet.size() ; i++) for (size_t i = 0 ; i < verlet.size() ; i++)
{ {
......
This diff is collapsed.
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