Commit ffcab9ac authored by Pietro Incardona's avatar Pietro Incardona

Fixing test

parent ca2becb0
...@@ -25,8 +25,7 @@ var options0= { ...@@ -25,8 +25,7 @@ var options0= {
title : 'Example', title : 'Example',
vAxis: {title: 'Y Axis'}, vAxis: {title: 'Y Axis'},
hAxis: {title: 'X Axis'}, hAxis: {title: 'X Axis'},
seriesType: 'bars', seriesType: 'bars'};
};
var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));chart.draw(data0, options0); var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));chart.draw(data0, options0);
}</script> }</script>
</head> </head>
......
...@@ -25,8 +25,7 @@ var options0= { ...@@ -25,8 +25,7 @@ var options0= {
title : 'Example', title : 'Example',
vAxis: {title: 'Y Axis'}, vAxis: {title: 'Y Axis'},
hAxis: {title: 'X Axis'}, hAxis: {title: 'X Axis'},
seriesType: '', seriesType: ''};
};
var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));chart.draw(data0, options0); var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));chart.draw(data0, options0);
}</script> }</script>
</head> </head>
......
...@@ -25,8 +25,7 @@ var options0= { ...@@ -25,8 +25,7 @@ var options0= {
title : '', title : '',
vAxis: {title: ''}, vAxis: {title: ''},
hAxis: {title: ''}, hAxis: {title: ''},
seriesType: '', seriesType: ''};
};
var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));chart.draw(data0, options0); var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));chart.draw(data0, options0);
}</script> }</script>
</head> </head>
......
...@@ -25,8 +25,7 @@ var options0= { ...@@ -25,8 +25,7 @@ var options0= {
title : '', title : '',
vAxis: {title: ''}, vAxis: {title: ''},
hAxis: {title: ''}, hAxis: {title: ''},
seriesType: '', seriesType: ''};
};
var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));chart.draw(data0, options0); var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));chart.draw(data0, options0);
}</script> }</script>
</head> </head>
......
...@@ -25,8 +25,7 @@ var options0= { ...@@ -25,8 +25,7 @@ var options0= {
title : '', title : '',
vAxis: {title: ''}, vAxis: {title: ''},
hAxis: {title: ''}, hAxis: {title: ''},
seriesType: '', seriesType: ''};
};
var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));chart.draw(data0, options0); var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));chart.draw(data0, options0);
}</script> }</script>
</head> </head>
......
...@@ -54,22 +54,19 @@ title : 'Example', ...@@ -54,22 +54,19 @@ title : 'Example',
vAxis: {title: 'Y Axis'}, vAxis: {title: 'Y Axis'},
hAxis: {title: 'X Axis'}, hAxis: {title: 'X Axis'},
seriesType: 'bars', seriesType: 'bars',
series: {3: {type: 'line'}} series: {3: {type: 'line'}}};
};
var options1= { var options1= {
title : 'Example', title : 'Example',
vAxis: {title: 'Y Axis'}, vAxis: {title: 'Y Axis'},
hAxis: {title: 'X Axis'}, hAxis: {title: 'X Axis'},
seriesType: 'bars', seriesType: 'bars',
series: {3: {type: 'line'}} series: {3: {type: 'line'}}};
};
var options2= { var options2= {
title : 'Example', title : 'Example',
vAxis: {title: 'Y Axis'}, vAxis: {title: 'Y Axis'},
hAxis: {title: 'X Axis'}, hAxis: {title: 'X Axis'},
seriesType: 'bars', seriesType: 'bars',
series: {3: {type: 'line'}} series: {3: {type: 'line'}}};
};
var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));chart.draw(data0, options0); var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));chart.draw(data0, options0);
var chart = new google.visualization.ComboChart(document.getElementById('chart_div1'));chart.draw(data1, options1); var chart = new google.visualization.ComboChart(document.getElementById('chart_div1'));chart.draw(data1, options1);
var chart = new google.visualization.ComboChart(document.getElementById('chart_div2'));chart.draw(data2, options2); var chart = new google.visualization.ComboChart(document.getElementById('chart_div2'));chart.draw(data2, options2);
......
...@@ -26,8 +26,7 @@ title : 'Example', ...@@ -26,8 +26,7 @@ title : 'Example',
vAxis: {title: 'Y Axis'}, vAxis: {title: 'Y Axis'},
hAxis: {title: 'X Axis'}, hAxis: {title: 'X Axis'},
seriesType: 'bars', seriesType: 'bars',
series: {3: {type: 'line'}} series: {3: {type: 'line'}}};
};
var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));chart.draw(data0, options0); var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));chart.draw(data0, options0);
}</script> }</script>
</head> </head>
......
...@@ -32,8 +32,7 @@ vAxis: {title: 'Y Axis'}, ...@@ -32,8 +32,7 @@ vAxis: {title: 'Y Axis'},
hAxis: {title: 'X Axis'}, hAxis: {title: 'X Axis'},
curveType: 'function', curveType: 'function',
lineWidth: 1, lineWidth: 1,
intervals: { 'style':'area' }, intervals: { 'style':'area' }};
};
var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));chart.draw(data0, options0); var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));chart.draw(data0, options0);
}</script> }</script>
</head> </head>
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <boost/mpl/for_each.hpp> #include <boost/mpl/for_each.hpp>
#include "csv_multiarray.hpp" #include "csv_multiarray.hpp"
#include "util.hpp" #include "util.hpp"
#include "is_csv_writable.hpp"
#define CSV_WRITER 0x30000 #define CSV_WRITER 0x30000
...@@ -60,8 +61,9 @@ struct csv_prp ...@@ -60,8 +61,9 @@ struct csv_prp
// Remove the reference from the column type // Remove the reference from the column type
typedef typename boost::remove_reference<col_type>::type col_rtype; typedef typename boost::remove_reference<col_type>::type col_rtype;
typedef typename std::remove_all_extents<col_rtype>::type base_col_rtype;
csv_value_str<col_rtype>(obj.template get<T::value>(),str); csv_value_str<col_rtype, is_csv_writable<base_col_rtype>::value >(obj.template get<T::value>(),str);
} }
}; };
......
...@@ -9,6 +9,7 @@ BOOST_AUTO_TEST_SUITE( csv_writer_test ) ...@@ -9,6 +9,7 @@ BOOST_AUTO_TEST_SUITE( csv_writer_test )
BOOST_AUTO_TEST_CASE( csv_writer_particles ) BOOST_AUTO_TEST_CASE( csv_writer_particles )
{ {
{
// Allocate a property vector // Allocate a property vector
auto v_prp = allocate_openfpm_prp(16); auto v_prp = allocate_openfpm_prp(16);
// Vector of position // Vector of position
...@@ -30,7 +31,31 @@ BOOST_AUTO_TEST_CASE( csv_writer_particles ) ...@@ -30,7 +31,31 @@ BOOST_AUTO_TEST_CASE( csv_writer_particles )
bool test = compare("csv_out.csv","csv_out_test.csv"); bool test = compare("csv_out.csv","csv_out_test.csv");
BOOST_REQUIRE_EQUAL(true,test); BOOST_REQUIRE_EQUAL(true,test);
}
{
// Allocate a property vector
auto v_prp = allocate_openfpm_aggregate_with_complex(16);
// Vector of position
openfpm::vector<Point<3,float>> v_pos;
// create a positional vector
for (size_t i = 0 ; i < v_prp.size() ; i++)
{
Point<3,float> p({1.0,2.0,3.0});
v_pos.add(p);
}
// CSVWriter test
CSVWriter<openfpm::vector<Point<3,float>>, openfpm::vector< aggregate<float,float,float,float,float[3],float[3][3],openfpm::vector<int>> > > csv_writer;
// 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");
BOOST_REQUIRE_EQUAL(true,test);
}
} }
......
...@@ -124,7 +124,7 @@ struct csv_col_str<T[N1][N2][N3][N4]> ...@@ -124,7 +124,7 @@ struct csv_col_str<T[N1][N2][N3][N4]>
* Will produce ",1.0,2.0,3.0" * Will produce ",1.0,2.0,3.0"
* *
*/ */
template<typename T> template<typename T, bool is_writable>
struct csv_value_str struct csv_value_str
{ {
inline csv_value_str(T & v, std::stringstream & str) inline csv_value_str(T & v, std::stringstream & str)
...@@ -134,8 +134,8 @@ struct csv_value_str ...@@ -134,8 +134,8 @@ struct csv_value_str
}; };
//! Partial specialization for N=1 1D-Array //! Partial specialization for N=1 1D-Array
template<typename T,size_t N1> template<typename T,size_t N1, bool is_writable>
struct csv_value_str<T[N1]> struct csv_value_str<T[N1], is_writable>
{ {
inline csv_value_str(const T v[N1], std::stringstream & str) inline csv_value_str(const T v[N1], std::stringstream & str)
{ {
...@@ -145,8 +145,8 @@ struct csv_value_str<T[N1]> ...@@ -145,8 +145,8 @@ struct csv_value_str<T[N1]>
}; };
//! Partial specialization for N=2 2D-Array //! Partial specialization for N=2 2D-Array
template<typename T,size_t N1,size_t N2> template<typename T,size_t N1,size_t N2, bool is_writable>
struct csv_value_str<T[N1][N2]> struct csv_value_str<T[N1][N2], is_writable>
{ {
inline csv_value_str(const T v[N1][N2], std::stringstream & str) inline csv_value_str(const T v[N1][N2], std::stringstream & str)
{ {
...@@ -161,8 +161,8 @@ struct csv_value_str<T[N1][N2]> ...@@ -161,8 +161,8 @@ struct csv_value_str<T[N1][N2]>
}; };
//! Partial specialization for N=3 //! Partial specialization for N=3
template<typename T,size_t N1,size_t N2,size_t N3> template<typename T,size_t N1,size_t N2,size_t N3, bool is_writable>
struct csv_value_str<T[N1][N2][N3]> struct csv_value_str<T[N1][N2][N3], is_writable>
{ {
inline csv_value_str(const T v[N1][N2][N3], std::stringstream & str) inline csv_value_str(const T v[N1][N2][N3], std::stringstream & str)
{ {
...@@ -180,8 +180,8 @@ struct csv_value_str<T[N1][N2][N3]> ...@@ -180,8 +180,8 @@ struct csv_value_str<T[N1][N2][N3]>
}; };
//! Partial specialization for N=4 //! Partial specialization for N=4
template<typename T,size_t N1,size_t N2,size_t N3,size_t N4> template<typename T,size_t N1,size_t N2,size_t N3,size_t N4, bool is_writable>
struct csv_value_str<T[N1][N2][N3][N4]> struct csv_value_str<T[N1][N2][N3][N4],is_writable>
{ {
inline csv_value_str(const T v[N1][N2][N3][N4], std::stringstream & str) inline csv_value_str(const T v[N1][N2][N3][N4], std::stringstream & str)
{ {
...@@ -201,4 +201,14 @@ struct csv_value_str<T[N1][N2][N3][N4]> ...@@ -201,4 +201,14 @@ struct csv_value_str<T[N1][N2][N3][N4]>
} }
}; };
//! Partial specialization for unknown property
template<typename T>
struct csv_value_str<T,false>
{
inline csv_value_str(const T v, std::stringstream & str)
{
str << "," << 0.0;
}
};
#endif /* CSV_MULTIARRAY_COPY_HPP_ */ #endif /* CSV_MULTIARRAY_COPY_HPP_ */
...@@ -7,9 +7,9 @@ io_CXXFLAGS = $(CUDA_CFLAGS) $(INCLUDES_PATH) $(BOOST_CPPFLAGS) -I/usr/local/inc ...@@ -7,9 +7,9 @@ io_CXXFLAGS = $(CUDA_CFLAGS) $(INCLUDES_PATH) $(BOOST_CPPFLAGS) -I/usr/local/inc
io_CFLAGS = $(CUDA_CFLAGS) io_CFLAGS = $(CUDA_CFLAGS)
io_LDADD = $(LINKLIBS) io_LDADD = $(LINKLIBS)
nobase_include_HEADERS = CSVWriter/csv_multiarray.hpp CSVWriter/CSVWriter.hpp \ nobase_include_HEADERS = CSVWriter/csv_multiarray.hpp CSVWriter/CSVWriter.hpp CSVWriter/is_csv_writable.hpp \
GraphMLWriter/GraphMLWriter.hpp util.hpp \ GraphMLWriter/GraphMLWriter.hpp util.hpp \
VTKWriter/VTKWriter.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 HDF5_XdmfWriter/HDF5_XdmfWriter.hpp HDF5_XdmfWriter/HDF5_XdmfWriter_point_set.hpp HDF5_XdmfWriter/HDF5_XdmfWriter_util.hpp \ VTKWriter/VTKWriter.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 \
Plot/GoogleChart.hpp Plot/util.hpp Plot/GoogleChart.hpp Plot/util.hpp
......
...@@ -14,6 +14,10 @@ ...@@ -14,6 +14,10 @@
#define GGRAPH_COLUMS 1 #define GGRAPH_COLUMS 1
#define GGRAPH_POINTS 2 #define GGRAPH_POINTS 2
#define GC_ZOOM std::string("explorer: {actions: ['dragToZoom', 'rightClickToReset'],axis: 'horizontal,vertical',keepInBounds: true, maxZoomIn: 128.0}")
#define GC_X_LOG std::string("hAxis: { logscale: true }")
#define GC_Y_LOG std::string("vAxis: { logscale: true }")
/*! \brief Google chart options /*! \brief Google chart options
* *
*/ */
...@@ -58,6 +62,9 @@ struct GCoptions ...@@ -58,6 +62,9 @@ struct GCoptions
//! more //! more
std::string more; std::string more;
//! curve type
std::string curveType = "function";
GCoptions & operator=(const GCoptions & opt) GCoptions & operator=(const GCoptions & opt)
{ {
title = opt.title; title = opt.title;
...@@ -190,7 +197,7 @@ class GoogleChart ...@@ -190,7 +197,7 @@ class GoogleChart
} }
data << "data" << i << ".addRows([\n"; data << "data" << i << ".addRows([\n";
for (size_t i = 0 ; i < y.size() ; i++) for (size_t i = 0 ; i < y.size() && x.size() ; i++)
{ {
for (size_t j = 0 ; j < y.get(i).size()+1 ; j++) for (size_t j = 0 ; j < y.get(i).size()+1 ; j++)
...@@ -215,13 +222,14 @@ class GoogleChart ...@@ -215,13 +222,14 @@ class GoogleChart
std::string get_colums_bar_option(const GCoptions & opt) std::string get_colums_bar_option(const GCoptions & opt)
{ {
std::stringstream str; std::stringstream str;
str << "title : '" << opt.title << "',\n"; str << "title : '" << opt.title << "'";
str << "vAxis: {title: '" << opt.yAxis << "'},\n"; str << ",\nvAxis: {title: '" << opt.yAxis << "'}";
str << "hAxis: {title: '" << opt.xAxis << "'},\n"; str << ",\nhAxis: {title: '" << opt.xAxis << "'}";
str << "seriesType: '" << opt.stype << "',\n"; str << ",\nseriesType: '" << opt.stype << "'";
if (opt.stypeext.size() != 0) if (opt.stypeext.size() != 0)
str << "series: " << opt.stypeext << "\n"; str << ",\nseries: " << opt.stypeext;
str << opt.more; if (opt.more.size() != 0)
str << ",\n" <<opt.more;
return str.str(); return str.str();
} }
...@@ -229,21 +237,22 @@ class GoogleChart ...@@ -229,21 +237,22 @@ class GoogleChart
std::string get_points_plot_option(const GCoptions & opt) std::string get_points_plot_option(const GCoptions & opt)
{ {
std::stringstream str; std::stringstream str;
str << "title : '" << opt.title << "',\n"; str << "title : '" << opt.title << "'";
str << "vAxis: {title: '" << opt.yAxis << "'},\n"; str << ",\nvAxis: {title: '" << opt.yAxis << "'}";
str << "hAxis: {title: '" << opt.xAxis << "'},\n"; str << ",\nhAxis: {title: '" << opt.xAxis << "'}";
str << "curveType: 'function',\n"; str << ",\ncurveType: '"<< opt.curveType << "'";
str << "lineWidth: " << opt.lineWidth << ",\n"; str << ",\nlineWidth: " << opt.lineWidth;
if (opt.intervalsext.size() != 0) if (opt.intervalsext.size() != 0)
str << "intervals: " << opt.intervalsext << ",\n"; str << ",\nintervals: " << opt.intervalsext;
else else
str << "intervals: " << "{ 'style':'area' }" << ",\n"; str << ",\nintervals: " << "{ 'style':'area' }";
if (opt.intervalext.size() != 0) if (opt.intervalext.size() != 0)
str << "interval: " << opt.intervalext << "\n"; str << ",\ninterval: " << opt.intervalext << "\n";
str << opt.more; if (opt.more.size() != 0)
str << ",\n" << opt.more;
return str.str(); return str.str();
} }
...@@ -405,11 +414,64 @@ public: ...@@ -405,11 +414,64 @@ public:
set_of_graphs.last().opt = opt; set_of_graphs.last().opt = opt;
} }
/*! \brief Add lines graph
*
* \param y A vector of vectors of values. each vector is a graph of points
*
* \param x Give a name or number to each x value, so can be a string or a number
*
* \param opt Graph options
*
*/
template<typename X, typename Y> void AddLines(openfpm::vector<X> & x, openfpm::vector<Y> & y , const GCoptions & opt)
{
openfpm::vector<std::string> yn;
if (y.size() == 0)
{
std::cerr << "Error: " << __FILE__ << ":" << __LINE__ << " vector y must be filled" << std::endl;
return;
}
for (size_t i = 0 ; i < y.last().size() ; i++)
yn.add(std::string("line") + std::to_string(i));
if (y.size() == 0)
return;
// number of points
size_t np = y.last().size();
for (size_t j = 0 ; j < y.size() ; j++)
{
if (y.get(j).size() != np)
std::cerr << __FILE__ << ":" << __LINE__ << " Error all the graph must have the same number of points " << np << "!=" << y.get(j).size() << std::endl;
}
openfpm::vector<openfpm::vector<X>> swap;
// swap the vector
// Each vector is a graph
// It is different from the other call where each vector
// has multiple value for the same point
for (size_t i = 0 ; i < np ; i++)
{
swap.add();
for (size_t j = 0 ; j < y.size() ; j++)
{
swap.last().add(y.get(j).get(i));
}
}
AddLinesGraph(x,swap,yn,opt);
}
/*! \brief Add a simple lines graph /*! \brief Add a simple lines graph
* *
* \param y A vector of vectors of values. The size of y indicate how many x values * \param y A vector of vectors of values. The size of y indicate how many x values
* we have, while the internal vector can store multiple realizations, * we have, while the internal vector can store multiple value of the same point,
* or min and max, for error bar * for example error bar
* *
* \param x Give a name or number to each x value, so can be a string or a number * \param x Give a name or number to each x value, so can be a string or a number
* *
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <boost/mpl/pair.hpp> #include <boost/mpl/pair.hpp>
#include "VTKWriter_grids_util.hpp" #include "VTKWriter_grids_util.hpp"
#include "is_vtk_writable.hpp"
/*! \brief It store one grid /*! \brief It store one grid
* *
...@@ -76,8 +77,9 @@ struct prop_out_g ...@@ -76,8 +77,9 @@ struct prop_out_g
void operator()(T& t) const void operator()(T& t) const
{ {
typedef typename boost::mpl::at<typename ele_g::value_type::value_type::type,boost::mpl::int_<T::value>>::type ptype; 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 > m(vg,v_out); meta_prop<boost::mpl::int_<T::value> ,ele_g,St, ptype, is_vtk_writable<base_ptype>::value > m(vg,v_out);
} }
void lastProp() void lastProp()
......
This diff is collapsed.
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <boost/mpl/pair.hpp> #include <boost/mpl/pair.hpp>
#include "VTKWriter_grids_util.hpp" #include "VTKWriter_grids_util.hpp"
#include "is_vtk_writable.hpp"
/*! \brief Store the couple of vector position and properties /*! \brief Store the couple of vector position and properties
* *
...@@ -90,8 +91,9 @@ struct prop_out_v ...@@ -90,8 +91,9 @@ struct prop_out_v
void operator()(T& t) const void operator()(T& t) const
{ {
typedef typename boost::mpl::at<typename ele_v::value_type::value_type::type,boost::mpl::int_<T::value>>::type ptype; typedef typename boost::mpl::at<typename ele_v::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_v,St, ptype > m(vv,v_out); meta_prop<boost::mpl::int_<T::value> ,ele_v,St, ptype, is_vtk_writable<base_ptype>::value > m(vv,v_out);
} }
void lastProp() void lastProp()
......
...@@ -508,7 +508,7 @@ BOOST_AUTO_TEST_CASE( vtk_writer_use_vector_box) ...@@ -508,7 +508,7 @@ BOOST_AUTO_TEST_CASE( vtk_writer_use_vector_box)
* \param g Grid to fill * \param g Grid to fill
* *
*/ */
void fill_grid_some_data(grid_cpu<2,Point_test<float>> & g) template<typename grid_type> void fill_grid_some_data(grid_type & g)
{ {
typedef Point_test<float> p; typedef Point_test<float> p;
...@@ -748,8 +748,74 @@ BOOST_AUTO_TEST_CASE( vtk_writer_use_grids) ...@@ -748,8 +748,74 @@ BOOST_AUTO_TEST_CASE( vtk_writer_use_grids)
bool test = compare("vtk_grids_prp.vtk","vtk_grids_prp_test.vtk"); bool test = compare("vtk_grids_prp.vtk","vtk_grids_prp_test.vtk");
BOOST_REQUIRE_EQUAL(test,true); 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,aggregate<float,float,float,float,float[3],float[3][3],openfpm::vector<int>> > g1(sz);
g1.setMemory();
fill_grid_some_data(g1);
grid_cpu<2,aggregate<float,float,float,float,float[3],float[3][3],openfpm::vector<int>> > g2(sz);
g2.setMemory();
fill_grid_some_data(g2);
grid_cpu<2,aggregate<float,float,float,float,float[3],float[3][3],openfpm::vector<int>> > g3(sz);
g3.setMemory();
fill_grid_some_data(g3);
grid_cpu<2,aggregate<float,float,float,float,float[3],float[3][3],openfpm::vector<int>> > g4(sz);
g4.setMemory();
fill_grid_some_data(g4);
// Create a writer and write
VTKWriter<boost::mpl::pair<grid_cpu<2,aggregate<float,float,float,float,float[3],float[3][3],openfpm::vector<int>> >,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);
vtk_g.write("vtk_grids_unk.vtk");
// Check that match
bool test = compare("vtk_grids_unk.vtk","vtk_grids_test.vtk");
BOOST_REQUIRE_EQUAL(test,true);
}
// Try
{
bool ret = is_vtk_writable<Point<3,float>>::value;
BOOST_REQUIRE_EQUAL(ret,true);
ret = is_vtk_writable<Point<3,double>>::value;
BOOST_REQUIRE_EQUAL(ret,true);
int dims = vtk_dims<Point<3,float>>::value;
BOOST_REQUIRE_EQUAL(dims,3);
dims = vtk_dims<long int>::value;
BOOST_REQUIRE_EQUAL(dims,1);
}
} }
BOOST_AUTO_TEST_CASE( vtk_writer_use_point_set ) BOOST_AUTO_TEST_CASE( vtk_writer_use_point_set )
{ {
{ {
...@@ -760,6 +826,7 @@ BOOST_AUTO_TEST_CASE( vtk_writer_use_point_set ) ...@@ -760,6 +826,7 @@ BOOST_AUTO_TEST_CASE( vtk_writer_use_point_set )
openfpm::vector<aggregate<float,float[3]>> v1pp; openfpm::vector<aggregate<float,float[3]>> v1pp;
openfpm::vector<aggregate<float,float[3]>> v2pp; openfpm::vector<aggregate<float,float[3]>> v2pp;
openfpm::vector<aggregate<float,float[3]>> v3pp; openfpm::vector<aggregate<float,float[3]>> v3pp;
openfpm::vector<aggregate<float,Point<3,float>>> v4pp;
// set the seed // set the seed
// create the random generator engine // create the random generator engine
...@@ -773,6 +840,7 @@ BOOST_AUTO_TEST_CASE( vtk_writer_use_point_set ) ...@@ -773,6 +840,7 @@ BOOST_AUTO_TEST_CASE( vtk_writer_use_point_set )
v1pp.resize(100); v1pp.resize(100);
v2pp.resize(100); v2pp.resize(100);
v3pp.resize(100); v3pp.resize(100);
v4pp.resize(100);
for (size_t i = 0 ; i < v1ps.size(); i++) for (size_t i = 0 ; i < v1ps.size(); i++)
{ {
...@@ -802,6 +870,11 @@ BOOST_AUTO_TEST_CASE( vtk_writer_use_point_set ) ...@@ -802,6 +870,11 @@ BOOST_AUTO_TEST_CASE( vtk_writer_use_point_set )
v3pp.template get<1>(i)[0] = rng.GetUniform(); v3pp.template get<1>(i)[0] = rng.GetUniform();
v3pp.template get<1>(i)[1] = rng.GetUniform(); v3pp.template get<1>(i)[1] = rng.GetUniform();
v3pp.template get<1>(i)[2] = rng.GetUniform(); v3pp.template get<1>(i)[2] = rng.GetUniform();
v4pp.template get<0>(i) = rng.GetUniform();
v4pp.template get<1>(i).get(0) = rng.GetUniform();
v4pp.template get<1>(i).get(1) = rng.GetUniform();
v4pp.template get<1>(i).get(2) = rng.GetUniform();
}