Skip to content
Snippets Groups Projects
Commit 6406c98f authored by tonynsyde's avatar tonynsyde
Browse files

Merging fixes

parents 1031dd1b e5cdbbf7
No related branches found
No related tags found
No related merge requests found
Showing
with 722 additions and 15 deletions
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
############
# it's better to unpack these files and commit the raw source
# git has its own built in compression methods
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip
# Logs and databases #
######################
*.log
*.sql
*.sqlite
# OS generated files #
######################
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
###### Other
AUTHORS
COPYING
ChangeLog
INSTALL
NEWS
README
Makefile
Makefile.in
config.status
configure
numerics
**/.deps
**/src/config
aclocal.m4
**/autom4te.cache
src/io
csv_out.csv
test_graph.graphml
test_graph2.graphml
*.html
......@@ -11,9 +11,7 @@ mkdir openfpm_io/src/config
git clone git@ppmcore.mpi-cbg.de:incardon/openfpm_devices.git openfpm_devices
git clone git@ppmcore.mpi-cbg.de:incardon/openfpm_data.git openfpm_data
git clone git@ppmcore.mpi-cbg.de:incardon/openfpm_pdata.git openfpm_pdata
cd "$1/openfpm_data"
git checkout develop
cd ..
git clone git@ppmcore.mpi-cbg.de:incardon/openfpm_vcluster.git openfpm_vcluster
cd "$1/openfpm_io"
......
......@@ -17,7 +17,18 @@ m4_ifdef([AX_BOOST_IOSTREAMS],,[m4_include([m4/ax_boost_iostreams.m4])])
m4_ifdef([AX_BOOST_PROGRAM_OPTIONS],,[m4_include([m4/ax_boost_program_options.m4])])
m4_ifdef([AX_BOOST_UNIT_TEST_FRAMEWORK],,[m4_include([m4/ax_boost_unit_test_framework.m4])])
CXXFLAGS+=" --std=c++11 -march=native -mtune=native -Wno-unused-local-typedefs -Wextra -Wno-unused-parameter "
case $host_os in
*cygwin*)
# Do something specific for cygwin
CXXFLAGS+=" --std=gnu++11 "
;;
*)
#Default Case
CXXFLAGS+=" --std=c++11 "
;;
esac
CXXFLAGS+=" -march=native -mtune=native -Wno-unused-local-typedefs -Wextra -Wno-unused-parameter "
NVCCFLAGS=" "
INCLUDES_PATH=" "
......@@ -73,6 +84,16 @@ AC_ARG_WITH([pdata],
[pdata_dir="$withval"],
[pdata_dir="../../openfpm_pdata/src"])
####### HDF5
AX_LIB_HDF5([parallel])
if test x"$with_hdf5" = x"no"; then
echo "Cannot detect hdf5, use the --with-hdf5 option if it is not installed in the default location"
exit 207
fi
####### include openfpm_devices include path
INCLUDES_PATH+="-I. -Iconfig -I../../openfpm_data/src -I../../openfpm_devices/src -I../../openfpm_vcluster/src -I$pdata_dir "
......
<html>
<head>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(drawVisualization);
function drawVisualization() {
var data0 = google.visualization.arrayToDataTable([
['X Axis','dataset1','dataset2','dataset3','dataset4'],
['colum1',2.200000,1.300000,4.500000,0.600000],
['colum2',5.000000,6.100000,1.300000,2.600000],
['colum3',2.100000,1.000000,6.100000,9.300000],
['colum4',1.100000,6.100000,3.000000,2.000000],
['colum5',3.300000,0.300000,0.000000,6.200000],
['colum6',2.000000,1.100000,4.000000,6.100000],
]);
var options0= {
title : 'Example',
vAxis: {title: 'Y Axis'},
hAxis: {title: 'X Axis'},
seriesType: 'bars',
};
var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));chart.draw(data0, options0);
}</script>
</head>
<body>
<div id="chart_div0" style="width: 900px; height: 500px;"></div>
</body>
</html>
<html>
<head>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(drawVisualization);
function drawVisualization() {
var data0 = google.visualization.arrayToDataTable([
['X Axis','dataset1','dataset2','dataset3','dataset4'],
['colum1',2.200000,1.300000,4.500000,0.600000],
['colum2',5.000000,6.100000,1.300000,2.600000],
['colum3',2.100000,1.000000,6.100000,9.300000],
['colum4',1.100000,6.100000,3.000000,2.000000],
['colum5',3.300000,0.300000,0.000000,6.200000],
['colum6',2.000000,1.100000,4.000000,6.100000],
]);
var options0= {
title : 'Example',
vAxis: {title: 'Y Axis'},
hAxis: {title: 'X Axis'},
seriesType: '',
};
var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));chart.draw(data0, options0);
}</script>
</head>
<body>
<div id="chart_div0" style="width: 900px; height: 500px;"></div>
</body>
</html>
<html>
<head>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(drawVisualization);
function drawVisualization() {
var data0 = google.visualization.arrayToDataTable([
['','dataset1','dataset2','dataset3','dataset4'],
['colum1',2.200000,1.300000,4.500000,0.600000],
['colum2',5.000000,6.100000,1.300000,2.600000],
['colum3',2.100000,1.000000,6.100000,9.300000],
['colum4',1.100000,6.100000,3.000000,2.000000],
['colum5',3.300000,0.300000,0.000000,6.200000],
['colum6',2.000000,1.100000,4.000000,6.100000],
]);
var options0= {
title : '',
vAxis: {title: ''},
hAxis: {title: ''},
seriesType: '',
};
var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));chart.draw(data0, options0);
}</script>
</head>
<body>
<div id="chart_div0" style="width: 900px; height: 500px;"></div>
</body>
</html>
<html>
<head>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(drawVisualization);
function drawVisualization() {
var data0 = google.visualization.arrayToDataTable([
['','','','',''],
['colum1',2.200000,1.300000,4.500000,0.600000],
['colum2',5.000000,6.100000,1.300000,2.600000],
['colum3',2.100000,1.000000,6.100000,9.300000],
['colum4',1.100000,6.100000,3.000000,2.000000],
['colum5',3.300000,0.300000,0.000000,6.200000],
['colum6',2.000000,1.100000,4.000000,6.100000],
]);
var options0= {
title : '',
vAxis: {title: ''},
hAxis: {title: ''},
seriesType: '',
};
var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));chart.draw(data0, options0);
}</script>
</head>
<body>
<div id="chart_div0" style="width: 900px; height: 500px;"></div>
</body>
</html>
<html>
<head>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(drawVisualization);
function drawVisualization() {
var data0 = google.visualization.arrayToDataTable([
['','','','',''],
['',2.200000,1.300000,4.500000,0.600000],
['',5.000000,6.100000,1.300000,2.600000],
['',2.100000,1.000000,6.100000,9.300000],
['',1.100000,6.100000,3.000000,2.000000],
['',3.300000,0.300000,0.000000,6.200000],
['',2.000000,1.100000,4.000000,6.100000],
]);
var options0= {
title : '',
vAxis: {title: ''},
hAxis: {title: ''},
seriesType: '',
};
var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));chart.draw(data0, options0);
}</script>
</head>
<body>
<div id="chart_div0" style="width: 900px; height: 500px;"></div>
</body>
</html>
<html>
<head>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(drawVisualization);
function drawVisualization() {
var data0 = google.visualization.arrayToDataTable([
['X Axis','dataset1','dataset2','dataset3','dataset4'],
['colum1',2,3,5,6],
['colum2',5,6,1,6],
['colum3',2,1,6,9],
['colum4',1,6,3,2],
['colum5',3,3,0,6],
['colum6',2,1,4,6],
]);
var data1 = google.visualization.arrayToDataTable([
['X Axis','dataset1','dataset2','dataset3','dataset4'],
['colum1',2,3,5,6],
['colum2',5,6,1,6],
['colum3',2,1,6,9],
['colum4',1,6,3,2],
['colum5',3,3,0,6],
['colum6',2,1,4,6],
]);
var data2 = google.visualization.arrayToDataTable([
['X Axis','dataset1','dataset2','dataset3','dataset4'],
['colum1',2,3,5,6],
['colum2',5,6,1,6],
['colum3',2,1,6,9],
['colum4',1,6,3,2],
['colum5',3,3,0,6],
['colum6',2,1,4,6],
]);
var options0= {
title : 'Example',
vAxis: {title: 'Y Axis'},
hAxis: {title: 'X Axis'},
seriesType: 'bars',
series: {3: {type: 'line'}}
};
var options1= {
title : 'Example',
vAxis: {title: 'Y Axis'},
hAxis: {title: 'X Axis'},
seriesType: 'bars',
series: {3: {type: 'line'}}
};
var options2= {
title : 'Example',
vAxis: {title: 'Y Axis'},
hAxis: {title: 'X Axis'},
seriesType: 'bars',
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_div1'));chart.draw(data1, options1);
var chart = new google.visualization.ComboChart(document.getElementById('chart_div2'));chart.draw(data2, options2);
}</script>
</head>
<body>
<h2>Before first graph</h2><div id="chart_div0" style="width: 900px; height: 500px;"></div>
<h2>Before second graph</h2><div id="chart_div1" style="width: 900px; height: 500px;"></div>
<h2>Before third graph</h2><div id="chart_div2" style="width: 900px; height: 500px;"></div>
<h2>At the end</h2></body>
</html>
<html>
<head>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(drawVisualization);
function drawVisualization() {
var data0 = google.visualization.arrayToDataTable([
['X Axis','dataset1','dataset2','dataset3','dataset4'],
['colum1',2,3,5,6],
['colum2',5,6,1,6],
['colum3',2,1,6,9],
['colum4',1,6,3,2],
['colum5',3,3,0,6],
['colum6',2,1,4,6],
]);
var options0= {
title : 'Example',
vAxis: {title: 'Y Axis'},
hAxis: {title: 'X Axis'},
seriesType: 'bars',
series: {3: {type: 'line'}}
};
var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));chart.draw(data0, options0);
}</script>
</head>
<body>
<div id="chart_div0" style="width: 900px; height: 500px;"></div>
</body>
</html>
<html>
<head>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(drawVisualization);
function drawVisualization() {
var data0 = new google.visualization.DataTable();
data0.addColumn('string','X Axis');
data0.addColumn('number','line0');
data0.addColumn('number','line1');
data0.addColumn('number','line2');
data0.addColumn('number','line3');
data0.addColumn('number','line4');
data0.addColumn('number','line5');
data0.addColumn('number','line6');
data0.addColumn('number','line7');
data0.addColumn('number','line8');
data0.addRows([
['colum1',0.1,0.2,0.19,0.22,0.195,0.215,0.35,0.34,0.36],
['colum2',0.11,0.21,0.18,0.22,0.19,0.215,0.36,0.35,0.37],
['colum3',0.12,0.22,0.21,0.23,0.215,0.225,0.35,0.34,0.36],
['colum4',0.15,0.25,0.2,0.26,0.22,0.255,0.36,0.35,0.37],
['colum5',0.09,0.29,0.25,0.3,0.26,0.295,0.35,0.34,0.36],
['colum6',0.08,0.28,0.27,0.29,0.275,0.285,0.36,0.35,0.37],
]);
var options0= {
title : 'Example',
vAxis: {title: 'Y Axis'},
hAxis: {title: 'X Axis'},
curveType: 'function',
lineWidth: 1,
intervals: { 'style':'area' },
};
var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));chart.draw(data0, options0);
}</script>
</head>
<body>
<div id="chart_div0" style="width: 900px; height: 500px;"></div>
</body>
</html>
<html>
<head>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(drawVisualization);
function drawVisualization() {
var data0 = new google.visualization.DataTable();
data0.addColumn('string','X Axis');
data0.addColumn('number','line1');
data0.addColumn('number','line2');
data0.addColumn({id:'i0', type:'number', role:'interval'});
data0.addColumn({id:'i0', type:'number', role:'interval'});
data0.addColumn({id:'i1', type:'number', role:'interval'});
data0.addColumn({id:'i1', type:'number', role:'interval'});
data0.addColumn('number','line3');
data0.addColumn({id:'i2', type:'number', role:'interval'});
data0.addColumn({id:'i2', type:'number', role:'interval'});
data0.addRows([
['colum1',0.1,0.2,0.19,0.22,0.195,0.215,0.35,0.34,0.36],
['colum2',0.11,0.21,0.18,0.22,0.19,0.215,0.36,0.35,0.37],
['colum3',0.12,0.22,0.21,0.23,0.215,0.225,0.35,0.34,0.36],
['colum4',0.15,0.25,0.2,0.26,0.22,0.255,0.36,0.35,0.37],
['colum5',0.09,0.29,0.25,0.3,0.26,0.295,0.35,0.34,0.36],
['colum6',0.08,0.28,0.27,0.29,0.275,0.285,0.36,0.35,0.37],
]);
var options0= {
title : 'Example',
vAxis: {title: 'Y Axis'},
hAxis: {title: 'X Axis'},
curveType: 'function',
lineWidth: 1,
intervals: { 'style':'area' },
interval: {'i2': { 'color': '#4374E0', 'style':'bars', 'lineWidth':4, 'fillOpacity':1 } }
};
var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));chart.draw(data0, options0);
}</script>
</head>
<body>
<div id="chart_div0" style="width: 900px; height: 500px;"></div>
</body>
</html>
......@@ -18,6 +18,8 @@
#include "csv_multiarray.hpp"
#include "util.hpp"
#define CSV_WRITER 0x30000
/*! \brief this class is a functor for "for_each" algorithm
*
* For each element of the boost::vector the operator() is called.
......@@ -54,7 +56,7 @@ struct csv_prp
void operator()(T& t)
{
// This is the type of the csv column
typedef typename boost::fusion::result_of::at_c<typename Tobj::type,T::value>::type col_type;
typedef decltype(obj.template get<T::value>()) col_type;
// Remove the reference from the column type
typedef typename boost::remove_reference<col_type>::type col_rtype;
......@@ -87,7 +89,7 @@ struct csv_col
void operator()(T& t)
{
// This is the type of the csv column
typedef typename boost::fusion::result_of::at_c<typename Tobj::type,T::value>::type col_type;
typedef decltype(std::declval<Tobj>.template get<T::value>()) col_type;
// Remove the reference from the column type
typedef typename boost::remove_reference<col_type>::type col_rtype;
......@@ -181,9 +183,10 @@ class CSVWriter
*
* \param v_pos vector that contain the positional information
* \param v_prp vector that contain the property information
* \param offset from where to start
*
*/
std::string get_csv_data(v_pos & vp, v_prp & vpr)
std::string get_csv_data(v_pos & vp, v_prp & vpr, size_t offset)
{
std::stringstream str;
......@@ -195,7 +198,7 @@ class CSVWriter
}
// Write the data
for (size_t i = 0 ; i < vp.size() ; i++)
for (size_t i = offset ; i < vp.size() ; i++)
{
for (size_t j = 0 ; j < v_pos::value_type::dims ; j++)
{
......@@ -206,9 +209,9 @@ class CSVWriter
}
// Object to write
typename v_prp::value_type obj = vpr.get(i);
auto obj = vpr.get(i);
csv_prp<typename v_prp::value_type> c_prp(str,obj);
csv_prp<decltype(obj)> c_prp(str,obj);
// write the properties to the stream string
boost::mpl::for_each< boost::mpl::range_c<int,0,v_prp::value_type::max_prop> >(c_prp);
......@@ -228,10 +231,11 @@ public:
* \param file path where to write
* \param v_pos positional vector
* \param v_prp properties vector
* \param offset from where to start to write
*
*/
bool write(std::string file, v_pos & v , v_prp & prp)
bool write(std::string file, v_pos & v , v_prp & prp, size_t offset=0)
{
// Header for csv (colums name)
std::string csv_header;
......@@ -242,7 +246,7 @@ public:
csv_header = get_csv_colums();
// For each property in the vertex type produce a point data
point_data = get_csv_data(v,prp);
point_data = get_csv_data(v,prp,offset);
// write the file
std::ofstream ofs(file);
......
File moved
......@@ -208,6 +208,11 @@ struct vertex_node
create_prop<typename G::V_type>(attributes_names);
};
inline ~vertex_node()
{
delete [] attributes_names;
}
#ifdef DEBUG
/*! \brief Constructor
*
......@@ -558,7 +563,7 @@ class GraphMLWriter
vn.new_node(nc);
// Iterate through all the vertex and create the vertex list
boost::mpl::for_each< boost::mpl::range_c<int,0,Graph::V_type::max_prop> >(vn);
boost::mpl::for_each_ref< boost::mpl::range_c<int,0,Graph::V_type::max_prop> >(vn);
// end node
vn.end_node();
......
......@@ -11,7 +11,6 @@
#define GS_SIZE 8
#include "GraphMLWriter.hpp"
#include "VTKWriter.hpp"
#include "Graph/CartesianGraphFactory.hpp"
#include "util.hpp"
......@@ -94,14 +93,22 @@ BOOST_AUTO_TEST_CASE( graphml_writer_use)
n1.get_i() = 6.0;
n1.get_str() = std::string("test");
g_csr2.addVertex(n1);
n1.get_str() = std::string("tes2");
g_csr2.addVertex(n1);
n1.get_str() = std::string("test3");
g_csr2.addVertex(n1);
n1.get_str() = std::string("test4");
g_csr2.addVertex(n1);
n1.get_str() = std::string("test5");
g_csr2.addEdge(0,1,n1);
n1.get_str() = std::string("test6");
g_csr2.addEdge(2,1,n1);
n1.get_str() = std::string("test7");
g_csr2.addEdge(3,1,n1);
n1.get_str() = std::string("test8");
g_csr2.addEdge(2,0,n1);
n1.get_str() = std::string("test9");
g_csr2.addEdge(3,2,n1);
// Create a graph ML
......@@ -123,7 +130,10 @@ BOOST_AUTO_TEST_CASE( graphml_writer_use)
// Box
Box<3,float> box({0.0,0.0,0.0},{1.0,1.0,1.0});
Graph_CSR<ne_cp,ne_cp> g_csr = g_factory.construct<5,float,2,ne_cp::x,ne_cp::y,ne_cp::z>(sz,box);
// Boundary conditions, non periodic
size_t bc[] = {NON_PERIODIC,NON_PERIODIC,NON_PERIODIC};
Graph_CSR<ne_cp,ne_cp> g_csr = g_factory.construct<5,NO_VERTEX_ID,float,2,ne_cp::x,ne_cp::y,ne_cp::z>(sz,box,bc);
// Create a graph ML
GraphMLWriter<Graph_CSR<ne_cp,ne_cp>> gw(g_csr);
......
/*
* H5PartWriter.hpp
*
* Created on: Feb 7, 2016
* Author: i-bird
*/
#ifndef OPENFPM_IO_SRC_HDF5_XDMFWRITER_HDF5_XDMFWRITER_HPP_
#define OPENFPM_IO_SRC_HDF5_XDMFWRITER_HDF5_XDMFWRITER_HPP_
#define H5PART_WRITER 0x20000
#define H5_POINTSET 1
template <unsigned int imp>
class HDF5_XdmfWriter
{
};
#include "HDF5_XdmfWriter_point_set.hpp"
#endif /* OPENFPM_IO_SRC_HDF5_XDMFWRITER_HDF5_XDMFWRITER_HPP_ */
/*
* H5PartWriter_point_set.hpp
*
* Created on: Feb 7, 2016
* Author: i-bird
*/
#ifndef OPENFPM_IO_SRC_HDF5_XDMFWRITER_HDF5_XDMFWRITER_POINT_SET_HPP_
#define OPENFPM_IO_SRC_HDF5_XDMFWRITER_HDF5_XDMFWRITER_POINT_SET_HPP_
#include "HDF5_XdmfWriter_util.hpp"
#include "Vector/map_vector.hpp"
#include "VCluster.hpp"
/*! \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 produce write each property in H5Part
*
* \tparam ele_v is the vector of properties
* \tparam seq, sequence of property to output
* \tparam has_name define if the structure define names for the properties
*
*/
template<typename ele_v, bool has_name>
struct H5_prop_out
{
// HDF5 file
hid_t file_id;
// vector that we are processing
ele_v & vv;
// Up to which element to write
size_t stop;
/*! \brief constructor
*
* \param v_out string to fill with the vertex properties
*
*/
H5_prop_out(hid_t file_id, ele_v & vv, size_t stop)
:file_id(file_id),vv(vv),stop(stop)
{};
//! It produce an output for each property
template<typename T>
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;
H5_write<ptype,T::value,ele_v>::write(file_id,std::string(ele_v::value_type::attributes::names[T::value]),vv,stop);
}
};
/*! \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 produce an output for each property
*
* \tparam ele_v is the vector of properties
* \tparam seq, sequence of property to output
* \tparam has_name define if the structure define names
*
*/
template<typename ele_v>
struct H5_prop_out<ele_v,false>
{
// HDF5 file
hid_t file_id;
// vector that we are processing
ele_v & vv;
// Up to which element to write
size_t stop;
/*! \brief constructor
*
* \param v_out string to fill with the vertex properties
*
*/
H5_prop_out(hid_t file_id, ele_v & vv, size_t stop)
:file_id(file_id),vv(vv),stop(stop)
{};
//! It produce an output for each property
template<typename T>
void operator()(T& t) const
{
typedef typename boost::mpl::at<typename ele_v::value_type::type,boost::mpl::int_<T::value>>::type ptype;
H5_write<ptype,T::value,ele_v>::write(file_id,std::string("attr") + std::to_string(T::value),vv,stop);
}
};
template <>
class HDF5_XdmfWriter<H5_POINTSET>
{
// Time step
int t;
//! HDF5 file
hid_t file_id;
public:
/*!
*
* H5PartWriter constructor
*
*/
HDF5_XdmfWriter()
:t(0)
{}
/*!
*
* \brief Write a set of particle position and properties into HDF5
*
* \tparam Pos Vector of positions type
* \taparam Prp Vector of properties type
* \tparam prp list of properties to output
*
* \param pos Vector with the positions
* \param prp Vector with the properties
* \param stop size of the vector to output
*
*/
template<typename VPos, typename VPrp, int ... prp > bool write(const std::string & file, openfpm::vector<VPos> & v_pos, openfpm::vector<VPrp> & v_prp, size_t stop)
{
Vcluster & v_cl = *global_v_cluster;
// Open and HDF5 file in parallel
hid_t plist_id = H5Pcreate(H5P_FILE_ACCESS);
H5Pset_fapl_mpio(plist_id, v_cl.getMPIComm(), MPI_INFO_NULL);
file_id = H5Fcreate(file.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, plist_id);
H5Pclose(plist_id);
// Single coordinate positional vector
openfpm::vector<typename VPos::coord_type> x_n;
x_n.resize(stop);
//for each component, fill x_n
for (size_t i = 0 ; i < VPos::dims ; i++)
{
//
for (size_t j = 0 ; j < stop ; j++)
x_n.get(j) = v_pos.template get<0>(j)[i];
std::stringstream str;
str << "x" << i;
HDF5CreateDataSet<typename VPos::coord_type>(file_id,str.str(),x_n.getPointer(),stop*sizeof(typename VPos::coord_type));
}
// Now we write the properties
typedef typename to_boost_vmpl<prp ... >::type v_prp_seq;
H5_prop_out<openfpm::vector<VPrp>,has_attributes<VPrp>::value> f(file_id,v_prp,stop);
boost::mpl::for_each_ref<v_prp_seq>(f);
H5Fclose(file_id);
return true;
}
};
#endif /* OPENFPM_IO_SRC_HDF5_XDMFWRITER_HDF5_XDMFWRITER_POINT_SET_HPP_ */
/*
* H5PartWriter_unit_tests.hpp
*
* Created on: Feb 22, 2016
* Author: i-bird
*/
#ifndef OPENFPM_IO_SRC_HDF5_XDMFWRITER_HDF5_XDMFWRITER_UNIT_TESTS_HPP_
#define OPENFPM_IO_SRC_HDF5_XDMFWRITER_HDF5_XDMFWRITER_UNIT_TESTS_HPP_
#include "VCluster.hpp"
#include "util/SimpleRNG.hpp"
#include "HDF5_XdmfWriter.hpp"
BOOST_AUTO_TEST_SUITE( HDF5_writer_test )
BOOST_AUTO_TEST_CASE( HDF5_writer_use)
{
openfpm::vector<Point<3,double>> pv;
openfpm::vector<Point_test<double>> pvp;
SimpleRNG rng;
Vcluster & v_cl = *global_v_cluster;
if (v_cl.getProcessingUnits() != 3)
return;
double z_base = v_cl.getProcessUnitID();
// fill 1000 particles for each processors
for (size_t i = 0 ; i < 1000 ; i++)
{
Point<3,double> p;
p[0] = rng.GetUniform();
p[1] = rng.GetUniform();
p[2] = z_base+rng.GetUniform();
pv.add(p);
p[0] += 2.0;
Point_test<double> pt;
pt.fill();
pvp.add(pt);
}
HDF5_XdmfWriter<H5_POINTSET> h5p;
h5p.template write<Point<3,double>,Point_test<double>,0,1,4,5>("h5part.h5",pv,pvp,1000);
// check that match
bool test = compare("test_h5part.h5part","test_h5part_test.h5part");
BOOST_REQUIRE_EQUAL(true,test);
}
BOOST_AUTO_TEST_SUITE_END()
#endif /* OPENFPM_IO_SRC_HDF5_XDMFWRITER_HDF5_XDMFWRITER_UNIT_TESTS_HPP_ */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment