Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
O
openfpm_io
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
openfpm
openfpm_io
Commits
cb37b2bc
Commit
cb37b2bc
authored
Feb 06, 2016
by
Pietro Incardona
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reordering io files
parent
62978d3e
Changes
15
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
399 additions
and
5 deletions
+399
-5
src/CSVWriter/CSVWriter.hpp
src/CSVWriter/CSVWriter.hpp
+0
-0
src/CSVWriter/CSVWriter_unit_tests.hpp
src/CSVWriter/CSVWriter_unit_tests.hpp
+0
-0
src/CSVWriter/csv_multiarray.hpp
src/CSVWriter/csv_multiarray.hpp
+0
-0
src/GraphMLWriter/GraphMLWriter.hpp
src/GraphMLWriter/GraphMLWriter.hpp
+0
-0
src/GraphMLWriter/GraphMLWriter_unit_tests.hpp
src/GraphMLWriter/GraphMLWriter_unit_tests.hpp
+0
-1
src/Makefile.am
src/Makefile.am
+1
-1
src/VTKWriter/VTKWriter.hpp
src/VTKWriter/VTKWriter.hpp
+0
-0
src/VTKWriter/VTKWriter_graph.hpp
src/VTKWriter/VTKWriter_graph.hpp
+0
-0
src/VTKWriter/VTKWriter_grids.hpp
src/VTKWriter/VTKWriter_grids.hpp
+0
-0
src/VTKWriter/VTKWriter_grids_st.hpp
src/VTKWriter/VTKWriter_grids_st.hpp
+0
-0
src/VTKWriter/VTKWriter_grids_util.hpp
src/VTKWriter/VTKWriter_grids_util.hpp
+0
-0
src/VTKWriter/VTKWriter_point_set.hpp
src/VTKWriter/VTKWriter_point_set.hpp
+394
-0
src/VTKWriter/VTKWriter_unit_tests.hpp
src/VTKWriter/VTKWriter_unit_tests.hpp
+1
-0
src/VTKWriter/VTKWriter_vector_box.hpp
src/VTKWriter/VTKWriter_vector_box.hpp
+0
-0
src/main.cpp
src/main.cpp
+3
-3
No files found.
src/CSVWriter.hpp
→
src/CSVWriter
/CSVWriter
.hpp
View file @
cb37b2bc
File moved
src/CSVWriter_unit_tests.hpp
→
src/CSVWriter
/CSVWriter
_unit_tests.hpp
View file @
cb37b2bc
File moved
src/csv_multiarray.hpp
→
src/
CSVWriter/
csv_multiarray.hpp
View file @
cb37b2bc
File moved
src/GraphMLWriter.hpp
→
src/GraphMLWriter
/GraphMLWriter
.hpp
View file @
cb37b2bc
File moved
src/GraphMLWriter_unit_tests.hpp
→
src/GraphMLWriter
/GraphMLWriter
_unit_tests.hpp
View file @
cb37b2bc
...
...
@@ -11,7 +11,6 @@
#define GS_SIZE 8
#include "GraphMLWriter.hpp"
#include "VTKWriter.hpp"
#include "Graph/CartesianGraphFactory.hpp"
#include "util.hpp"
...
...
src/Makefile.am
View file @
cb37b2bc
...
...
@@ -7,7 +7,7 @@ io_CXXFLAGS = $(CUDA_CFLAGS) $(INCLUDES_PATH) $(BOOST_CPPFLAGS) -I/usr/local/inc
io_CFLAGS
=
$(CUDA_CFLAGS)
io_LDADD
=
$(LINKLIBS)
nobase_include_HEADERS
=
csv_multiarray.hpp CSVWriter.hpp GraphMLWriter.hpp util.hpp VTKWriter.hpp VTKWriter_graph.hpp VTKWriter_grids.hpp VTKWriter_grids_st.hpp VTKWriter_grids_util.hpp
VTKWriter_vector_box.hpp
nobase_include_HEADERS
=
CSVWriter/csv_multiarray.hpp CSVWriter/CSVWriter.hpp GraphMLWriter/GraphMLWriter.hpp util.hpp VTKWriter/VTKWriter.hpp VTKWriter/VTKWriter_graph.hpp VTKWriter/VTKWriter_grids.hpp VTKWriter/VTKWriter_grids_st.hpp VTKWriter/VTKWriter_grids_util.hpp VTKWriter/
VTKWriter_vector_box.hpp
.cu.o
:
...
...
src/VTKWriter.hpp
→
src/VTKWriter
/VTKWriter
.hpp
View file @
cb37b2bc
File moved
src/VTKWriter_graph.hpp
→
src/VTKWriter
/VTKWriter
_graph.hpp
View file @
cb37b2bc
File moved
src/VTKWriter_grids.hpp
→
src/VTKWriter
/VTKWriter
_grids.hpp
View file @
cb37b2bc
File moved
src/VTKWriter_grids_st.hpp
→
src/VTKWriter
/VTKWriter
_grids_st.hpp
View file @
cb37b2bc
File moved
src/VTKWriter_grids_util.hpp
→
src/VTKWriter
/VTKWriter
_grids_util.hpp
View file @
cb37b2bc
File moved
src/VTKWriter/VTKWriter_point_set.hpp
0 → 100644
View file @
cb37b2bc
/*
* VTKWriter_point_set.hpp
*
* Created on: Feb 6, 2016
* Author: i-bird
*/
#ifndef OPENFPM_IO_SRC_VTKWRITER_POINT_SET_HPP_
#define OPENFPM_IO_SRC_VTKWRITER_POINT_SET_HPP_
#include <boost/mpl/pair.hpp>
#include "VTKWriter_grids_util.hpp"
/*! \brief Store the couple of vector position and properties
*
* \tparam Vps Type of vector that store the position of the particles
*
*/
template
<
typename
Vps
>
class
ele_vps
{
public:
typedef
Vps
value_type
;
const
Vps
&
g
;
size_t
mark
;
ele_vps
(
const
Vps
&
g
,
size_t
mark
)
:
g
(
g
),
mark
(
mark
)
{}
};
/*! \brief Store the couple of vector position and properties
*
* \tparam Vpp Type of vector that store the property of the particles
*
*/
template
<
typename
Vpp
>
class
ele_vpp
{
public:
typedef
Vpp
value_type
;
const
Vpp
&
g
;
size_t
mark
;
ele_vpp
(
const
Vpp
&
vpp
,
size_t
mark
)
:
g
(
vpp
),
mark
(
mark
)
{}
};
/*! \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 It is the class ele_v that store the couple vector of position and property
*
*
*/
template
<
typename
ele_v
,
typename
St
>
struct
prop_out_v
{
// property output string
std
::
string
&
v_out
;
// vector that we are processing
const
openfpm
::
vector_std
<
ele_v
>
&
vv
;
/*! \brief constructor
*
* \param v_out string to fill with the vertex properties
*
*/
prop_out_v
(
std
::
string
&
v_out
,
const
openfpm
::
vector_std
<
ele_v
>
&
vv
)
:
v_out
(
v_out
),
vv
(
vv
)
{};
//! 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
;
meta_prop
<
boost
::
mpl
::
int_
<
T
::
value
>
,
ele_v
,
St
,
ptype
>
m
(
vv
,
v_out
);
}
void
lastProp
()
{
// Create point data properties
v_out
+=
"SCALARS domain float
\n
"
;
// Default lookup table
v_out
+=
"LOOKUP_TABLE default
\n
"
;
// Produce point data
for
(
size_t
k
=
0
;
k
<
vv
.
size
()
;
k
++
)
{
//! Get a vertex iterator
auto
it
=
vv
.
get
(
k
).
g
.
getIterator
();
// if there is the next element
while
(
it
.
isNext
())
{
if
(
it
.
get
()
<
vv
.
get
(
k
).
mark
)
v_out
+=
"1.0
\n
"
;
else
v_out
+=
"0.0
\n
"
;
// increment the iterator and counter
++
it
;
}
}
}
};
/*!
*
* It write a VTK format file for a list of grids defined on a space
*
* \tparam boost::mpl::pair<G,S>
*
* where G is the type of the vector containing the properties, S is the
* type of vector containing the particle positions
*
*/
template
<
typename
pair
>
class
VTKWriter
<
pair
,
VECTOR_POINTS
>
{
//! Vector of couple, position and properties
openfpm
::
vector
<
ele_vps
<
typename
pair
::
first
>>
vps
;
openfpm
::
vector
<
ele_vpp
<
typename
pair
::
second
>>
vpp
;
/*! \brief Get the total number of points
*
* \return the total number
*
*/
size_t
get_total
()
{
size_t
tot
=
0
;
//! Calculate the full number of vertices
for
(
size_t
i
=
0
;
i
<
vps
.
size
()
;
i
++
)
{
tot
+=
vps
.
get
(
i
).
g
.
size
();
}
return
tot
;
}
/*! \brief It get the vertex properties list
*
* It get the vertex properties list of the vertex defined as VTK header
*
* \return a string that define the vertex properties in graphML format
*
*/
std
::
string
get_vertex_properties_list
()
{
//! vertex property output string
std
::
string
v_out
;
// write the number of vertex
v_out
+=
"VERTICES "
+
std
::
to_string
(
get_total
())
+
" "
+
std
::
to_string
(
get_total
()
*
2
)
+
"
\n
"
;
// return the vertex properties string
return
v_out
;
}
/*! \brief It get the vertex properties list
*
* It get the vertex properties list of the vertex defined as a VTK header
*
* \return a string that define the vertex properties in graphML format
*
*/
std
::
string
get_point_properties_list
()
{
//! vertex property output string
std
::
string
v_out
;
// write the number of vertex
v_out
+=
"POINTS "
+
std
::
to_string
(
get_total
())
+
" float"
+
"
\n
"
;
// return the vertex properties string
return
v_out
;
}
/*! \brief Create the VTK point definition
*
*/
std
::
string
get_point_list
()
{
//! vertex node output string
std
::
stringstream
v_out
;
//! For each defined grid
for
(
size_t
i
=
0
;
i
<
vps
.
size
()
;
i
++
)
{
//! write the particle position
auto
it
=
vps
.
get
(
i
).
g
.
getIterator
();
// if there is the next element
while
(
it
.
isNext
())
{
Point
<
pair
::
first
::
value_type
::
dims
,
typename
pair
::
first
::
value_type
::
coord_type
>
p
;
p
=
vps
.
get
(
i
).
g
.
get
(
it
.
get
());
if
(
pair
::
first
::
value_type
::
dims
==
2
)
v_out
<<
p
.
toString
()
<<
" 0.0"
<<
"
\n
"
;
else
v_out
<<
p
.
toString
()
<<
"
\n
"
;
// increment the iterator and counter
++
it
;
}
}
// return the vertex list
return
v_out
.
str
();
}
/*! \brief Create the VTK vertex definition
*
*/
std
::
string
get_vertex_list
()
{
//! vertex node output string
std
::
string
v_out
;
size_t
k
=
0
;
for
(
size_t
i
=
0
;
i
<
vps
.
size
()
;
i
++
)
{
//! For each grid point create a vertex
auto
it
=
vps
.
get
(
i
).
g
.
getIterator
();
while
(
it
.
isNext
())
{
v_out
+=
"1 "
+
std
::
to_string
(
k
)
+
"
\n
"
;
++
k
;
++
it
;
}
}
// return the vertex list
return
v_out
;
}
/*! \brief Get the point data header
*
* \return a string with the point data header for VTK format
*
*/
std
::
string
get_point_data_header
()
{
std
::
string
v_out
;
v_out
+=
"POINT_DATA "
+
std
::
to_string
(
get_total
())
+
"
\n
"
;
return
v_out
;
}
public:
/*!
*
* VTKWriter constructor
*
*/
VTKWriter
()
{}
/*! \brief Add a vector dataset
*
* \param vps vector of positions
* \param vpp vector of properties
* \param mark, additional information that divide the dataset into 2
* (in general is used to mark real from ghost information)
*
*/
void
add
(
const
typename
pair
::
first
&
vps
,
const
typename
pair
::
second
&
vpp
,
size_t
mark
)
{
ele_vps
<
typename
pair
::
first
>
t1
(
vps
,
mark
);
ele_vpp
<
typename
pair
::
second
>
t2
(
vpp
,
mark
);
this
->
vps
.
add
(
t1
);
this
->
vpp
.
add
(
t2
);
}
/*! \brief It write a VTK file from a vector of points
*
* \tparam prp_out which properties to output [default = -1 (all)]
*
* \param file path where to write
* \param name name of the dataset
* \param file_type specify if it is a VTK BINARY or ASCII file [default = ASCII]
*
*/
template
<
int
prp
=
-
1
>
bool
write
(
std
::
string
file
,
std
::
string
f_name
=
"grids"
,
file_type
ft
=
file_type
::
ASCII
)
{
// Header for the vtk
std
::
string
vtk_header
;
// Point list of the VTK
std
::
string
point_list
;
// Vertex list of the VTK
std
::
string
vertex_list
;
// Graph header
std
::
string
vtk_binary_or_ascii
;
// vertex properties header
std
::
string
point_prop_header
;
// edge properties header
std
::
string
vertex_prop_header
;
// Data point header
std
::
string
point_data_header
;
// Data point
std
::
string
point_data
;
// VTK header
vtk_header
=
"# vtk DataFile Version 3.0
\n
"
+
f_name
+
"
\n
"
;
// Choose if binary or ASCII
if
(
ft
==
file_type
::
ASCII
)
{
vtk_header
+=
"ASCII
\n
"
;}
else
{
vtk_header
+=
"BINARY
\n
"
;}
// Data type for graph is DATASET POLYDATA
vtk_header
+=
"DATASET POLYDATA
\n
"
;
// point properties header
point_prop_header
=
get_point_properties_list
();
// Get point list
point_list
=
get_point_list
();
// vertex properties header
vertex_prop_header
=
get_vertex_properties_list
();
// Get vertex list
vertex_list
=
get_vertex_list
();
// 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_v
<
ele_vpp
<
typename
pair
::
second
>
,
typename
pair
::
first
::
value_type
::
coord_type
>
pp
(
point_data
,
vpp
);
if
(
prp
==
-
1
)
boost
::
mpl
::
for_each
<
boost
::
mpl
::
range_c
<
int
,
0
,
pair
::
second
::
value_type
::
max_prop
>
>
(
pp
);
else
boost
::
mpl
::
for_each
<
boost
::
mpl
::
range_c
<
int
,
prp
,
prp
>
>
(
pp
);
// Add the last property
pp
.
lastProp
();
// write the file
std
::
ofstream
ofs
(
file
);
// Check if the file is open
if
(
ofs
.
is_open
()
==
false
)
{
std
::
cerr
<<
"Error cannot create the VTK file: "
+
file
+
"
\n
"
;}
ofs
<<
vtk_header
<<
point_prop_header
<<
point_list
<<
vertex_prop_header
<<
vertex_list
<<
point_data_header
<<
point_data
;
// Close the file
ofs
.
close
();
// Completed succefully
return
true
;
}
};
#endif
/* OPENFPM_IO_SRC_VTKWRITER_POINT_SET_HPP_ */
src/VTKWriter_unit_tests.hpp
→
src/VTKWriter
/VTKWriter
_unit_tests.hpp
View file @
cb37b2bc
...
...
@@ -10,6 +10,7 @@
#include "data_type/aggregate.hpp"
#include <random>
#include "VTKWriter.hpp"
BOOST_AUTO_TEST_SUITE
(
vtk_writer_test
)
...
...
src/VTKWriter_vector_box.hpp
→
src/VTKWriter
/VTKWriter
_vector_box.hpp
View file @
cb37b2bc
File moved
src/main.cpp
View file @
cb37b2bc
...
...
@@ -6,7 +6,7 @@
#define BOOST_TEST_MODULE "C++ test module for OpenFPM_io project"
#include <boost/test/included/unit_test.hpp>
#include "CSVWriter_unit_tests.hpp"
#include "GraphMLWriter_unit_tests.hpp"
#include "VTKWriter_unit_tests.hpp"
#include "CSVWriter
/CSVWriter
_unit_tests.hpp"
#include "GraphMLWriter
/GraphMLWriter
_unit_tests.hpp"
#include "VTKWriter
/VTKWriter
_unit_tests.hpp"
#include "Plot/Plot_unit_tests.hpp"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment