Commit 89411e76 authored by incardon's avatar incardon

Fixing several IO bug

parent fac23ddd
......@@ -68,6 +68,11 @@ struct ne_cp
static const std::string name[max_prop];
};
static inline bool noPointers()
{
return true;
}
//! type of the spatial information
typedef float s_type;
};
......
......@@ -435,10 +435,11 @@ template<unsigned int dims,typename T> inline void output_point(Point<dims,T> &
{
if (ft == file_type::ASCII)
{
if (dims == 2)
v_out << p.toString() << " 0.0" << "\n";
else
v_out << p.toString() << "\n";
v_out << p.toString();
size_t i = dims;
for ( ; i < 3 ; i++)
{v_out << " 0.0";}
v_out << "\n";
}
else
{
......@@ -455,7 +456,7 @@ template<unsigned int dims,typename T> inline void output_point(Point<dims,T> &
// we use float so we have to convert to float
/* coverity[dead_error_begin] */
auto tmp = 0.0;
T tmp = 0.0;
tmp = swap_endian_lt(tmp);
v_out.write((const char *)&tmp,sizeof(tmp));
}
......
......@@ -64,6 +64,11 @@ struct vertex
}
static inline bool noPointers()
{
return true;
}
/*! \brief Initialize the VTKVertex
*
* \param x coordinate x
......@@ -115,6 +120,11 @@ struct vertex2
}
static inline bool noPointers()
{
return true;
}
/*! \brief Initialize the VTKVertex
*
* \param x coordinate x
......@@ -337,6 +347,11 @@ struct vertex3
}
static inline bool noPointers()
{
return true;
}
/*! \brief Initialize the VTKVertex
*
* \param
......@@ -636,60 +651,116 @@ BOOST_AUTO_TEST_CASE( vtk_writer_use_grids)
Vcluster & v_cl = create_vcluster();
if (v_cl.getProcessUnitID() != 0)
return;
{return;}
{
// Create box grids
Point<2,float> offset1({0.0,0.0});
Point<2,float> spacing1({0.1,0.2});
Box<2,size_t> d1({1,2},{14,15});
// Create box grids
Point<2,float> offset2({5.0,7.0});
Point<2,float> spacing2({0.2,0.1});
Box<2,size_t> d2({2,1},{13,15});
// Create box grids
Point<1,float> offset1({0.0});
Point<1,float> spacing1({0.1});
Box<1,size_t> d1({1},{14});
// Create box grids
Point<1,float> offset2({5.0,7.0});
Point<1,float> spacing2({0.2,0.1});
Box<1,size_t> d2({2},{13});
// Create box grids
Point<1,float> offset3({0.0});
Point<1,float> spacing3({0.05});
Box<1,size_t> d3({3},{11});
// Create box grids
Point<1,float> offset4({5.0});
Point<1,float> spacing4({0.1});
Box<1,size_t> d4({1},{7});
size_t sz[] = {16};
grid_cpu<1,Point_test<float>> g1(sz);
g1.setMemory();
fill_grid_some_data(g1);
grid_cpu<1,Point_test<float>> g2(sz);
g2.setMemory();
fill_grid_some_data(g2);
grid_cpu<1,Point_test<float>> g3(sz);
g3.setMemory();
fill_grid_some_data(g3);
grid_cpu<1,Point_test<float>> g4(sz);
g4.setMemory();
fill_grid_some_data(g4);
// Create box grids
Point<2,float> offset3({0.0,7.0});
Point<2,float> spacing3({0.05,0.07});
Box<2,size_t> d3({3,2},{11,10});
// Create a writer and write
VTKWriter<boost::mpl::pair<grid_cpu<1,Point_test<float>>,float>,VECTOR_GRIDS> vtk_g;
vtk_g.add(g1,offset1,spacing1,d1);
vtk_g.add(g2,offset2,spacing2,d2);
vtk_g.add(g3,offset3,spacing3,d3);
vtk_g.add(g4,offset4,spacing4,d4);
// Create box grids
Point<2,float> offset4({5.0,0.0});
Point<2,float> spacing4({0.1,0.1});
Box<2,size_t> d4({1,1},{7,7});
openfpm::vector<std::string> prp_names;
vtk_g.write("vtk_grids_1d.vtk",prp_names);
size_t sz[] = {16,16};
grid_cpu<2,Point_test<float>> g1(sz);
g1.setMemory();
fill_grid_some_data(g1);
grid_cpu<2,Point_test<float>> g2(sz);
g2.setMemory();
fill_grid_some_data(g2);
grid_cpu<2,Point_test<float>> g3(sz);
g3.setMemory();
fill_grid_some_data(g3);
grid_cpu<2,Point_test<float>> g4(sz);
g4.setMemory();
fill_grid_some_data(g4);
#ifndef SE_CLASS3
// Create a writer and write
VTKWriter<boost::mpl::pair<grid_cpu<2,Point_test<float>>,float>,VECTOR_GRIDS> vtk_g;
vtk_g.add(g1,offset1,spacing1,d1);
vtk_g.add(g2,offset2,spacing2,d2);
vtk_g.add(g3,offset3,spacing3,d3);
vtk_g.add(g4,offset4,spacing4,d4);
// Check that match
bool test = compare("vtk_grids_1d.vtk","test_data/vtk_grids_test_1d.vtk");
BOOST_REQUIRE_EQUAL(test,true);
openfpm::vector<std::string> prp_names;
vtk_g.write("vtk_grids.vtk",prp_names);
#endif
}
#ifndef SE_CLASS3
{
// Check that match
bool test = compare("vtk_grids.vtk","test_data/vtk_grids_test.vtk");
BOOST_REQUIRE_EQUAL(test,true);
// Create box grids
Point<2,float> offset1({0.0,0.0});
Point<2,float> spacing1({0.1,0.2});
Box<2,size_t> d1({1,2},{14,15});
// Create box grids
Point<2,float> offset2({5.0,7.0});
Point<2,float> spacing2({0.2,0.1});
Box<2,size_t> d2({2,1},{13,15});
// Create box grids
Point<2,float> offset3({0.0,7.0});
Point<2,float> spacing3({0.05,0.07});
Box<2,size_t> d3({3,2},{11,10});
// Create box grids
Point<2,float> offset4({5.0,0.0});
Point<2,float> spacing4({0.1,0.1});
Box<2,size_t> d4({1,1},{7,7});
size_t sz[] = {16,16};
grid_cpu<2,Point_test<float>> g1(sz);
g1.setMemory();
fill_grid_some_data(g1);
grid_cpu<2,Point_test<float>> g2(sz);
g2.setMemory();
fill_grid_some_data(g2);
grid_cpu<2,Point_test<float>> g3(sz);
g3.setMemory();
fill_grid_some_data(g3);
grid_cpu<2,Point_test<float>> g4(sz);
g4.setMemory();
fill_grid_some_data(g4);
#endif
// Create a writer and write
VTKWriter<boost::mpl::pair<grid_cpu<2,Point_test<float>>,float>,VECTOR_GRIDS> vtk_g;
vtk_g.add(g1,offset1,spacing1,d1);
vtk_g.add(g2,offset2,spacing2,d2);
vtk_g.add(g3,offset3,spacing3,d3);
vtk_g.add(g4,offset4,spacing4,d4);
openfpm::vector<std::string> prp_names;
vtk_g.write("vtk_grids.vtk",prp_names);
#ifndef SE_CLASS3
// Check that match
bool test = compare("vtk_grids.vtk","test_data/vtk_grids_test.vtk");
BOOST_REQUIRE_EQUAL(test,true);
#endif
}
{
......
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