Commit 18738a8e authored by incardon's avatar incardon

IO working

parents 3eed4d7c 5218dbe9
openfpm_data @ a677ffb0
Subproject commit dde50897665d36fc2723aabb0917291c9573c065
Subproject commit a677ffb0def932b598829ea77f86b2d10588f784
......@@ -119,6 +119,9 @@ protected:
//! the set of all local sub-domain as vector
openfpm::vector<SpaceBox<dim, T>> sub_domains;
//! the global set of all sub-domains as vector of 'sub_domains' vectors
mutable openfpm::vector<openfpm::vector<SpaceBox<dim, T>>> sub_domains_global;
//! for each sub-domain, contain the list of the neighborhood processors
openfpm::vector<openfpm::vector<long unsigned int> > box_nn_processor;
......@@ -1223,6 +1226,16 @@ public:
return domain;
}
openfpm::vector<SpaceBox<dim, T>> getSubDomains() const
{
return sub_domains;
}
openfpm::vector<openfpm::vector<SpaceBox<dim, T>>> & getSubDomainsGlobal()
{
return sub_domains_global;
}
/*! \brief Check if the particle is local
*
* \warning if the particle id outside the domain the result is unreliable
......
......@@ -38,7 +38,7 @@ class ie_ghost
openfpm::vector<p_box<dim,T> > vb_int;
//! Cell-list that store the geometrical information of the internal ghost boxes
CellList<dim,T,FAST,shift<dim,T>> geo_cell;
CellList<dim,T,Mem_fast<dim,T>,shift<dim,T>> geo_cell;
//! shift vectors
openfpm::vector<Point<dim,T>> shifts;
......@@ -750,9 +750,9 @@ public:
* \return An iterator with the id's of the internal boxes in which the point fall
*
*/
auto getInternalIDBoxes(Point<dim,T> & p) -> decltype(geo_cell.getIterator(geo_cell.getCell(p)))
auto getInternalIDBoxes(Point<dim,T> & p) -> decltype(geo_cell.getCellIterator(geo_cell.getCell(p)))
{
return geo_cell.getIterator(geo_cell.getCell(p));
return geo_cell.getCellIterator(geo_cell.getCell(p));
}
/*! \brief if the point fall into the ghost of some near processor it return the processors id's in which
......@@ -762,9 +762,9 @@ public:
* \return iterator of the processors id's
*
*/
inline auto labelPoint(Point<dim,T> & p) -> decltype(geo_cell.getIterator(geo_cell.getCell(p)))
inline auto labelPoint(Point<dim,T> & p) -> decltype(geo_cell.getCellIterator(geo_cell.getCell(p)))
{
return geo_cell.getIterator(geo_cell.getCell(p));
return geo_cell.getCellIterator(geo_cell.getCell(p));
}
/*! \brief Given a position it return if the position belong to any neighborhood processor ghost
......@@ -790,7 +790,7 @@ public:
// Check with geo-cell if a particle is inside one Cell containing boxes
auto cell_it = geo_cell.getIterator(geo_cell.getCell(p));
auto cell_it = geo_cell.getCellIterator(geo_cell.getCell(p));
// For each element in the cell, check if the point is inside the box
// if it is, store the processor id
......@@ -839,7 +839,7 @@ public:
// Check with geo-cell if a particle is inside one Cell containing boxes
auto cell_it = geo_cell.getIterator(geo_cell.getCell(p));
auto cell_it = geo_cell.getCellIterator(geo_cell.getCell(p));
// For each element in the cell, check if the point is inside the box
// if it is, store the processor id
......@@ -883,7 +883,7 @@ public:
// Check with geo-cell if a particle is inside one Cell containing boxes
auto cell_it = geo_cell.getIterator(geo_cell.getCell(p));
auto cell_it = geo_cell.getCellIterator(geo_cell.getCell(p));
// For each element in the cell, check if the point is inside the box
// if it is, store the processor id
......@@ -926,7 +926,7 @@ public:
// Check with geo-cell if a particle is inside one Cell containing boxes
auto cell_it = geo_cell.getIterator(geo_cell.getCell(p));
auto cell_it = geo_cell.getCellIterator(geo_cell.getCell(p));
// For each element in the cell, check if the point is inside the box
// if it is, store the processor id
......
This diff is collapsed.
/*
* grid_dist_id_HDF5_chckpnt_restart_test.hpp
*
* Created on: Nov 9, 2016
* Author: Yaroslav Zaluzhnyi
*/
#ifndef SRC_GRID_GRID_DIST_ID_HDF5_CHCKPNT_RESTART_TEST_HPP_
#define SRC_GRID_GRID_DIST_ID_HDF5_CHCKPNT_RESTART_TEST_HPP_
#include "Grid/grid_dist_id.hpp"
BOOST_AUTO_TEST_SUITE( gd_hdf5_chckpnt_rstrt_test )
BOOST_AUTO_TEST_CASE( grid_dist_id_hdf5_save_test )
{
// Input data
size_t k = 2400;
float ghost_part = 0.0;
// Domain
Box<2,float> domain({0.0,0.0},{1.0,1.0});
Vcluster & v_cl = create_vcluster();
// Skip this test on big scale
if (v_cl.getProcessingUnits() >= 32)
return;
if (v_cl.getProcessUnitID() == 0)
std::cout << "Saving Distributed 2D Grid..." << std::endl;
// grid size
size_t sz[2];
sz[0] = k;
sz[1] = k;
// Ghost
Ghost<2,float> g(ghost_part);
// Distributed grid with id decomposition
grid_dist_id<2, float, scalar<float>, CartDecomposition<2,float>> g_dist(sz,domain,g);
// get the decomposition
auto & dec = g_dist.getDecomposition();
// check the consistency of the decomposition
bool val = dec.check_consistency();
BOOST_REQUIRE_EQUAL(val,true);
size_t count = 0;
auto it = g_dist.getDomainIterator();
while (it.isNext())
{
//key
auto key = it.get();
auto keyg = g_dist.getGKey(key);
g_dist.template get<0>(key) = keyg.get(0);
++it;
count++;
}
std::cout << "Count: " << count << std::endl;
openfpm::vector<size_t> count_total;
v_cl.allGather(count,count_total);
v_cl.execute();
size_t sum = 0;
for (size_t i = 0; i < count_total.size(); i++)
sum += count_total.get(i);
std::cout << "Sum: " << sum << std::endl;
timer t;
t.start();
// Save the grid
g_dist.save("grid_dist_id.h5");
t.stop();
std::cout << "Saving time: " << t.getwct() << std::endl;
}
BOOST_AUTO_TEST_CASE( grid_dist_id_hdf5_load_test )
{
// Input data
size_t k = 2400;
float ghost_part = 0.0;
// Domain
Box<2,float> domain({0.0,0.0},{1.0,1.0});
Vcluster & v_cl = create_vcluster();
// Skip this test on big scale
if (v_cl.getProcessingUnits() >= 32)
return;
if (v_cl.getProcessUnitID() == 0)
std::cout << "Loading Distributed 2D Grid..." << std::endl;
// grid size
size_t sz[2];
sz[0] = k;
sz[1] = k;
// Ghost
Ghost<2,float> g(ghost_part);
// Distributed grid with id decomposition
grid_dist_id<2, float, scalar<float>, CartDecomposition<2,float>> g_dist(sz,domain,g);
g_dist.getDecomposition().write("Before_load_grid_decomposition");
g_dist.write("Before_Loaded_grid");
timer t;
t.start();
// Save the grid
g_dist.load("grid_dist_id.h5");
t.stop();
g_dist.write("Loaded_grid");
g_dist.getDecomposition().write("Loaded_grid_decomposition");
std::cout << "Loading time: " << t.getwct() << std::endl;
auto it = g_dist.getDomainIterator();
size_t count = 0;
while (it.isNext())
{
//key
auto key = it.get();
//BOOST_CHECK_CLOSE(g_dist.template get<0>(key),1,0.0001);
//std::cout << "Element: " << g_dist.template get<0>(key) << std::endl;
auto keyg = g_dist.getGKey(key);
BOOST_REQUIRE_EQUAL(g_dist.template get<0>(key), keyg.get(0));
++it;
count++;
}
std::cout << "COOOOOOUNT: " << count << std::endl;
openfpm::vector<size_t> count_total;
v_cl.allGather(count,count_total);
v_cl.execute();
size_t sum = 0;
for (size_t i = 0; i < count_total.size(); i++)
sum += count_total.get(i);
BOOST_REQUIRE_EQUAL(sum, (size_t)k*k);
}
BOOST_AUTO_TEST_SUITE_END()
#endif /* SRC_GRID_GRID_DIST_ID_HDF5_CHCKPNT_RESTART_TEST_HPP_ */
This diff is collapsed.
......@@ -15,6 +15,73 @@
#define N_VERLET_TEST 3
#define N_STAT_TEST 30
static inline void warning_set(int & warning_level, double mean, double mean_ref, double sigma)
{
int warning_level_candidate;
if (mean - mean_ref < -2.0*sigma )
warning_level_candidate = -1;
else if (mean - mean_ref < 2.0*sigma)
warning_level_candidate = 0;
else if (mean - mean_ref < 3.0*sigma)
warning_level_candidate = 1;
else
warning_level_candidate = 2;
if (warning_level_candidate > warning_level)
warning_level = warning_level_candidate;
}
static inline void addchartarea(std::string & chart_area, int lvl)
{
std::string color;
if (lvl == -1)
{
chart_area = std::string(",chartArea: {\
backgroundColor: {\
stroke: '#00FF00',\
strokeWidth: 6\
}\
}");
}
else if (lvl == 0)
{
// NOTHING TO DO
}
else if (lvl == 1)
{
chart_area = std::string(",chartArea: {\
backgroundColor: {\
stroke: '#FFFF00',\
strokeWidth: 6\
}\
}");
}
else if (lvl == 2)
{
chart_area = std::string(",chartArea: {\
backgroundColor: {\
stroke: '#FF0000',\
strokeWidth: 6\
}\
}");
}
}
void addUpdtateTime(GoogleChart & cg)
{
time_t t = time(0); // get time now
struct tm * now = localtime( & t );
std::stringstream str;
str << "<h3>Updated: " << now->tm_mday << "/" << now->tm_mon + 1 << "/" << now->tm_year+1900 << " " << now->tm_hour << ":" << now->tm_min << ":" << now->tm_sec << std::endl;
cg.addHTML(str.str());
}
/*! \brief Standard deviation
*
* \param measures set of measures
......
This diff is collapsed.
/*
* vector_dist_HDF5_save.hpp
*
* Created on: Jun 12, 2016
* Author: Yaroslav Zaluzhnyi
*/
#ifndef SRC_VECTOR_VECTOR_DIST_HDF5_CHCKPNT_RESTART_TEST_HPP_
#define SRC_VECTOR_VECTOR_DIST_HDF5_CHCKPNT_RESTART_TEST_HPP_
#include "vector_dist.hpp"
#include "Packer_Unpacker/Pack_selector.hpp"
#include "Packer_Unpacker/Packer.hpp"
#include "Packer_Unpacker/Unpacker.hpp"
#include "Vector/performance/vector_dist_performance_util.hpp"
#include "hdf5.h"
BOOST_AUTO_TEST_SUITE( vd_hdf5_chckpnt_rstrt_test )
// Input data
// Number of particles
size_t k = 1000000;
// Dimensionality
const size_t dim = 3;
BOOST_AUTO_TEST_CASE( vector_dist_hdf5_save_test )
{
Vcluster & v_cl = create_vcluster();
if (v_cl.getProcessUnitID() == 0)
std::cout << "Saving distributed vector" << std::endl;
Box<dim,float> box;
for (size_t i = 0; i < dim; i++)
{
box.setLow(i,0.0);
box.setHigh(i,1.0);
}
// Boundary conditions
size_t bc[dim];
const size_t Ng = cbrt(k);
// we create a Grid iterator
size_t sz[dim] = {Ng,Ng,Ng};
for (size_t i = 0; i < dim; i++)
bc[i] = NON_PERIODIC;
// ghost
Ghost<dim,float> ghost(1.0/(Ng-2));
vector_dist<dim,float, aggregate<float[dim]>, CartDecomposition<dim,float> > vd(0,box,bc,ghost);
// Put particles
auto it = vd.getGridIterator(sz);
while (it.isNext())
{
vd.add();
auto key = it.get();
vd.getLastPos()[0] = key.get(0) * it.getSpacing(0);
vd.getLastPos()[1] = key.get(1) * it.getSpacing(1);
vd.getLastPos()[2] = key.get(2) * it.getSpacing(2);
++it;
}
//BOOST_REQUIRE_EQUAL(it.getSpacing(0),1.0f/(Ng-1));
//BOOST_REQUIRE_EQUAL(it.getSpacing(1),1.0f/(Ng-1));
//BOOST_REQUIRE_EQUAL(it.getSpacing(2),1.0f/(Ng-1));
vd.map();
// Put forces
auto it2 = vd.getDomainIterator();
while (it2.isNext())
{
auto key = it2.get();
//Put the forces
for (size_t i = 0; i < dim; i++)
vd.template getProp<0>(key)[i] = 0.51234 + vd.getPos(key)[0] + vd.getPos(key)[1]+ vd.getPos(key)[2];
++it2;
}
timer t;
t.start();
// Save the vector
vd.save("vector_dist.h5");
t.stop();
std::cout << "Saving time: " << t.getwct() << std::endl;
}
BOOST_AUTO_TEST_CASE( vector_dist_hdf5_load_test )
{
Vcluster & v_cl = create_vcluster();
if (v_cl.getProcessUnitID() == 0)
std::cout << "Loading distributed vector" << std::endl;
Box<dim,float> box;
for (size_t i = 0; i < dim; i++)
{
box.setLow(i,0.0);
box.setHigh(i,1.0);
}
// Boundary conditions
size_t bc[dim];
for (size_t i = 0; i < dim; i++)
bc[i] = NON_PERIODIC;
const size_t Ng = cbrt(k);
// we create a Grid iterator
size_t sz[3] = {Ng,Ng,Ng};
// ghost
Ghost<dim,float> ghost(1.0/(Ng-2));
vector_dist<dim,float, aggregate<float[dim]>, CartDecomposition<dim,float> > vd(0,box,bc,ghost);
vd.load("vector_dist.h5");
timer t;
t.start();
// Save the vector
vd.load("vector_dist.h5");
t.stop();
std::cout << "Loading time: " << t.getwct() << std::endl;
/////////////////// Checking data ///////////////////////
// Check total number of particles
size_t n_part = vd.size_local();
openfpm::vector<size_t> tot_n_part;
v_cl.allGather(n_part,tot_n_part);
v_cl.execute();
size_t sum = 0;
for (size_t i = 0; i < tot_n_part.size(); i++)
sum += tot_n_part.get(i);
BOOST_REQUIRE_EQUAL(sum,k);
//std::cout << "Sum: " << sum << std::endl;
// Check spacing (positions)
auto it = vd.getGridIterator(sz);
while (it.isNext())
{
//auto key = it.get();
++it;
}
BOOST_REQUIRE_EQUAL(it.getSpacing(0),1.0f/(Ng-1));
BOOST_REQUIRE_EQUAL(it.getSpacing(1),1.0f/(Ng-1));
BOOST_REQUIRE_EQUAL(it.getSpacing(2),1.0f/(Ng-1));
// Check properties
auto it2 = vd.getDomainIterator();
while (it2.isNext())
{
auto key = it2.get();
//Put the forces
for (size_t i = 0; i < dim; i++)
BOOST_CHECK_CLOSE(vd.template getProp<0>(key)[i],0.51234 + vd.getPos(key)[0] + vd.getPos(key)[1]+ vd.getPos(key)[2],0.0001);
++it2;
}
}
BOOST_AUTO_TEST_SUITE_END()
#endif /* SRC_VECTOR_VECTOR_DIST_HDF5_CHCKPNT_RESTART_TEST_HPP_ */
......@@ -1064,7 +1064,7 @@ void Test_interacting(Box<3,float> & box)
Point<3,float> xp = vd.getPos(p);
auto Np = NN.getIterator(NN.getCell(xp));
auto Np = NN.getCellIterator(NN.getCell(xp));
while (Np.isNext())
{
......
......@@ -46,6 +46,11 @@ int main(int argc, char* argv[])
#include "Decomposition/Distribution/metis_util_unit_test.hpp"
#include "dec_optimizer_unit_test.hpp"
#include "Vector/vector_dist_unit_test.hpp"
#include "Vector/vector_dist_HDF5_chckpnt_restart_test.hpp"
#include "Grid/grid_dist_id_HDF5_chckpnt_restart_test.hpp"
#ifdef PERFORMANCE_TEST
#include "pdata_performance.hpp"
#endif
#include "Decomposition/Distribution/Distribution_unit_tests.hpp"
#include "Grid/Iterators/grid_dist_id_iterators_unit_tests.hpp"
//#include "DLB/DLB_unit_test.hpp"
......
......@@ -32,73 +32,6 @@ boost::property_tree::ptree pt;
BOOST_AUTO_TEST_SUITE( performance )
static inline void warning_set(int & warning_level, double mean, double mean_ref, double sigma)
{
int warning_level_candidate;
if (mean - mean_ref < -2.0*sigma )
warning_level_candidate = -1;
else if (mean - mean_ref < 2.0*sigma)
warning_level_candidate = 0;
else if (mean - mean_ref < 3.0*sigma)
warning_level_candidate = 1;
else
warning_level_candidate = 2;
if (warning_level_candidate > warning_level)
warning_level = warning_level_candidate;
}
static inline void addchartarea(std::string & chart_area, int lvl)
{
std::string color;
if (lvl == -1)
{
chart_area = std::string(",chartArea: {\
backgroundColor: {\
stroke: '#00FF00',\
strokeWidth: 6\
}\
}");
}
else if (lvl == 0)
{
// NOTHING TO DO
}
else if (lvl == 1)
{
chart_area = std::string(",chartArea: {\
backgroundColor: {\
stroke: '#FFFF00',\
strokeWidth: 6\
}\
}");
}
else if (lvl == 2)
{
chart_area = std::string(",chartArea: {\
backgroundColor: {\
stroke: '#FF0000',\
strokeWidth: 6\
}\
}");
}
}
void addUpdtateTime(GoogleChart & cg)
{
time_t t = time(0); // get time now
struct tm * now = localtime( & t );
std::stringstream str;
str << "<h3>Updated: " << now->tm_mday << "/" << now->tm_mon + 1 << "/" << now->tm_year+1900 << " " << now->tm_hour << ":" << now->tm_min << ":" << now->tm_sec << std::endl;
cg.addHTML(str.str());
}
#include "Vector/performance/vector_dist_performance_util.hpp"
#include "Vector/performance/verlet_performance_tests.hpp"
#include "Vector/performance/cell_list_part_reorder.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