5 #ifndef SFCSORTBENCH_TREENODE2VTK_H 6 #define SFCSORTBENCH_TREENODE2VTK_H 17 #define VTK_HEXAHEDRON 12 24 void treeNodesTovtk(std::vector<T>& nodes,
int mpi_rank,std::string vtk_file_name,
bool hsorted=
false);
27 void treeNodesTovtk(std::vector<T> &nodes,
int mpi_rank, std::string vtk_file_name,
bool hsorted) {
30 if (!mpi_rank) std::cout <<
"writing mesh to VTK file: " << vtk_file_name << std::endl;
31 std::ostringstream convert;
33 #ifdef HILBERT_ORDERING 34 convert << vtk_file_name <<
"_H_" << mpi_rank <<
".vtk";
36 convert << vtk_file_name <<
"_M_" << mpi_rank <<
".vtk";
40 vtk_file_name = convert.str();
43 myfile.open(vtk_file_name.c_str());
45 myfile <<
"# vtk DataFile Version 2.0" << std::endl;
46 myfile <<
"DENDRO OCTREES" << std::endl;
47 myfile <<
"ASCII" << std::endl;
48 myfile <<
"DATASET UNSTRUCTURED_GRID" << std::endl;
52 int unit_points = 1 << dim;
53 int num_verticies = nodes.size() * (unit_points);
54 int num_cells = nodes.size();
59 myfile <<
"POINTS " << num_verticies <<
" float" << std::endl;
63 }
else if (dim == 3) {
65 unsigned int xl, yl, zl;
66 int num_data_field = 2;
72 int num_cells_elements = num_cells * unit_points + num_cells;
74 for (
int i = 0; i < nodes.size(); i++) {
76 len = 1 << (nodes[i].getMaxDepth() - nodes[i].getLevel());
81 myfile << xl <<
" " << yl <<
" " << zl << std::endl;
82 myfile << (xl + len) <<
" " << yl <<
" " << zl << std::endl;
83 myfile << (xl + len) <<
" " << (yl + len) <<
" " << zl << std::endl;
84 myfile << xl <<
" " << (yl + len) <<
" " << zl << std::endl;
86 myfile << xl <<
" " << yl <<
" " << (zl + len) << std::endl;
87 myfile << (xl + len) <<
" " << yl <<
" " << (zl + len) << std::endl;
88 myfile << (xl + len) <<
" " << (yl + len) <<
" " << (zl + len) << std::endl;
89 myfile << xl <<
" " << (yl + len) <<
" " << (zl + len) << std::endl;
93 myfile <<
"CELLS " << nodes.size() <<
" " << num_cells_elements << std::endl;
95 for (
int i = 0; i < num_cells; i++) {
96 myfile << unit_points <<
" ";
97 for (
int j = 0; j < unit_points; j++) {
98 myfile << (i * unit_points + j) <<
" ";
103 myfile <<
"CELL_TYPES " << num_cells << std::endl;
104 for (
int i = 0; i < num_cells; i++) {
105 myfile << VTK_HEXAHEDRON << std::endl;
113 myfile <<
"CELL_DATA "<<num_cells<<std::endl;
121 myfile <<
"SCALARS cell_level FLOAT"<< std::endl;
122 myfile <<
"LOOKUP_TABLE default"<<std::endl;
124 for (
int i = 0; i < nodes.size(); i++)
125 myfile << nodes[i].getLevel() <<std::endl;
131 myfile <<
"SCALARS mpi_rank FLOAT"<< std::endl;
132 myfile <<
"LOOKUP_TABLE default"<<std::endl;
133 for (
int i = 0; i < nodes.size(); i++)
134 myfile <<mpi_rank << std::endl;
146 #endif //SFCSORTBENCH_TREENODE2VTK_H