Commit 9c4009de authored by incardon's avatar incardon

Parallel IO

parent fa73ac92
......@@ -34,6 +34,11 @@ CXXFLAGS+=" -march=native -mtune=native -Wno-unused-local-typedefs -Wextra -Wno-
NVCCFLAGS=" "
INCLUDES_PATH=" "
AC_LANG_PUSH([C++])
AC_CHECK_HEADER(mpi.h,[],[echo "mpi.h not found"
exit 200])
AC_LANG_POP([C++])
# set default prefix
if test "$prefix" = "NONE"; then
prefix="/usr/local"
......
x[0],x[1],x[2],x,y,z,s,v_[0],v_[1],v_[2],t_[0][0],t_[0][1],t_[0][2],t_[1][0],t_[1][1],t_[1][2],t_[2][0],t_[2][1],t_[2][2]
1,2,3,1,2,3,4,1,2,7,10,13,8,19,23,5,4,3,11
1,2,3,1,2,3,4,2,3,8,11,14,9,20,24,6,5,4,12
1,2,3,1,2,3,4,3,4,9,12,15,10,21,25,7,6,5,13
1,2,3,1,2,3,4,4,5,10,13,16,11,22,26,8,7,6,14
1,2,3,1,2,3,4,5,6,11,14,17,12,23,27,9,8,7,15
1,2,3,1,2,3,4,6,7,12,15,18,13,24,28,10,9,8,16
1,2,3,1,2,3,4,7,8,13,16,19,14,25,29,11,10,9,17
1,2,3,1,2,3,4,8,9,14,17,20,15,26,30,12,11,10,18
1,2,3,0,0,0,0,9,10,15,18,21,16,27,31,13,12,11,19
1,2,3,0,0,0,0,10,11,16,19,22,17,28,32,14,13,12,20
1,2,3,0,0,0,0,11,12,17,20,23,18,29,33,15,14,13,21
1,2,3,0,0,0,0,12,13,18,21,24,19,30,34,16,15,14,22
1,2,3,0,0,0,0,13,14,19,22,25,20,31,35,17,16,15,23
1,2,3,0,0,0,0,14,15,20,23,26,21,32,36,18,17,16,24
1,2,3,0,0,0,0,15,16,21,24,27,22,33,37,19,18,17,25
1,2,3,0,0,0,0,16,17,22,25,28,23,34,38,20,19,18,26
x[0],x[1],x[2],column_0,column_1,column_2,column_3,column_4_[0],column_4_[1],column_4_[2],column_5_[0][0],column_5_[0][1],column_5_[0][2],column_5_[1][0],column_5_[1][1],column_5_[1][2],column_5_[2][0],column_5_[2][1],column_5_[2][2],column_6
1,2,3,100,102,107,109,1,2,7,10,13,8,19,23,5,4,3,11,0
1,2,3,101,103,108,110,2,3,8,11,14,9,20,24,6,5,4,12,0
1,2,3,102,104,109,111,3,4,9,12,15,10,21,25,7,6,5,13,0
1,2,3,103,105,110,112,4,5,10,13,16,11,22,26,8,7,6,14,0
1,2,3,104,106,111,113,5,6,11,14,17,12,23,27,9,8,7,15,0
1,2,3,105,107,112,114,6,7,12,15,18,13,24,28,10,9,8,16,0
1,2,3,106,108,113,115,7,8,13,16,19,14,25,29,11,10,9,17,0
1,2,3,107,109,114,116,8,9,14,17,20,15,26,30,12,11,10,18,0
1,2,3,108,110,115,117,9,10,15,18,21,16,27,31,13,12,11,19,0
1,2,3,109,111,116,118,10,11,16,19,22,17,28,32,14,13,12,20,0
1,2,3,110,112,117,119,11,12,17,20,23,18,29,33,15,14,13,21,0
1,2,3,111,113,118,120,12,13,18,21,24,19,30,34,16,15,14,22,0
1,2,3,112,114,119,121,13,14,19,22,25,20,31,35,17,16,15,23,0
1,2,3,113,115,120,122,14,15,20,23,26,21,32,36,18,17,16,24,0
1,2,3,114,116,121,123,15,16,21,24,27,22,33,37,19,18,17,25,0
1,2,3,115,117,122,124,16,17,22,25,28,23,34,38,20,19,18,26,0
File mode changed from 100755 to 100644
......@@ -9,6 +9,11 @@ BOOST_AUTO_TEST_SUITE( csv_writer_test )
BOOST_AUTO_TEST_CASE( csv_writer_particles )
{
Vcluster & v_cl = create_vcluster();
if (v_cl.getProcessUnitID() != 0)
return;
{
// Allocate a property vector
auto v_prp = allocate_openfpm_prp(16);
......@@ -29,7 +34,7 @@ BOOST_AUTO_TEST_CASE( csv_writer_particles )
// Write the CSV
csv_writer.write("csv_out.csv",v_pos,v_prp);
bool test = compare("csv_out.csv","csv_out_test.csv");
bool test = compare("csv_out.csv","test_data/csv_out_test.csv");
BOOST_REQUIRE_EQUAL(true,test);
}
......@@ -53,7 +58,7 @@ BOOST_AUTO_TEST_CASE( csv_writer_particles )
// Write the CSV
csv_writer.write("csv_out_unk.csv",v_pos,v_prp);
bool test = compare("csv_out_unk.csv","csv_out_unk_test.csv");
bool test = compare("csv_out_unk.csv","test_data/csv_out_unk_test.csv");
BOOST_REQUIRE_EQUAL(true,test);
}
......
......@@ -77,6 +77,11 @@ const std::string ne_cp::attributes::name[] = {"x","y","z","double_num","long_nu
BOOST_AUTO_TEST_CASE( graphml_writer_use)
{
Vcluster & v_cl = create_vcluster();
if (v_cl.getProcessUnitID() != 0)
return;
Graph_CSR<ne_cp,ne_cp> g_csr2;
// Add 4 vertex and connect
......@@ -114,7 +119,7 @@ BOOST_AUTO_TEST_CASE( graphml_writer_use)
// check that match
bool test = compare("test_graph2.graphml","test_graph2_test.graphml");
bool test = compare("test_graph2.graphml","test_data/test_graph2_test.graphml");
BOOST_REQUIRE_EQUAL(true,test);
//! Create a graph
......@@ -138,7 +143,7 @@ BOOST_AUTO_TEST_CASE( graphml_writer_use)
// check that match
test = compare("test_graph.graphml","test_graph_test.graphml");
test = compare("test_graph.graphml","test_data/test_graph_test.graphml");
BOOST_REQUIRE_EQUAL(true,test);
}
......
......@@ -2,14 +2,14 @@
LINKLIBS = $(PTHREAD_LIBS) $(OPT_LIBS) $(BOOST_IOSTREAMS_LIB) $(BOOST_LDFLAGS) $(BOOST_PROGRAM_OPTIONS_LIB) $(BOOST_THREAD_LIB) $(HDF5_LDFLAGS) $(HDF5_LIBS)
noinst_PROGRAMS = io
io_SOURCES = main.cpp ../../openfpm_vcluster/src/VCluster/VCluster.cpp ../../openfpm_devices/src/memory/HeapMemory.cpp ../../openfpm_devices/src/Memleak_check.cpp
io_SOURCES = main.cpp ../../openfpm_vcluster/src/VCluster/VCluster.cpp ../../openfpm_devices/src/memory/HeapMemory.cpp ../../openfpm_devices/src/Memleak_check.cpp ../../openfpm_devices/src/memory/PtrMemory.cpp
io_CXXFLAGS = $(AM_CXXFLAGS) $(CUDA_CFLAGS) $(INCLUDES_PATH) $(BOOST_CPPFLAGS) -I/usr/local/include $(HDF5_CPPFLAGS)
io_CFLAGS = $(CUDA_CFLAGS)
io_LDADD = $(LINKLIBS)
io_LDADD = $(LINKLIBS)
nobase_include_HEADERS = CSVWriter/csv_multiarray.hpp CSVWriter/CSVWriter.hpp CSVWriter/is_csv_writable.hpp \
nobase_include_HEADERS = RawReader/RawReader.hpp RawReader/RawReader_unit_tests.hpp CSVWriter/csv_multiarray.hpp CSVWriter/CSVWriter.hpp CSVWriter/is_csv_writable.hpp \
GraphMLWriter/GraphMLWriter.hpp util.hpp \
VTKWriter/VTKWriter.hpp VTKWriter/byteswap_portable.hpp VTKWriter/VTKWriter_dist_graph.hpp VTKWriter/VTKWriter_graph.hpp VTKWriter/VTKWriter_point_set.hpp VTKWriter/VTKWriter_grids.hpp VTKWriter/VTKWriter_grids_st.hpp VTKWriter/VTKWriter_grids_util.hpp VTKWriter/VTKWriter_vector_box.hpp VTKWriter/is_vtk_writable.hpp HDF5_XdmfWriter/HDF5_XdmfWriter.hpp HDF5_XdmfWriter/HDF5_XdmfWriter_point_set.hpp HDF5_XdmfWriter/HDF5_XdmfWriter_util.hpp \
VTKWriter/VTKWriter.hpp VTKWriter/byteswap_portable.hpp VTKWriter/VTKWriter_dist_graph.hpp VTKWriter/VTKWriter_graph.hpp VTKWriter/VTKWriter_point_set.hpp VTKWriter/VTKWriter_grids.hpp VTKWriter/VTKWriter_grids_st.hpp VTKWriter/VTKWriter_grids_util.hpp VTKWriter/VTKWriter_vector_box.hpp VTKWriter/is_vtk_writable.hpp HDF5_wr/HDF5_writer.hpp HDF5_wr/HDF5_writer_vd.hpp HDF5_wr/HDF5_reader.hpp HDF5_wr/HDF5_reader_vd.hpp \
Plot/GoogleChart.hpp Plot/util.hpp
......
......@@ -71,7 +71,11 @@ struct GCoptions
//! barWD
bool barWD = false;
//! copy operator
/*! \brief copy operator
*
* \param opt object to copy
*
*/
GCoptions & operator=(const GCoptions & opt)
{
title = opt.title;
......
......@@ -16,6 +16,11 @@ BOOST_AUTO_TEST_SUITE( plot_unit_test )
BOOST_AUTO_TEST_CASE( google_chart_bar_string )
{
Vcluster & v_cl = create_vcluster();
if (v_cl.getProcessUnitID() != 0)
return;
//! [Producing an Histogram graph]
openfpm::vector<std::string> x;
......@@ -69,6 +74,11 @@ BOOST_AUTO_TEST_CASE( google_chart_bar_string )
BOOST_AUTO_TEST_CASE( google_chart )
{
Vcluster & v_cl = create_vcluster();
if (v_cl.getProcessUnitID() != 0)
return;
//! [Producing an Histogram graph]
openfpm::vector<std::string> x;
......@@ -120,6 +130,11 @@ BOOST_AUTO_TEST_CASE( google_chart )
BOOST_AUTO_TEST_CASE( google_chart2 )
{
Vcluster & v_cl = create_vcluster();
if (v_cl.getProcessUnitID() != 0)
return;
openfpm::vector<std::string> x;
openfpm::vector<openfpm::vector<float>> y;
openfpm::vector<std::string> yn;
......@@ -164,6 +179,11 @@ BOOST_AUTO_TEST_CASE( google_chart2 )
BOOST_AUTO_TEST_CASE( google_chart3 )
{
Vcluster & v_cl = create_vcluster();
if (v_cl.getProcessUnitID() != 0)
return;
openfpm::vector<std::string> x;
openfpm::vector<openfpm::vector<float>> y;
openfpm::vector<std::string> yn;
......@@ -207,6 +227,11 @@ BOOST_AUTO_TEST_CASE( google_chart3 )
BOOST_AUTO_TEST_CASE( google_chart4 )
{
Vcluster & v_cl = create_vcluster();
if (v_cl.getProcessUnitID() != 0)
return;
openfpm::vector<std::string> x;
openfpm::vector<openfpm::vector<float>> y;
openfpm::vector<std::string> yn;
......@@ -243,6 +268,11 @@ BOOST_AUTO_TEST_CASE( google_chart4 )
BOOST_AUTO_TEST_CASE( google_chart5 )
{
Vcluster & v_cl = create_vcluster();
if (v_cl.getProcessUnitID() != 0)
return;
openfpm::vector<std::string> x;
openfpm::vector<openfpm::vector<float>> y;
......@@ -271,6 +301,11 @@ BOOST_AUTO_TEST_CASE( google_chart5 )
BOOST_AUTO_TEST_CASE( google_chart6 )
{
Vcluster & v_cl = create_vcluster();
if (v_cl.getProcessUnitID() != 0)
return;
openfpm::vector<openfpm::vector<float>> y;
// Each colums can have multiple data-set
......@@ -291,6 +326,11 @@ BOOST_AUTO_TEST_CASE( google_chart6 )
BOOST_AUTO_TEST_CASE( google_chart_with_inject_HTML )
{
Vcluster & v_cl = create_vcluster();
if (v_cl.getProcessUnitID() != 0)
return;
//! [Producing a set of histograms graphs]
openfpm::vector<std::string> x;
......@@ -349,6 +389,11 @@ BOOST_AUTO_TEST_CASE( google_chart_with_inject_HTML )
BOOST_AUTO_TEST_CASE( google_chart_linear_plot )
{
Vcluster & v_cl = create_vcluster();
if (v_cl.getProcessUnitID() != 0)
return;
//! [Producing lines graph with style]
openfpm::vector<std::string> x;
......@@ -411,6 +456,11 @@ BOOST_AUTO_TEST_CASE( google_chart_linear_plot )
BOOST_AUTO_TEST_CASE( google_chart_linear_plot2 )
{
Vcluster & v_cl = create_vcluster();
if (v_cl.getProcessUnitID() != 0)
return;
//! [Producing lines]
openfpm::vector<std::string> x;
......@@ -464,6 +514,11 @@ double f(double x)
BOOST_AUTO_TEST_CASE( plot_util )
{
Vcluster & v_cl = create_vcluster();
if (v_cl.getProcessUnitID() != 0)
return;
//! [fill a vector]
openfpm::vector<double> x;
......
/*! \brief This class read a Grid raw data format
*
* A grid row data format is very simple. The first n numbers indicate the
* size in every dimension of the grid. The other is the data contained by the grid.
* In particular if we are in 3D and we are saving a 45x50x30 grid after the 3 numbers
* I am expecting 45x50x30 = 67500 objects of type T. There is no check the dimensionality
* is correct, neither the type is correct
*
* \tparam dim dimensionality of the grid
* \tparam T type of the grid
*
*/
#include <iostream>
#include <Grid/map_grid.hpp>
#include <fstream>
#define FORTRAN_STYLE 1
#define STRUCT_OF_ARRAY 2
/*! \brief This is the scalar case
*
* \tparam T scalar type
*
*/
template<unsigned int dim, typename Tg, typename Tr, unsigned int i>
struct meta_raw_read
{
static inline void read(grid_cpu<dim,Tg> & gr,std::ifstream & raw)
{
auto it = gr.getIterator();
while (it.isNext())
{
auto key = it.get();
raw.read((char *)&gr.template get<i>(key),sizeof(Tr));
++it;
}
}
};
/*! \brief This is the vector case
*
* \tparam T vector type
*
*/
template<unsigned int dim, typename Tg, typename Tr ,unsigned int i, unsigned int nv>
struct meta_raw_read<dim,Tg,Tr[nv],i>
{
static inline void read(grid_cpu<dim,Tg> & gr,std::ifstream & raw)
{
for (size_t k = 0 ; k < nv ; k++)
{
auto it = gr.getIterator();
while (it.isNext())
{
auto key = it.get();
raw.read((char *)&gr.template get<i>(key)[k],sizeof(Tr));
++it;
}
}
}
};
/*! \brief this class is a functor for "for_each" algorithm
*
* This class is a functor for "for_each" algorithm. For each
* element of the boost::vector the operator() is called.
* Is mainly used to read each property
*
* \tparam ele_g element that store the grid and its attributes
* \param St type of space where the grid live
*
*/
template<unsigned int dim, typename Tg>
struct raw_read
{
//! Grid out
grid_cpu<dim,Tg> & gr;
//! File stream
std::ifstream & fl;
/*! \brief constructor
*
* \param gr grid to fill
* \param fl file from where to read
*
*/
raw_read(grid_cpu<dim,Tg> & gr,std::ifstream & fl)
:gr(gr),fl(fl)
{};
//! It read for each property
template<typename T>
void operator()(T& t) const
{
typedef typename boost::mpl::at<typename Tg::type,boost::mpl::int_<T::value>>::type Tr;
meta_raw_read<dim,Tg,Tr,T::value>::read(gr,fl);
}
};
template <unsigned int dim, typename T, typename idx_type>
class GridRawReader
{
public:
//! Constructor
GridRawReader() {};
/*! \brief Read a raw grid
*
* \param file raw file to read
* \param gr grid to fill
* \param opt option (FORTRAN_STYLE)
* \param skip skip N byte
*
*/
bool read(std::string file, grid_cpu<dim,T> & gr, size_t opt = 0, size_t skip = 0)
{
idx_type tmp;
std::ifstream raw;
raw.open (file, std::ios::binary );
if (raw.is_open() == false)
{
std::cerr << __FILE__ << ":" << __LINE__ << " error in opening the file: " << file << std::endl;
return false;
}
// get length of file:
raw.seekg (0, std::ios::end);
size_t length = raw.tellg();
raw.seekg (skip, std::ios::beg);
if (opt & FORTRAN_STYLE)
raw.read((char *)&tmp,sizeof(idx_type));
size_t sz[dim];
for (size_t i = 0 ; i < dim ; i++)
{
sz[i] = 0;
raw.read((char *)&sz[i],sizeof(idx_type));
}
if (opt & FORTRAN_STYLE)
raw.read((char *)&tmp,sizeof(idx_type));
if (opt & FORTRAN_STYLE)
raw.read((char *)&tmp,sizeof(idx_type));
grid_sm<dim,void> gs(sz);
size_t offset = 0;
if (opt & FORTRAN_STYLE)
offset += 2*sizeof(idx_type)*2;
// Check the the file size make sense
if (length - dim*sizeof(idx_type) - offset - skip != gs.size()*sizeof(T) )
{
std::cout << __FILE__ << ":" << __LINE__ << " Error the size of the raw file does not match with the calculated one" << std::endl;
return false;
}
gr.setMemory();
// resize the grid
gr.resize(sz);
if (!(opt & STRUCT_OF_ARRAY))
{
// read the data
raw.read((char *)gr.getPointer(),gr.size()*sizeof(T));
raw.close();
}
else
{
// for each property
raw_read<dim,T> rr(gr,raw);
boost::mpl::for_each< boost::mpl::range_c<int,0, T::max_prop> >(rr);
}
return true;
}
};
/*
* RawReader_unit_tests.hpp
*
* Created on: April 16, 2016
* Author: i-bird
*/
#ifndef OPENFPM_IO_RAW_READER_UNIT_TESTS_HPP_
#define OPENFPM_IO_RAW_READER_UNIT_TESTS_HPP_
#include "RawReader.hpp"
BOOST_AUTO_TEST_SUITE( raw_reader_unit_test )
BOOST_AUTO_TEST_CASE( raw_reader_read_test )
{
Vcluster & v_cl = create_vcluster();
if (v_cl.getProcessUnitID() != 0)
return;
grid_cpu<3,aggregate<float,float[3]>> read_bin_test;
GridRawReader<3,aggregate<float,float[3]>,int> rr;
rr.read("test_data/raw_read_sv_test.bin",read_bin_test,FORTRAN_STYLE | STRUCT_OF_ARRAY,12);
auto it = read_bin_test.getIterator();
while (it.isNext())
{
auto key = it.get();
BOOST_REQUIRE_EQUAL(read_bin_test.template get<0>(key),1.5f);
BOOST_REQUIRE_EQUAL(read_bin_test.template get<1>(key)[0],1.5f);
BOOST_REQUIRE_EQUAL(read_bin_test.template get<1>(key)[1],2.5f);
BOOST_REQUIRE_EQUAL(read_bin_test.template get<1>(key)[2],3.5f);
++it;
}
}
BOOST_AUTO_TEST_SUITE_END()
#endif /* OPENFPM_DATA_SRC_PLOT_PLOT_UNIT_TESTS_HPP_ */
......@@ -63,14 +63,17 @@ struct prop_out_g
//! grid that we are processing
const openfpm::vector_std< ele_g > & vg;
//! File type
file_type ft;
/*! \brief constructor
*
* \param v_out string to fill with the vertex properties
* \param vg vector of elements to write
*
*/
prop_out_g(std::string & v_out, const openfpm::vector_std< ele_g > & vg)
:v_out(v_out),vg(vg)
prop_out_g(std::string & v_out, const openfpm::vector_std< ele_g > & vg, file_type ft)
:v_out(v_out),vg(vg),ft(ft)
{};
//! It produce an output for each property
......@@ -80,7 +83,7 @@ struct prop_out_g
typedef typename boost::mpl::at<typename ele_g::value_type::value_type::type,boost::mpl::int_<T::value>>::type ptype;
typedef typename std::remove_all_extents<ptype>::type base_ptype;
meta_prop<boost::mpl::int_<T::value> ,ele_g,St, ptype, is_vtk_writable<base_ptype>::value > m(vg,v_out,file_type::ASCII);
meta_prop<boost::mpl::int_<T::value> ,ele_g,St, ptype, is_vtk_writable<base_ptype>::value > m(vg,v_out,ft);
}
void lastProp()
......@@ -185,9 +188,11 @@ class VTKWriter<pair,VECTOR_GRIDS>
}
/*! \brief Create the VTK point definition
*
* \param ft file type
*
*/
std::string get_point_list()
std::string get_point_list(file_type ft)
{
//! vertex node output string
std::stringstream v_out;
......@@ -209,10 +214,7 @@ class VTKWriter<pair,VECTOR_GRIDS>
p = it.get().toPoint();
p = pmul(p,vg.get(i).spacing) + vg.get(i).offset;
if (pair::first::dims == 2)
v_out << p.toString() << " 0.0" << "\n";
else
v_out << p.toString() << "\n";
output_point<pair::first::dims,typename pair::second>(p,v_out,ft);
// increment the iterator and counter
++it;
......@@ -224,9 +226,11 @@ class VTKWriter<pair,VECTOR_GRIDS>
}
/*! \brief Create the VTK vertex definition
*
* \param ft file type
*
*/
std::string get_vertex_list()
std::string get_vertex_list(file_type ft)
{
//! vertex node output string
std::string v_out;
......@@ -240,7 +244,7 @@ class VTKWriter<pair,VECTOR_GRIDS>
while (it.isNext())
{
v_out += "1 " + std::to_string(k) + "\n";
output_vertex(k,v_out,ft);
++k;
++it;
......@@ -280,10 +284,13 @@ public:
* \param g Grid to add
* \param offset grid offset
* \param spacing spacing of the grid
* \param dom part of the spacethat is the domain
* \param dom part of the space that is the domain
*
*/
void add(const typename pair::first & g, const Point<pair::first::dims,typename pair::second> & offset, const Point<pair::first::dims,typename pair::second> & spacing, const Box<pair::first::dims,typename pair::second> & dom)
void add(const typename pair::first & g,
const Point<pair::first::dims,typename pair::second> & offset,
const Point<pair::first::dims,typename pair::second> & spacing,
const Box<pair::first::dims,typename pair::second> & dom)
{
ele_g<typename pair::first,typename pair::second> t(g,offset,spacing,dom);
......@@ -336,20 +343,20 @@ public:
point_prop_header = get_point_properties_list();
// Get point list
point_list = get_point_list();
point_list = get_point_list(ft);
// vertex properties header
vertex_prop_header = get_vertex_properties_list();
// Get vertex list
vertex_list = get_vertex_list();
vertex_list = get_vertex_list(ft);
// Get the point data header
point_data_header = get_point_data_header();
// For each property in the vertex type produce a point data
prop_out_g< ele_g<typename pair::first,typename pair::second>, typename pair::second > pp(point_data, vg);
prop_out_g< ele_g<typename pair::first,typename pair::second>, typename pair::second > pp(point_data, vg, ft);
if (prp == -1)
boost::mpl::for_each< boost::mpl::range_c<int,0, pair::first::value_type::max_prop> >(pp);
......
......@@ -395,4 +395,41 @@ struct meta_prop<I,ele_g,St,T,false>
}
};
template<unsigned int dims,typename T> inline void output_point(Point<dims,T> & p,std::stringstream & v_out, file_type ft)
{
if (ft == file_type::ASCII)
{
if (dims == 2)
v_out << p.toString() << " 0.0" << "\n";
else
v_out << p.toString() << "\n";
}
else
{
for (size_t i = 0 ; i < dims ; i++)
{
// we use float so we have to convert to float
float tmp = p.get(i);
tmp = swap_endian_lt(tmp);
v_out.write((const char *)&tmp,sizeof(tmp));
}
}
}
inline void output_vertex(size_t k,std::string & v_out, file_type ft)
{
if (ft == file_type::ASCII)
v_out += "1 " + std::to_string(k) + "\n";
else
{
int tmp;
tmp = 1;
tmp = swap_endian_lt(tmp);
v_out.append((const char *)&tmp,sizeof(int));
tmp = k;
tmp = swap_endian_lt(tmp);
v_out.append((const char *)&tmp,sizeof(int));
}
}
#endif /* SRC_VTKWRITER_GRIDS_UTIL_HPP_ */
......@@ -258,23 +258,7 @@ class VTKWriter<pair,VECTOR_POINTS>
Point<pair::first::value_type::dims,typename pair::first::value_type::coord_type> p;
p = vps.get(i).g.get(it.get());
if (ft == file_type::ASCII)
{
if (pair::first::value_type::dims == 2)
v_out << p.toString() << " 0.0" << "\n";
else
v_out << p.toString() << "\n";
}
else
{
for (size_t i = 0 ; i < pair::first::value_type::dims ; i++)
{
// we use float so we have to convert to float
float tmp = p.get(i);
tmp = swap_endian_lt(tmp);
v_out.write((const char *)&tmp,sizeof(tmp));
}
}
output_point<pair::first::value_type::dims,typename pair::first::value_type::coord_type>(p,v_out,ft);
// increment the iterator and counter
++it;
......@@ -310,18 +294,7 @@ class VTKWriter<pair,VECTOR_POINTS>
while (it.isNext())
{
if (ft == file_type::ASCII)
v_out += "1 " + std::to_string(k) + "\n";
else
{
int tmp;
tmp = 1;
tmp = swap_endian_lt(tmp);
v_out.append((const char *)&tmp,sizeof(int));
tmp = k;
tmp = swap_endian_lt(tmp);
v_out.append((const char *)&tmp,sizeof(int));
}
output_vertex(k,v_out,ft);
++k;
++it;
......
......@@ -127,6 +127,11 @@ const std::string vertex2::attributes::name[] = {"x","prp1","prp2"};
BOOST_AUTO_TEST_CASE( vtk_writer_use_graph3D )
{
Vcluster & v_cl = create_vcluster();
if (v_cl.getProcessUnitID() != 0)
return;