Commit f8a9ae64 authored by Pietro Incardona's avatar Pietro Incardona

VTK writer for a set of point or particles

parent 45f102f9
......@@ -38,7 +38,6 @@ Thumbs.db
###### Other
*.vtk
AUTHORS
COPYING
ChangeLog
......
......@@ -98,6 +98,7 @@ enum file_type
#define VECTOR_BOX 2
#define VECTOR_GRIDS 3
#define VECTOR_ST_GRIDS 4
#define VECTOR_POINTS 5
template <typename Graph, unsigned int imp>
class VTKWriter
......@@ -109,5 +110,6 @@ class VTKWriter
#include "VTKWriter_vector_box.hpp"
#include "VTKWriter_grids.hpp"
#include "VTKWriter_grids_st.hpp"
#include "VTKWriter_point_set.hpp"
#endif /* VTKWRITER_HPP_ */
......@@ -11,6 +11,12 @@
#include <boost/mpl/pair.hpp>
#include "VTKWriter_grids_util.hpp"
/*! \brief It store one grid
*
* \tparam Grid type of grid
* \tparam St type of space where the grid is defined
*
*/
template <typename Grid, typename St>
class ele_g
{
......@@ -22,6 +28,7 @@ public:
:g(g),offset(offset),spacing(spacing),dom(dom)
{}
//! Dataset name
std::string dataset;
//! Grid
const Grid & g;
......@@ -41,10 +48,8 @@ public:
* element of the boost::vector the operator() is called.
* Is mainly used to produce at output for each property
*
* \tparam Graph graph we are processing
*
* \param dim Dimensionality
* \param S type of grid
* \tparam ele_g element that store the grid and its attributes
* \param St type of space where the grid live
*
*/
......
......@@ -198,7 +198,10 @@ public:
/*! \brief This class is an helper to create properties output from scalar and compile-time array elements
*
* This class is an helper to copy scalar and compile-time array elements
* \tparam I It is an boost::mpl::int_ that indicate which property we are writing
* \tparam ele_g element type that store the grid information
* \tparam St type of space where the grid live
* \tparam T the type of the property
*
*/
template<typename I, typename ele_g, typename St, typename T>
......
......@@ -8,6 +8,9 @@
#ifndef VTKWRITER_UNIT_TESTS_HPP_
#define VTKWRITER_UNIT_TESTS_HPP_
#include "data_type/aggregate.hpp"
#include <random>
BOOST_AUTO_TEST_SUITE( vtk_writer_test )
/* \brief Sub-domain vertex graph node
......@@ -754,6 +757,76 @@ BOOST_AUTO_TEST_CASE( vtk_writer_use_grids)
}
}
BOOST_AUTO_TEST_CASE( vtk_writer_use_point_set )
{
{
// Create 3 vectors with random particles
openfpm::vector<Point<3,double>> v1ps;
openfpm::vector<Point<3,double>> v2ps;
openfpm::vector<Point<3,double>> v3ps;
openfpm::vector<aggregate<float,float[3]>> v1pp;
openfpm::vector<aggregate<float,float[3]>> v2pp;
openfpm::vector<aggregate<float,float[3]>> v3pp;
// set the seed
// create the random generator engine
std::srand(0);
std::default_random_engine eg;
std::uniform_real_distribution<float> ud(0.0f, 1.0f);
// fill the vector with random data
v1ps.resize(100);
v2ps.resize(100);
v3ps.resize(100);
v1pp.resize(100);
v2pp.resize(100);
v3pp.resize(100);
for (size_t i = 0 ; i < v1ps.size(); i++)
{
v1ps.template get<0>(i)[0] = ud(eg);
v1ps.template get<0>(i)[1] = ud(eg);
v1ps.template get<0>(i)[2] = ud(eg);
v2ps.template get<0>(i)[0] = ud(eg)*0.5;
v2ps.template get<0>(i)[1] = ud(eg)*0.5;
v2ps.template get<0>(i)[2] = ud(eg)*0.5;
v3ps.template get<0>(i)[0] = ud(eg)*0.3;
v3ps.template get<0>(i)[1] = ud(eg)*0.3;
v3ps.template get<0>(i)[2] = ud(eg)*0.3;
v1pp.template get<0>(i) = ud(eg);
v1pp.template get<1>(i)[0] = ud(eg);
v1pp.template get<1>(i)[1] = ud(eg);
v1pp.template get<1>(i)[2] = ud(eg);
v2pp.template get<0>(i) = ud(eg);
v2pp.template get<1>(i)[0] = ud(eg);
v2pp.template get<1>(i)[1] = ud(eg);
v2pp.template get<1>(i)[2] = ud(eg);
v3pp.template get<0>(i) = ud(eg);
v3pp.template get<1>(i)[0] = ud(eg);
v3pp.template get<1>(i)[1] = ud(eg);
v3pp.template get<1>(i)[2] = ud(eg);
}
// Create a writer and write
VTKWriter<boost::mpl::pair<openfpm::vector<Point<3,double>>,openfpm::vector<aggregate<float,float[3]>>>,VECTOR_POINTS> vtk_v;
vtk_v.add(v1ps,v1pp,75);
vtk_v.add(v2ps,v2pp,88);
vtk_v.add(v3ps,v3pp,90);
vtk_v.write("vtk_points.vtk");
// Check that match
bool test = compare("vtk_points.vtk","vtk_points_test.vtk");
BOOST_REQUIRE_EQUAL(test,true);
}
}
BOOST_AUTO_TEST_SUITE_END()
#endif /* VTKWRITER_UNIT_TESTS_HPP_ */
This diff is collapsed.
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