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
13e4a081
Commit
13e4a081
authored
Sep 03, 2015
by
incardon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added VTKWriter for staggered grid
parent
e4e6e157
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
619 additions
and
14 deletions
+619
-14
src/VTKWriter.hpp
src/VTKWriter.hpp
+2
-0
src/VTKWriter_grids.hpp
src/VTKWriter_grids.hpp
+2
-10
src/VTKWriter_grids_st.hpp
src/VTKWriter_grids_st.hpp
+547
-0
src/VTKWriter_grids_util.hpp
src/VTKWriter_grids_util.hpp
+15
-4
src/VTKWriter_unit_tests.hpp
src/VTKWriter_unit_tests.hpp
+53
-0
No files found.
src/VTKWriter.hpp
View file @
13e4a081
...
...
@@ -96,6 +96,7 @@ enum file_type
#define GRAPH 1
#define VECTOR_BOX 2
#define VECTOR_GRIDS 3
#define VECTOR_ST_GRIDS 4
template
<
typename
Graph
,
unsigned
int
imp
>
class
VTKWriter
...
...
@@ -106,5 +107,6 @@ class VTKWriter
#include "VTKWriter_graph.hpp"
#include "VTKWriter_vector_box.hpp"
#include "VTKWriter_grids.hpp"
#include "VTKWriter_grids_st.hpp"
#endif
/* VTKWRITER_HPP_ */
src/VTKWriter_grids.hpp
View file @
13e4a081
...
...
@@ -177,13 +177,9 @@ class VTKWriter<pair,VECTOR_GRIDS>
}
/*! \brief Create the VTK point definition
*
* \tparam s_type spatial type of the data
* \tparam attr false x,y,z are set to 0 for each vertex
*
*/
template
<
bool
attr
>
std
::
string
get_point_list
()
std
::
string
get_point_list
()
{
//! vertex node output string
std
::
stringstream
v_out
;
...
...
@@ -220,12 +216,8 @@ class VTKWriter<pair,VECTOR_GRIDS>
}
/*! \brief Create the VTK vertex definition
*
* \tparam s_type spatial type of the data
* \tparam attr false x,y,z are set to 0 for each vertex
*
*/
std
::
string
get_vertex_list
()
{
//! vertex node output string
...
...
@@ -336,7 +328,7 @@ public:
point_prop_header
=
get_point_properties_list
();
// Get point list
point_list
=
get_point_list
<
has_attributes
<
typename
pair
::
first
::
value_type
>::
value
>
();
point_list
=
get_point_list
();
// vertex properties header
vertex_prop_header
=
get_vertex_properties_list
();
...
...
src/VTKWriter_grids_st.hpp
0 → 100644
View file @
13e4a081
This diff is collapsed.
Click to expand it.
src/VTKWriter_grids_util.hpp
View file @
13e4a081
...
...
@@ -2,12 +2,14 @@
* VTKWriter_grids_util.hpp
*
* Created on: Aug 10, 2015
* Author:
i-bird
* Author:
Pietro Incardona
*/
#ifndef SRC_VTKWRITER_GRIDS_UTIL_HPP_
#define SRC_VTKWRITER_GRIDS_UTIL_HPP_
#include "util/util_debug.hpp"
/*! \brief This class specialize functions in the case the type T
* has or not defined attributes
*
...
...
@@ -67,14 +69,20 @@ public:
//! vertex node output string
std
::
string
v_out
;
typedef
typename
boost
::
fusion
::
result_of
::
at
<
typename
ele_g
::
value_type
::
type
,
boost
::
mpl
::
int_
<
i
>>::
type
ctype
;
// Check if T is a supported format
// for now we support only scalar of native type
std
::
string
type
=
getType
<
typename
boost
::
fusion
::
result_of
::
at
<
typename
ele_g
::
value_type
::
type
,
boost
::
mpl
::
int_
<
i
>>::
type
>
();
std
::
string
type
=
getType
<
c
type
>
();
// if the type is not supported return
// if the type is not supported return
if
(
type
.
size
()
==
0
)
{
return
v_out
;}
{
std
::
cerr
<<
"Error "
<<
__FILE__
<<
":"
<<
__LINE__
<<
" the type "
<<
demangle
(
typeid
(
ctype
).
name
())
<<
" is not supported by vtk
\n
"
;
return
""
;
}
// Create point data properties
v_out
+=
"SCALARS "
+
get_attributes
(
oprp
)
+
" "
+
type
+
"
\n
"
;
...
...
@@ -136,7 +144,10 @@ public:
// if the type is not supported return
if
(
type
.
size
()
==
0
)
{
return
v_out
;}
{
std
::
cerr
<<
"Error "
<<
__FILE__
<<
":"
<<
__LINE__
<<
" the type "
<<
demangle
(
typeid
(
ctype
).
name
())
<<
" is not supported by vtk
\n
"
;
return
""
;
}
// Create point data properties
v_out
+=
"SCALARS "
+
get_attributes
(
oprp
)
+
" "
+
type
+
"
\n
"
;
...
...
src/VTKWriter_unit_tests.hpp
View file @
13e4a081
...
...
@@ -258,6 +258,7 @@ void fill_grid_some_data(grid_cpu<2,Point_test<float>> & g)
BOOST_AUTO_TEST_CASE
(
vtk_writer_use_grids
)
{
{
// Create box grids
Point
<
2
,
float
>
offset1
({
0.0
,
0.0
});
Point
<
2
,
float
>
spacing1
({
0.1
,
0.2
});
...
...
@@ -304,6 +305,58 @@ BOOST_AUTO_TEST_CASE( vtk_writer_use_grids)
// Check that match
bool
test
=
compare
(
"vtk_grids.vtk"
,
"vtk_grids_test.vtk"
);
BOOST_REQUIRE_EQUAL
(
test
,
true
);
}
{
// Create box grids
Point
<
2
,
float
>
offset1
({
0.0
,
0.0
});
Point
<
2
,
float
>
spacing1
({
0.1
,
0.1
});
Box
<
2
,
size_t
>
d1
({
1
,
2
},{
14
,
15
});
// Create box grids
Point
<
2
,
float
>
offset2
({
0.0
,
0.0
});
Point
<
2
,
float
>
spacing2
({
0.1
,
0.1
});
Box
<
2
,
size_t
>
d2
({
2
,
1
},{
13
,
15
});
// Create box grids
Point
<
2
,
float
>
offset3
({
5.0
,
5.0
});
Point
<
2
,
float
>
spacing3
({
0.1
,
0.1
});
Box
<
2
,
size_t
>
d3
({
3
,
2
},{
11
,
10
});
// Create box grids
Point
<
2
,
float
>
offset4
({
5.0
,
5.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
,
Point_test
<
float
>>
g1
(
sz
);
g1
.
setMemory
();
fill_grid_some_data
(
g1
);
grid_cpu
<
2
,
Point_test
<
float
>>
g2
(
sz
);
g2
.
setMemory
();
fill_grid_some_data
(
g2
);
grid_cpu
<
2
,
Point_test
<
float
>>
g3
(
sz
);
g3
.
setMemory
();
fill_grid_some_data
(
g3
);
grid_cpu
<
2
,
Point_test
<
float
>>
g4
(
sz
);
g4
.
setMemory
();
fill_grid_some_data
(
g4
);
comb
<
2
>
cmb
;
cmb
.
zero
();
comb
<
2
>
cmb2
;
cmb2
.
mone
();
// Create a writer and write
VTKWriter
<
boost
::
mpl
::
pair
<
grid_cpu
<
2
,
Point_test
<
float
>>
,
float
>
,
VECTOR_ST_GRIDS
>
vtk_g
;
vtk_g
.
add
(
0
,
g1
,
offset1
,
spacing1
,
d1
,
cmb
);
vtk_g
.
add
(
0
,
g2
,
offset2
,
spacing2
,
d2
,
cmb
);
vtk_g
.
add
(
1
,
g3
,
offset3
,
spacing3
,
d3
,
cmb
);
vtk_g
.
add
(
1
,
g4
,
offset4
,
spacing4
,
d4
,
cmb2
);
vtk_g
.
write
(
"vtk_grids_st.vtk"
);
}
}
BOOST_AUTO_TEST_SUITE_END
()
...
...
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