Commit 8fd4e3d4 authored by Pietro Incardona's avatar Pietro Incardona

Fixing vector with negative domain

parent daf36c05
......@@ -123,7 +123,7 @@ protected:
//! Structure that decompose your structure into cell without creating them
//! useful to convert positions to CellId or sub-domain id in this case
CellDecomposer_sm<dim, T> cd;
CellDecomposer_sm<dim, T, shift<dim,T>> cd;
//! rectangular domain to decompose
::Box<dim,T> domain;
......@@ -137,26 +137,21 @@ protected:
//! Create distribution
Distribution dist;
// Smallest subdivision on each direction
//! Smallest subdivision on each direction
::Box<dim,T> ss_box;
//! Processor bounding box
::Box<dim,T> bbox;
// reference counter of the object in case is shared between object
//! reference counter of the object in case is shared between object
long int ref_cnt;
// ghost info
//! ghost info
Ghost<dim,T> ghost;
// Boundary condition info
//! Boundary condition info
size_t bc[dim];
// Heap memory receiver
HeapMemory hp_recv;
// Receive counter
size_t recv_cnt = 0;
/*! \brief It convert the box from the domain decomposition into sub-domain
*
* The decomposition box from the domain-decomposition contain the box in integer
......
......@@ -169,13 +169,13 @@ protected:
switch (cmbs[j][k])
{
case 1:
shifts.get(cmbs[j].lin()).template get<0>()[k] = -domain.getHigh(k);
shifts.get(cmbs[j].lin()).template get<0>()[k] = -(domain.getHigh(k) - domain.getLow(k));
break;
case 0:
shifts.get(cmbs[j].lin()).template get<0>()[k] = 0;
break;
case -1:
shifts.get(cmbs[j].lin()).template get<0>()[k] = domain.getHigh(k);
shifts.get(cmbs[j].lin()).template get<0>()[k] = (domain.getHigh(k) - domain.getLow(k));
break;
}
}
......
......@@ -28,21 +28,21 @@ class nn_prcs
//! List of adjacent processors
openfpm::vector<size_t> nn_processors;
// for each near processor store the sub-domains of the near processors
//! for each near processor store the sub-domains of the near processors
std::unordered_map<size_t, N_box<dim,T>> nn_processor_subdomains;
// when we add new boxes, are added here
//! when we add new boxes, are added here
std::unordered_map<size_t, N_box<dim,T>> nn_processor_subdomains_tmp;
// contain the same information as the member boxes with the difference that
// instead of the Box itself, it contain the sub-domain id in the list of the
// local sub-domains
//! contain the same information as the member boxes with the difference that
//! instead of the Box itself, it contain the sub-domain id in the list of the
//! local sub-domains
openfpm::vector<openfpm::vector<size_t>> proc_adj_box;
//! contain the set of sub-domains sent to the other processors
openfpm::vector< openfpm::vector< ::SpaceBox<dim,T>> > boxes;
// Receive counter
//! Receive counter
size_t recv_cnt;
//! applyBC function is suppose to be called only one time
......
......@@ -97,7 +97,7 @@ void print_test(std::string test, size_t sz)
std::cout << test << " " << sz << "\n";
}
BOOST_AUTO_TEST_CASE( vector_dist_ghost )
void Test2D_ghost(Box<2,float> & box)
{
// Communication object
Vcluster & v_cl = create_vcluster();
......@@ -111,7 +111,6 @@ BOOST_AUTO_TEST_CASE( vector_dist_ghost )
//! [Create a vector of elements distributed on a grid like way]
Box<2,float> box({0.0,0.0},{1.0,1.0});
size_t g_div[]= {sz,sz};
// number of particles
......@@ -134,7 +133,7 @@ BOOST_AUTO_TEST_CASE( vector_dist_ghost )
grid_sm<2,void> g_info(g_div);
// Calculate the grid spacing
Point<2,float> spacing = box.getP2();
Point<2,float> spacing = box.getP2() - box.getP1();
spacing = spacing / g_div;
// middle spacing
......@@ -162,8 +161,8 @@ BOOST_AUTO_TEST_CASE( vector_dist_ghost )
// set the particle position
vd.getPos(key_v)[0] = key.get(0) * spacing[0] + m_spacing[0];
vd.getPos(key_v)[1] = key.get(1) * spacing[1] + m_spacing[1];
vd.getPos(key_v)[0] = key.get(0) * spacing[0] + m_spacing[0] + box.getLow(0);
vd.getPos(key_v)[1] = key.get(1) * spacing[1] + m_spacing[1] + box.getLow(1);
cobj++;
......@@ -253,21 +252,26 @@ BOOST_AUTO_TEST_CASE( vector_dist_ghost )
BOOST_REQUIRE(n_part != 0);
}
CellDecomposer_sm<2,float> cd(SpaceBox<2,float>(box),g_div,0);
CellDecomposer_sm<2,float,shift<2,float>> cd(SpaceBox<2,float>(box),g_div,0);
for (size_t i = 0 ; i < vb.size() ; i++)
{
// Calculate how many particle should be in the box
size_t n_point = cd.getGridPoints(dec.getEGhostBox(i)).getVolumeKey();
if (n_point != vb.get(i))
{
std::cout << n_point << " " << dec.getEGhostBoxProcessor(i) << " " << v_cl.getProcessUnitID() << dec.getEGhostBox(i).toString() << "\n";
}
//BOOST_REQUIRE_EQUAL(n_point,vb.get(i));
BOOST_REQUIRE_EQUAL(n_point,vb.get(i));
}
}
BOOST_AUTO_TEST_CASE( vector_dist_ghost )
{
Box<2,float> box({0.0,0.0},{1.0,1.0});
Test2D_ghost(box);
Box<2,float> box2({-1.0,-1.0},{2.5,2.5});
Test2D_ghost(box2);
}
void print_test_v(std::string test, size_t sz)
{
if (create_vcluster().getProcessUnitID() == 0)
......@@ -952,7 +956,7 @@ BOOST_AUTO_TEST_CASE( vector_dist_out_of_bound_policy )
BOOST_REQUIRE_EQUAL(cnt_l,100-v_cl.getProcessingUnits());
}
BOOST_AUTO_TEST_CASE( vector_dist_periodic_test_interacting_particles )
void Test_interacting(Box<3,float> & box)
{
Vcluster & v_cl = create_vcluster();
......@@ -963,7 +967,7 @@ BOOST_AUTO_TEST_CASE( vector_dist_periodic_test_interacting_particles )
// create the random generator engine
std::srand(v_cl.getProcessUnitID());
std::default_random_engine eg;
std::uniform_real_distribution<float> ud(0.0f, 1.0f);
std::uniform_real_distribution<float> ud(-0.5f, 0.5f);
size_t nsz[] = {0,32,4};
nsz[0] = 65536 * v_cl.getProcessingUnits();
......@@ -977,8 +981,6 @@ BOOST_AUTO_TEST_CASE( vector_dist_periodic_test_interacting_particles )
BOOST_TEST_CHECKPOINT( "Testing 3D random walk interacting particles vector k=" << k );
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};
......@@ -1030,8 +1032,13 @@ BOOST_AUTO_TEST_CASE( vector_dist_periodic_test_interacting_particles )
vd.map();
vd.write("Without_ghost");
vd.ghost_get<0>();
vd.write("With_ghost");
vd.getDecomposition().write("With_dec_ghost");
// get the cell list with a cutoff radius
bool error = false;
......@@ -1080,12 +1087,19 @@ BOOST_AUTO_TEST_CASE( vector_dist_periodic_test_interacting_particles )
size_t cnt = total_n_part_lc(vd,bc);
BOOST_REQUIRE_EQUAL((size_t)k,cnt);
}
}
}
BOOST_AUTO_TEST_CASE( vector_dist_periodic_test_interacting_particles )
{
Box<3,float> box({0.0,0.0,0.0},{1.0,1.0,1.0});
Test_interacting(box);
Box<3,float> box2({-0.5,-0.5,-0.5},{0.5,0.5,0.5});
Test_interacting(box2);
}
BOOST_AUTO_TEST_CASE( vector_dist_grid_iterator )
{
long int k = 64*64*64*create_vcluster().getProcessingUnits();
......
......@@ -46,6 +46,6 @@ int main(int argc, char* argv[])
//#include "DLB/DLB_unit_test.hpp"
#include "Graph/dist_map_graph_unit_test.hpp"
#include "Graph/DistGraphFactory.hpp"
//#include "Decomposition/nn_processor_unit_test.hpp"
#include "Decomposition/nn_processor_unit_test.hpp"
#include "Grid/staggered_grid_dist_unit_test.hpp"
//#include "antoniol_test_isolation.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