Commit 91660439 authored by incardon's avatar incardon
Browse files

Merge branch 'master' of git.mpi-cbg.de:openfpm/openfpm_io

parents 821c4194 43c5a58c
......@@ -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));
}
......
......@@ -150,13 +150,13 @@ struct prop_out_v
{
if (it.get() < vv.get(k).mark)
{
int one = 1;
float one = 1;
one = swap_endian_lt(one);
v_out.append((const char *)&one,sizeof(int));
}
else
{
int zero = 0;
float zero = 0;
zero = swap_endian_lt(zero);
v_out.append((const char *)&zero,sizeof(int));
}
......
......@@ -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
......@@ -554,7 +569,10 @@ template<typename grid_type> void fill_grid_some_data(grid_type & g)
while (it.isNext())
{
g.template get<p::x>(it.get()) = it.get().get(0);
g.template get<p::y>(it.get()) = it.get().get(1);
if (grid_type::dims != 1)
{g.template get<p::y>(it.get()) = it.get().get(1);}
else
{g.template get<p::y>(it.get()) = 0.0;}
g.template get<p::z>(it.get()) = 0;
g.template get<p::s>(it.get()) = 1.0;
g.template get<p::v>(it.get())[0] = g.getGrid().LinId(it.get());
......@@ -636,60 +654,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
}
{
......
# vtk DataFile Version 3.0
grids
ASCII
DATASET POLYDATA
POINTS 64 float
0.000000 0.0 0.0
0.100000 0.0 0.0
0.200000 0.0 0.0
0.300000 0.0 0.0
0.400000 0.0 0.0
0.500000 0.0 0.0
0.600000 0.0 0.0
0.700000 0.0 0.0
0.800000 0.0 0.0
0.900000 0.0 0.0
1.000000 0.0 0.0
1.100000 0.0 0.0
1.200000 0.0 0.0
1.300000 0.0 0.0
1.400000 0.0 0.0
1.500000 0.0 0.0
5.000000 0.0 0.0
5.200000 0.0 0.0
5.400000 0.0 0.0
5.600000 0.0 0.0
5.800000 0.0 0.0
6.000000 0.0 0.0
6.200000 0.0 0.0
6.400000 0.0 0.0
6.600000 0.0 0.0
6.800000 0.0 0.0
7.000000 0.0 0.0
7.200000 0.0 0.0
7.400000 0.0 0.0
7.600000 0.0 0.0
7.800000 0.0 0.0
8.000000 0.0 0.0
0.000000 0.0 0.0
0.050000 0.0 0.0
0.100000 0.0 0.0
0.150000 0.0 0.0
0.200000 0.0 0.0
0.250000 0.0 0.0
0.300000 0.0 0.0
0.350000 0.0 0.0
0.400000 0.0 0.0
0.450000 0.0 0.0
0.500000 0.0 0.0
0.550000 0.0 0.0
0.600000 0.0 0.0
0.650000 0.0 0.0
0.700000 0.0 0.0
0.750000 0.0 0.0
5.000000 0.0 0.0
5.100000 0.0 0.0
5.200000 0.0 0.0
5.300000 0.0 0.0
5.400000 0.0 0.0
5.500000 0.0 0.0
5.600000 0.0 0.0
5.700000 0.0 0.0
5.800000 0.0 0.0
5.900000 0.0 0.0
6.000000 0.0 0.0
6.100000 0.0 0.0
6.200000 0.0 0.0
6.300000 0.0 0.0
6.400000 0.0 0.0
6.500000 0.0 0.0
VERTICES 64 128
1 0
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
1 60
1 61
1 62
1 63
POINT_DATA 64
SCALARS attr0 float
LOOKUP_TABLE default
0.000000
1.000000
2.000000
3.000000
4.000000
5.000000
6.000000
7.000000
8.000000
9.000000
10.000000
11.000000
12.000000
13.000000
14.000000
15.000000
0.000000
1.000000
2.000000
3.000000
4.000000
5.000000
6.000000
7.000000
8.000000
9.000000
10.000000
11.000000
12.000000
13.000000
14.000000
15.000000
0.000000
1.000000
2.000000
3.000000
4.000000
5.000000
6.000000
7.000000
8.000000
9.000000
10.000000
11.000000
12.000000
13.000000
14.000000
15.000000
0.000000
1.000000
2.000000
3.000000
4.000000
5.000000
6.000000
7.000000
8.000000
9.000000
10.000000
11.000000
12.000000
13.000000
14.000000
15.000000
SCALARS attr1 float
LOOKUP_TABLE default
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
SCALARS attr2 float
LOOKUP_TABLE default
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
SCALARS attr3 float
LOOKUP_TABLE default
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000