71 if (std::abs (data) < std::numeric_limits<float>::min ())
92 write_asc_float (File, data) <<
' ';
101 File << (float) data[0] << (
float) 0.f << (float) 0.f;
103 write_asc_float (File, data[0]) <<
" 0 0 ";
111 File << (float) data[0] << (
float) data[1] << (float) 0.f;
114 write_asc_float (File, data[0]) <<
' ';
115 write_asc_float (File, data[1]) <<
" 0 ";
124 File << (float) data[0] << (
float) data[1] << (float) data[2];
127 write_asc_float (File, data[0]) <<
' ';
128 write_asc_float (File, data[1]) <<
' ';
129 write_asc_float (File, data[2]) <<
' ';
138 File << (float) data(0,0) << (float) 0.f << (
float) 0.f << (float) 0.f << (
float) 0.f << (float) 0.f << (
float) 0.f << (float) 0.f << (
float) 0.f;
140 write_asc_float (File, data(0,0)) <<
" 0 0 0 0 0 0 0 0 ";
149 File << (float) data(0,0) << (float) data(0,1) << (float) 0.f;
150 File << (float) data(1,0) << (float) data(1,1) << (float) 0.f << (
float) 0.f << (float) 0.f << (
float) 0.f;
154 write_asc_float (File, data(0,0)) <<
' '; write_asc_float (File, data(0,1)) <<
" 0 ";
155 write_asc_float (File, data(1,0)) <<
' '; write_asc_float (File, data(1,1)) <<
" 0 0 0 0 ";
165 File << (float) data(0,0) << (float) data(0,1) << (float) data(0,2);
166 File << (float) data(1,0) << (float) data(1,1) << (float) data(1,2);
167 File << (float) data(2,0) << (float) data(2,1) << (float) data(2,2);
171 write_asc_float (File, data(0,0)) <<
' '; write_asc_float (File, data(0,1)) <<
' '; write_asc_float (File, data(0,2)) <<
' ';
172 write_asc_float (File, data(1,0)) <<
' '; write_asc_float (File, data(1,1)) <<
' '; write_asc_float (File, data(1,2)) <<
' ';
173 write_asc_float (File, data(2,0)) <<
' '; write_asc_float (File, data(2,1)) <<
' '; write_asc_float (File, data(2,2)) <<
' ';
182 template <
typename TFunction>
184 print(
const char* filename, TFunction& u,
int step,
number time,
bool makeConsistent)
190 UG_THROW(
"VTK::print: Cannot change storage type to consistent.");
194 bool bEverywhere =
true;
195 for(
size_t fct = 0; fct < u.num_fct(); ++fct)
198 if(!u.is_def_everywhere(fct))
210 SubsetGroup all_ss (u.domain()->subset_handler ());
212 print_subsets(filename, u, all_ss, step, time, makeConsistent);
219 for(
int si = 0; si < u.num_subsets(); ++si)
223 print_subset(filename, u, si, step, time, makeConsistent);
225 UG_CATCH_THROW(
"VTK::print: Failed to write Subset "<< si <<
".");
230 write_subset_pvd(u.num_subsets(), filename, step, time);
245 template <
typename TFunction>
247 print_subset(
const char* filename, TFunction& u,
int si,
int step,
number time,
bool makeConsistent)
254 UG_THROW(
"VTK::print_subset: Cannot change storage type to consistent.");
258 Grid& grid = *u.domain()->grid();
267 aaVrtIndex.
access(grid, aVrtIndex);
278 vtu_filename(
name, filename, rank, si, u.num_subsets()-1, step);
290 bool bTimeDep = (step >= 0);
297 File <<
"<?xml version=\"1.0\"?>\n";
301 File <<
"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"";
303 else File <<
"BigEndian";
309 File <<
" <Time timestep=\""<<time<<
"\"/>\n";
313 File <<
" <UnstructuredGrid>\n";
322 write_grid_solution_piece(File, aaVrtIndex, grid, u, time, ssg,
dim);
329 if((si >=0) && u.domain()->subset_handler()->template num<Vertex>(si) != 0)
331 UG_THROW(
"VTK::print_subset: Dimension of grid/subset not"
332 " detected correctly although grid objects present.");
335 write_empty_grid_piece(File);
340 File <<
" </UnstructuredGrid>\n";
341 File <<
"</VTKFile>\n";
349 write_pvtu(u, filename, si, step, time);
358 std::vector<number>& vTimestep = m_mTimestep[filename];
361 vTimestep.resize(step+1);
364 vTimestep[step] = time;
368 UG_CATCH_THROW(
"VTK::print_subset: Failed to open file: '" << filename <<
"' for output");
380 template <
typename TFunction>
389 UG_THROW(
"VTK::print_subset: Cannot change storage type to consistent.");
393 Grid& grid = *u.domain()->grid();
400 aaVrtIndex.
access(grid, aVrtIndex);
411 vtu_filename(
name, filename, rank, -1, u.num_subsets()-1, step);
423 bool bTimeDep = (step >= 0);
430 File <<
"<?xml version=\"1.0\"?>\n";
434 File <<
"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"";
436 else File <<
"BigEndian";
442 File <<
" <Time timestep=\""<<time<<
"\"/>\n";
446 File <<
" <UnstructuredGrid>\n";
450 for(
size_t i = 0; i < ssGrp.
size(); i++)
461 write_grid_solution_piece(File, aaVrtIndex, grid, u, time, ssGrp,
dim);
467 UG_THROW(
"VTK::print_subsets: Dimension of grid/subset not"
468 " detected correctly although grid objects present.");
473 File <<
" </UnstructuredGrid>\n";
474 File <<
"</VTKFile>\n";
482 write_pvtu(u, filename, -1, step, time);
491 std::vector<number>& vTimestep = m_mTimestep[filename];
494 vTimestep.resize(step+1);
497 vTimestep[step] = time;
501 UG_CATCH_THROW(
"VTK::print_subset: Failed open file: '" << filename <<
"' for output");
513 template <
typename TFunction>
515 print_subsets(
const char* filename, TFunction& u,
const char* ssNames,
int step,
number time,
bool makeConsistent)
517 std::vector<std::string> v_ss_names;
521 ssGrp.
add (v_ss_names);
522 print_subsets(filename, u, ssGrp, step, time, makeConsistent);
536 template <
typename T>
542 const int numVert,
const int numElem,
const int numConn)
546 write_points<T>(File, aaVrtIndex, aaPos, grid, iterContainer, ssGrp,
dim, numVert);
548 UG_CATCH_THROW(
"VTK::write_points_cells_piece: Failed to write vertices (Points).");
552 write_cells(File, aaVrtIndex, grid, iterContainer, ssGrp,
dim, numElem, numConn);
554 UG_CATCH_THROW(
"VTK::write_points_cells_piece: Failed to write grid elements (Cells).");
561 template <
typename T>
569 int numVert = 0, numElem = 0, numConn = 0;
573 count_piece_sizes(grid, iterContainer, ssGrp,
dim, numVert, numElem, numConn);
580 File <<
" <Piece NumberOfPoints=\""<<numVert<<
581 "\" NumberOfCells=\""<<numElem<<
"\">\n";
584 write_points_cells_piece<T>
585 (File, aaVrtIndex, aaPos, grid, iterContainer, ssGrp,
dim, numVert, numElem, numConn);
589 File <<
" </Piece>\n";
598 template <
typename TFunction>
606 int numVert = 0, numElem = 0, numConn = 0;
610 count_piece_sizes(grid, u, ssGrp,
dim, numVert, numElem, numConn);
617 File <<
" <Piece NumberOfPoints=\""<<numVert<<
618 "\" NumberOfCells=\""<<numElem<<
"\">\n";
621 write_points_cells_piece<TFunction>
622 (File, aaVrtIndex, u.domain()->position_accessor(), grid, u, ssGrp,
dim, numVert, numElem, numConn);
626 for(
size_t fct = 0; fct < u.num_fct(); ++fct){
627 if(!vtk_name_used(u.name(fct).c_str())){
629 select_nodal(u.name(fct).c_str(), u.name(fct).c_str());
631 select_element(u.name(fct).c_str(), u.name(fct).c_str());
638 write_nodal_values_piece(File, u, time, grid, ssGrp,
dim, numVert);
641 write_cell_values_piece(File, u, time, grid, ssGrp,
dim, numElem);
645 File <<
" </Piece>\n";
653 template <
typename TElem,
typename T>
656 int& numVert,
int& numElem,
int& numConn)
663 static const int numCo = ref_elem_type::numCorners;
671 for( ; iterBegin != iterEnd; ++iterBegin)
674 TElem *elem = *iterBegin;
691 for(
int i = 0; i < numCo; ++i)
711 template <
typename T>
714 int& numVert,
int& numElem,
int& numConn)
716 numVert = numElem = numConn = 0;
721 for(
size_t i = 0; i < ssGrp.
size(); i++)
723 const int si = ssGrp[i];
726 case 0: count_sizes<Vertex, T>(grid, iterContainer, si, numVert, numElem, numConn);
break;
727 case 1: count_sizes<RegularEdge, T>(grid, iterContainer, si, numVert, numElem, numConn);
728 count_sizes<ConstrainingEdge, T>(grid, iterContainer, si, numVert, numElem, numConn);
break;
729 case 2: count_sizes<Triangle, T>(grid, iterContainer, si, numVert, numElem, numConn);
730 count_sizes<Quadrilateral, T>(grid, iterContainer, si, numVert, numElem, numConn);
731 count_sizes<ConstrainingTriangle, T>(grid, iterContainer, si, numVert, numElem, numConn);
732 count_sizes<ConstrainingQuadrilateral, T>(grid, iterContainer, si, numVert, numElem, numConn);
break;
733 case 3: count_sizes<Tetrahedron, T>(grid, iterContainer, si, numVert, numElem, numConn);
734 count_sizes<Pyramid, T>(grid, iterContainer, si, numVert, numElem, numConn);
735 count_sizes<Prism, T>(grid, iterContainer, si, numVert, numElem, numConn);
736 count_sizes<Octahedron, T>(grid, iterContainer, si, numVert, numElem, numConn);
737 count_sizes<Hexahedron, T>(grid, iterContainer, si, numVert, numElem, numConn);
break;
738 default:
UG_THROW(
"VTK::count_piece_sizes: Dimension " <<
dim <<
739 " is not supported.");
758 template <
typename TElem,
typename T>
763 Grid& grid,
const T& iterContainer,
const int si,
int& n)
778 for( ; iterBegin != iterEnd; ++iterBegin)
781 TElem *elem = *iterBegin;
784 for(
size_t i = 0; i < (size_t) ref_elem_type::numCorners; ++i)
799 write_item_to_file(File, aaPos[v]);
809 template <
typename T>
823 File <<
" <Points>\n";
824 File <<
" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format="
825 << (m_bBinary ?
"\"binary\"" :
"\"ascii\"") <<
">\n";
826 int n = 3*
sizeof(float) * numVert;
838 for(
size_t i = 0; i < ssGrp.
size(); i++){
840 case 0: write_points_elementwise<Vertex,T>(File, aaVrtIndex, aaPos, grid, iterContainer, ssGrp[i], n);
break;
841 case 1: write_points_elementwise<RegularEdge,T>(File, aaVrtIndex, aaPos, grid, iterContainer, ssGrp[i], n);
842 write_points_elementwise<ConstrainingEdge,T>(File, aaVrtIndex, aaPos, grid, iterContainer, ssGrp[i], n);
break;
843 case 2: write_points_elementwise<Triangle,T>(File, aaVrtIndex, aaPos, grid, iterContainer, ssGrp[i], n);
844 write_points_elementwise<Quadrilateral,T>(File, aaVrtIndex, aaPos, grid, iterContainer, ssGrp[i], n);
845 write_points_elementwise<ConstrainingTriangle,T>(File, aaVrtIndex, aaPos, grid, iterContainer, ssGrp[i], n);
846 write_points_elementwise<ConstrainingQuadrilateral,T>(File, aaVrtIndex, aaPos, grid, iterContainer, ssGrp[i], n);
break;
847 case 3: write_points_elementwise<Tetrahedron,T>(File, aaVrtIndex, aaPos, grid, iterContainer, ssGrp[i], n);
848 write_points_elementwise<Pyramid,T>(File, aaVrtIndex, aaPos, grid, iterContainer, ssGrp[i], n);
849 write_points_elementwise<Prism,T>(File, aaVrtIndex, aaPos, grid, iterContainer, ssGrp[i], n);
850 write_points_elementwise<Octahedron,T>(File, aaVrtIndex, aaPos, grid, iterContainer, ssGrp[i], n);
851 write_points_elementwise<Hexahedron,T>(File, aaVrtIndex, aaPos, grid, iterContainer, ssGrp[i], n);
break;
852 default:
UG_THROW(
"VTK::write_points: Dimension " <<
dim <<
853 " is not supported.");
862 File <<
"\n </DataArray>\n";
863 File <<
" </Points>\n";
875 File <<
" <RegionInfo Name=\"regions\">\n";
877 File <<
" <Region Name=\"" << sh.
get_subset_name(i) <<
"\"></Region>\n";
879 File <<
" </RegionInfo>\n";
886 template <
typename T>
891 const int numElem,
const int numConn)
896 File <<
" <Cells>\n";
899 write_cell_connectivity(File, aaVrtIndex, grid, iterContainer, ssGrp,
dim, numConn);
902 write_cell_offsets(File, iterContainer, ssGrp,
dim, numElem);
905 write_cell_types(File, iterContainer, ssGrp,
dim, numElem);
909 File <<
" </Cells>\n";
918 template <
class TElem,
typename T>
922 Grid& grid,
const T& iterContainer,
const int si)
942 for( ; iterBegin != iterEnd; iterBegin++)
945 TElem* elem = *iterBegin;
950 for(
size_t i=0; i< (size_t) ref_elem_type::numCorners; i++)
952 Vertex* vert = elem->vertex(i);
953 int id = aaVrtIndex[vert];
961 int id = aaVrtIndex[elem->vertex(0)]; File << id;
962 if(!m_bBinary) File <<
' ';
963 id = aaVrtIndex[elem->vertex(2)]; File << id;
964 if(!m_bBinary) File <<
' ';
965 id = aaVrtIndex[elem->vertex(1)]; File << id;
966 if(!m_bBinary) File <<
' ';
967 id = aaVrtIndex[elem->vertex(3)]; File << id;
968 if(!m_bBinary) File <<
' ';
969 id = aaVrtIndex[elem->vertex(5)]; File << id;
970 if(!m_bBinary) File <<
' ';
971 id = aaVrtIndex[elem->vertex(4)]; File << id;
972 if(!m_bBinary) File <<
' ';
978 int id = aaVrtIndex[elem->vertex(1)]; File << id;
979 if(!m_bBinary) File <<
' ';
980 id = aaVrtIndex[elem->vertex(2)]; File << id;
981 if(!m_bBinary) File <<
' ';
982 id = aaVrtIndex[elem->vertex(3)]; File << id;
983 if(!m_bBinary) File <<
' ';
984 id = aaVrtIndex[elem->vertex(4)]; File << id;
985 if(!m_bBinary) File <<
' ';
986 id = aaVrtIndex[elem->vertex(5)]; File << id;
987 if(!m_bBinary) File <<
' ';
990 id = aaVrtIndex[elem->vertex(1)]; File << id;
991 if(!m_bBinary) File <<
' ';
992 id = aaVrtIndex[elem->vertex(2)]; File << id;
993 if(!m_bBinary) File <<
' ';
994 id = aaVrtIndex[elem->vertex(3)]; File << id;
995 if(!m_bBinary) File <<
' ';
996 id = aaVrtIndex[elem->vertex(4)]; File << id;
997 if(!m_bBinary) File <<
' ';
998 id = aaVrtIndex[elem->vertex(0)]; File << id;
999 if(!m_bBinary) File <<
' ';
1009 template <
typename T>
1014 const int dim,
const int numConn)
1018 File <<
" <DataArray type=\"Int32\" Name=\"connectivity\" format="
1019 << (m_bBinary ?
"\"binary\"":
"\"ascii\"") <<
">\n";
1020 int n =
sizeof(int) * numConn;
1026 for(
size_t i = 0; i < ssGrp.
size(); i++){
1030 case 1: write_cell_connectivity<RegularEdge,T>(File, aaVrtIndex, grid, iterContainer, ssGrp[i]);
1031 write_cell_connectivity<ConstrainingEdge,T>(File, aaVrtIndex, grid, iterContainer, ssGrp[i]);
break;
1032 case 2: write_cell_connectivity<Triangle,T>(File, aaVrtIndex, grid, iterContainer, ssGrp[i]);
1033 write_cell_connectivity<Quadrilateral,T>(File, aaVrtIndex, grid, iterContainer, ssGrp[i]);
1034 write_cell_connectivity<ConstrainingTriangle,T>(File, aaVrtIndex, grid, iterContainer, ssGrp[i]);
1035 write_cell_connectivity<ConstrainingQuadrilateral,T>(File, aaVrtIndex, grid, iterContainer, ssGrp[i]);
break;
1036 case 3: write_cell_connectivity<Tetrahedron,T>(File, aaVrtIndex, grid, iterContainer, ssGrp[i]);
1037 write_cell_connectivity<Pyramid,T>(File, aaVrtIndex, grid, iterContainer, ssGrp[i]);
1038 write_cell_connectivity<Prism,T>(File, aaVrtIndex, grid, iterContainer, ssGrp[i]);
1039 write_cell_connectivity<Octahedron,T>(File, aaVrtIndex, grid, iterContainer, ssGrp[i]);
1040 write_cell_connectivity<Hexahedron,T>(File, aaVrtIndex, grid, iterContainer, ssGrp[i]);
break;
1041 default:
UG_THROW(
"VTK::write_cell_connectivity: Dimension " <<
dim <<
1042 " is not supported.");
1048 File <<
"\n </DataArray>\n";
1057 template <
class TElem,
typename T>
1076 for( ; iterBegin != iterEnd; ++iterBegin)
1082 n += ref_elem_type::numCorners;
1114 template <
typename T>
1117 const int dim,
const int numElem)
1121 File <<
" <DataArray type=\"Int32\" Name=\"offsets\" format="
1122 << (m_bBinary ?
"\"binary\"":
"\"ascii\"") <<
">\n";
1123 int n =
sizeof(int) * numElem;
1130 for(
size_t i = 0; i < ssGrp.
size(); i++){
1134 case 1: write_cell_offsets<RegularEdge,T>(File, iterContainer, ssGrp[i], n);
1135 write_cell_offsets<ConstrainingEdge,T>(File, iterContainer, ssGrp[i], n);
break;
1136 case 2: write_cell_offsets<Triangle,T>(File, iterContainer, ssGrp[i], n);
1137 write_cell_offsets<Quadrilateral,T>(File, iterContainer, ssGrp[i], n);
1138 write_cell_offsets<ConstrainingTriangle,T>(File, iterContainer, ssGrp[i], n);
1139 write_cell_offsets<ConstrainingQuadrilateral,T>(File, iterContainer, ssGrp[i], n);
break;
1140 case 3: write_cell_offsets<Tetrahedron,T>(File, iterContainer, ssGrp[i], n);
1141 write_cell_offsets<Pyramid,T>(File, iterContainer, ssGrp[i], n);
1142 write_cell_offsets<Prism,T>(File, iterContainer, ssGrp[i], n);
1143 write_cell_offsets<Octahedron,T>(File, iterContainer, ssGrp[i], n);
1144 write_cell_offsets<Hexahedron,T>(File, iterContainer, ssGrp[i], n);
break;
1145 default:
UG_THROW(
"VTK::write_cell_offsets: Dimension " <<
dim <<
1146 " is not supported.");
1152 File <<
"\n </DataArray>\n";
1161 template <
class TElem,
typename T>
1185 default:
UG_THROW(
"Element Type not known.");
1198 for( ; iterBegin != iterEnd; ++iterBegin)
1206 File << (int) type <<
' ';
1217 File << (int) type <<
' ';
1218 File << (int) type <<
' ';
1229 template <
typename T>
1232 const int dim,
int numElem)
1236 File <<
" <DataArray type=\"Int8\" Name=\"types\" format="
1237 << (m_bBinary ?
"\"binary\"":
"\"ascii\"") <<
">\n";
1243 for(
size_t i = 0; i < ssGrp.
size(); i++)
1248 case 1: write_cell_types<RegularEdge>(File, iterContainer, ssGrp[i]);
1249 write_cell_types<ConstrainingEdge>(File, iterContainer, ssGrp[i]);
break;
1250 case 2: write_cell_types<Triangle>(File, iterContainer, ssGrp[i]);
1251 write_cell_types<Quadrilateral>(File, iterContainer, ssGrp[i]);
1252 write_cell_types<ConstrainingTriangle>(File, iterContainer, ssGrp[i]);
1253 write_cell_types<ConstrainingQuadrilateral>(File, iterContainer, ssGrp[i]);
break;
1254 case 3: write_cell_types<Tetrahedron>(File, iterContainer, ssGrp[i]);
1255 write_cell_types<Pyramid>(File, iterContainer, ssGrp[i]);
1256 write_cell_types<Prism>(File, iterContainer, ssGrp[i]);
1257 write_cell_types<Octahedron>(File, iterContainer, ssGrp[i]);
1258 write_cell_types<Hexahedron>(File, iterContainer, ssGrp[i]);
break;
1259 default:
UG_THROW(
"VTK::write_cell_types: Dimension " <<
dim <<
1260 " is not supported.");
1266 File <<
"\n </DataArray>\n";
1275 template <
class TElem,
typename T>
1292 for( ; iterBegin != iterEnd; ++iterBegin)
1298 File << (char) subset <<
' ';
1301 File << subset <<
' ';
1311 template <
typename T>
1318 File <<
" <DataArray type=\"Int8\" Name=\"regions\" format="
1319 << (m_bBinary ?
"\"binary\"":
"\"ascii\"") <<
">\n";
1325 for(
size_t i = 0; i < ssGrp.
size(); i++)
1330 case 1: write_cell_subsets<RegularEdge>(File, iterContainer, ssGrp[i], sh);
1331 write_cell_subsets<ConstrainingEdge>(File, iterContainer, ssGrp[i], sh);
break;
1332 case 2: write_cell_subsets<Triangle>(File, iterContainer, ssGrp[i], sh);
1333 write_cell_subsets<Quadrilateral>(File, iterContainer, ssGrp[i], sh);
1334 write_cell_subsets<ConstrainingTriangle>(File, iterContainer, ssGrp[i], sh);
1335 write_cell_subsets<ConstrainingQuadrilateral>(File, iterContainer, ssGrp[i], sh);
break;
1336 case 3: write_cell_subsets<Tetrahedron>(File, iterContainer, ssGrp[i], sh);
1337 write_cell_subsets<Pyramid>(File, iterContainer, ssGrp[i], sh);
1338 write_cell_subsets<Prism>(File, iterContainer, ssGrp[i], sh);
1339 write_cell_subsets<Octahedron>(File, iterContainer, ssGrp[i], sh);
1340 write_cell_subsets<Hexahedron>(File, iterContainer, ssGrp[i], sh);
break;
1341 default:
UG_THROW(
"VTK::write_cell_subsets: Dimension " <<
dim <<
1342 " is not supported.");
1348 File <<
"\n </DataArray>\n";
1357 template <
class TElem,
typename T>
1378 for( ; iterBegin != iterEnd; ++iterBegin)
1382 File << (char) rank <<
' ';
1385 File << rank <<
' ';
1394 template <
typename T>
1401 File <<
" <DataArray type=\"Int8\" Name=\"proc_ranks\" format="
1402 << (m_bBinary ?
"\"binary\"":
"\"ascii\"") <<
">\n";
1408 for(
size_t i = 0; i < ssGrp.
size(); i++)
1413 case 1: write_cell_proc_ranks<RegularEdge>(File, iterContainer, ssGrp[i], sh);
1414 write_cell_proc_ranks<ConstrainingEdge>(File, iterContainer, ssGrp[i], sh);
break;
1415 case 2: write_cell_proc_ranks<Triangle>(File, iterContainer, ssGrp[i], sh);
1416 write_cell_proc_ranks<Quadrilateral>(File, iterContainer, ssGrp[i], sh);
1417 write_cell_proc_ranks<ConstrainingTriangle>(File, iterContainer, ssGrp[i], sh);
1418 write_cell_proc_ranks<ConstrainingQuadrilateral>(File, iterContainer, ssGrp[i], sh);
break;
1419 case 3: write_cell_proc_ranks<Tetrahedron>(File, iterContainer, ssGrp[i], sh);
1420 write_cell_proc_ranks<Pyramid>(File, iterContainer, ssGrp[i], sh);
1421 write_cell_proc_ranks<Prism>(File, iterContainer, ssGrp[i], sh);
1422 write_cell_proc_ranks<Octahedron>(File, iterContainer, ssGrp[i], sh);
1423 write_cell_proc_ranks<Hexahedron>(File, iterContainer, ssGrp[i], sh);
break;
1424 default:
UG_THROW(
"VTK::write_cell_proc_ranks: Dimension " <<
dim <<
1425 " is not supported.");
1431 File <<
"\n </DataArray>\n";
1439 template <
typename TElem,
typename TFunction,
typename TData>
1443 Grid& grid,
const int si)
1449 static const size_t numCo = ref_elem_type::numCorners;
1461 std::vector<MathVector<TDim> > vCorner(numCo);
1463 TData vValue[numCo];
1464 bool bNeedFct = spData->requires_grid_fct();
1467 for( ; iterBegin != iterEnd; ++iterBegin)
1470 TElem *elem = *iterBegin;
1477 if(si < 0) theSI = u.domain()->subset_handler()->get_subset_index(elem);
1487 u.indices(elem, ind);
1497 (*spData)(vValue, &vCorner[0], time, theSI, elem,
1498 &vCorner[0], refElem.corners(), numCo, &locU, NULL);
1500 UG_CATCH_THROW(
"VTK::write_nodal_data_elementwise: Cannot evaluate data.");
1506 (*spData)(vValue, &vCorner[0], time, theSI, numCo);
1508 UG_CATCH_THROW(
"VTK::write_nodal_data_elementwise: Cannot evaluate data.");
1512 for(
size_t co = 0; co < numCo; ++co)
1524 write_item_to_file(File, vValue[co]);
1534 template <
typename TFunction,
typename TData>
1539 const std::string&
name,
1542 spData->set_function_pattern(u.function_pattern());
1545 if(!spData->continuous())
1546 UG_THROW(
"VTK: data with name '"<<
name<<
"' is scheduled for nodal output,"
1547 " but the data is not continuous. Cannot write it as nodal data.")
1551 File <<
" <DataArray type=\"Float32\" Name=\""<<
name<<
"\" "
1552 "NumberOfComponents=\""<<numCmp<<
"\" format="
1553 << (m_bBinary ?
"\"binary\"":
"\"ascii\"") <<
">\n";
1555 int n =
sizeof(float) * numVert * numCmp;
1563 for(
size_t i = 0; i < ssGrp.
size(); i++)
1566 case 1: write_nodal_data_elementwise<RegularEdge,TFunction,TData>(File, u, time, spData, grid, ssGrp[i]);
1567 write_nodal_data_elementwise<ConstrainingEdge,TFunction,TData>(File, u, time, spData, grid, ssGrp[i]);
break;
1568 case 2: write_nodal_data_elementwise<Triangle,TFunction,TData>(File, u, time, spData, grid, ssGrp[i]);
1569 write_nodal_data_elementwise<Quadrilateral,TFunction,TData>(File, u, time, spData, grid, ssGrp[i]);
1570 write_nodal_data_elementwise<ConstrainingTriangle,TFunction,TData>(File, u, time, spData, grid, ssGrp[i]);
1571 write_nodal_data_elementwise<ConstrainingQuadrilateral,TFunction,TData>(File, u, time, spData, grid, ssGrp[i]);
break;
1572 case 3: write_nodal_data_elementwise<Tetrahedron,TFunction,TData>(File, u, time, spData, grid, ssGrp[i]);
1573 write_nodal_data_elementwise<Pyramid,TFunction,TData>(File, u, time, spData, grid, ssGrp[i]);
1574 write_nodal_data_elementwise<Prism,TFunction,TData>(File, u, time, spData, grid, ssGrp[i]);
1575 write_nodal_data_elementwise<Octahedron,TFunction,TData>(File, u, time, spData, grid, ssGrp[i]);
1576 write_nodal_data_elementwise<Hexahedron,TFunction,TData>(File, u, time, spData, grid, ssGrp[i]);
break;
1577 default:
UG_THROW(
"VTK::write_nodal_data: Dimension " <<
dim <<
1578 " is not supported.");
1586 File <<
"\n </DataArray>\n";
1591 template <
typename TElem,
typename TFunction>
1594 const std::vector<size_t>& vFct,
1595 Grid& grid,
const int si)
1606 std::vector<DoFIndex> vMultInd;
1614 for( ; iterBegin != iterEnd; ++iterBegin)
1617 TElem *elem = *iterBegin;
1620 for(
size_t co = 0; co < (size_t) ref_elem_type::numCorners; ++co)
1632 for(
size_t i = 0; i < vFct.size(); ++i)
1635 if(u.inner_dof_indices(v, vFct[i], vMultInd) != 1)
1636 UG_THROW(
"VTK:write_nodal_values_elementwise: "
1637 "The function component "<<vFct[i]<<
" has "<<
1638 vMultInd.size()<<
" DoFs in a vertex of an element of subset "
1639 <<si<<
". To write a component to vtk, exactly "
1640 "one DoF must be given in any vertex.");
1643 write_item_to_file(File,
DoFRef(u, vMultInd[0]));
1649 if(vFct.size() != 1) {
1650 for(
size_t i = vFct.size(); i < 3; ++i) {
1651 write_item_to_file(File, 0.f);
1660 template <
typename TFunction>
1663 const std::vector<size_t>& vFct,
const std::string&
name,
1668 File <<
" <DataArray type=\"Float32\" Name=\""<<
name<<
"\" "
1669 "NumberOfComponents=\""<<(vFct.size() == 1 ? 1 : 3)<<
"\" format="
1670 << (m_bBinary ?
"\"binary\"":
"\"ascii\"") <<
">\n";
1672 int n =
sizeof(float) * numVert * (vFct.size() == 1 ? 1 : 3);
1680 for(
size_t i = 0; i < ssGrp.
size(); i++)
1683 case 0: write_nodal_values_elementwise<Vertex>(File, u, vFct, grid, ssGrp[i]);
break;
1684 case 1: write_nodal_values_elementwise<RegularEdge>(File, u, vFct, grid, ssGrp[i]);
1685 write_nodal_values_elementwise<ConstrainingEdge>(File, u, vFct, grid, ssGrp[i]);
break;
1686 case 2: write_nodal_values_elementwise<Triangle>(File, u, vFct, grid, ssGrp[i]);
1687 write_nodal_values_elementwise<Quadrilateral>(File, u, vFct, grid, ssGrp[i]);
1688 write_nodal_values_elementwise<ConstrainingTriangle>(File, u, vFct, grid, ssGrp[i]);
1689 write_nodal_values_elementwise<ConstrainingQuadrilateral>(File, u, vFct, grid, ssGrp[i]);
break;
1690 case 3: write_nodal_values_elementwise<Tetrahedron>(File, u, vFct, grid, ssGrp[i]);
1691 write_nodal_values_elementwise<Pyramid>(File, u, vFct, grid, ssGrp[i]);
1692 write_nodal_values_elementwise<Prism>(File, u, vFct, grid, ssGrp[i]);
1693 write_nodal_values_elementwise<Octahedron>(File, u, vFct, grid, ssGrp[i]);
1694 write_nodal_values_elementwise<Hexahedron>(File, u, vFct, grid, ssGrp[i]);
break;
1695 default:
UG_THROW(
"VTK::write_nodal_values: Dimension " <<
dim <<
1696 " is not supported.");
1704 File <<
"\n </DataArray>\n";
1708 template <
typename TFunction>
1713 if(!m_vSymbFct.empty()){
1714 for(std::map<std::string, std::vector<std::string> >::const_iterator iter =
1715 m_vSymbFct.begin(); iter != m_vSymbFct.end(); ++iter){
1716 const std::vector<std::string>& symbNames = (*iter).second;
1717 const std::string& vtkName = (*iter).first;
1719 bool bContinuous =
true;
1720 for(
size_t i = 0; i < symbNames.size(); ++i){
1721 size_t fct = u.fct_id_by_name(symbNames[i].c_str());
1723 bContinuous =
false;
break;
1728 m_vSymbFctNodal[vtkName] = symbNames;
1734 if(m_vSymbFctNodal.empty() && m_vScalarNodalData.empty() && m_vVectorNodalData.empty())
1739 File <<
" <PointData>\n";
1742 for(std::map<std::string, std::vector<std::string> >::const_iterator iter =
1743 m_vSymbFctNodal.begin(); iter != m_vSymbFctNodal.end(); ++iter)
1746 const std::vector<std::string>& symbNames = (*iter).second;
1747 const std::string& vtkName = (*iter).first;
1750 std::vector<size_t> fctGrp(symbNames.size());
1751 for(
size_t i = 0; i < symbNames.size(); ++i)
1752 fctGrp[i] = u.fct_id_by_name(symbNames[i].c_str());
1755 bool bContained =
true;
1756 for(
size_t i = 0; i < fctGrp.size(); ++i)
1757 for (
size_t j = 0; j < ssGrp.
size(); ++j)
1758 if(!u.is_def_in_subset(fctGrp[i], ssGrp[j]))
1761 if(!bContained)
continue;
1765 write_nodal_values(File, u, fctGrp, vtkName, grid, ssGrp,
dim, numVert);
1772 iter != m_vScalarNodalData.end(); ++iter)
1776 const std::string& vtkName = (*iter).first;
1780 write_nodal_data<TFunction,number>
1781 (File, u, time, spData, 1, vtkName, grid, ssGrp,
dim, numVert);
1783 UG_CATCH_THROW(
"VTK::write_piece: Failed write nodal scalar Data.");
1788 iter != m_vVectorNodalData.end(); ++iter)
1792 const std::string& vtkName = (*iter).first;
1796 write_nodal_data<TFunction,MathVector<TDim> >
1797 (File, u, time, spData, 3, vtkName, grid, ssGrp,
dim, numVert);
1799 UG_CATCH_THROW(
"VTK::write_piece: Failed write nodal vector Data.");
1804 iter != m_vMatrixNodalData.end(); ++iter)
1808 const std::string& vtkName = (*iter).first;
1812 write_nodal_data<TFunction,MathMatrix<TDim,TDim> >
1813 (File, u, time, spData, 9, vtkName, grid, ssGrp,
dim, numVert);
1815 UG_CATCH_THROW(
"VTK::write_piece: Failed write nodal matrix Data.");
1820 File <<
" </PointData>\n";
1829 template <
typename TElem,
typename TFunction,
typename TData>
1833 Grid& grid,
const int si)
1840 static const size_t numCo = ref_elem_type::numCorners;
1856 std::vector<MathVector<TDim> > vCorner(numCo);
1859 bool bNeedFct = spData->requires_grid_fct();
1862 for( ; iterBegin != iterEnd; ++iterBegin)
1865 TElem *elem = *iterBegin;
1875 if(si < 0) theSI = u.domain()->subset_handler()->get_subset_index(elem);
1885 u.indices(elem, ind);
1895 (*spData)(value, globIP, time, theSI, elem,
1896 &vCorner[0], localIP, &locU);
1898 UG_CATCH_THROW(
"VTK::write_cell_data_elementwise: Cannot evaluate data.");
1904 (*spData)(value, globIP, time, theSI);
1906 UG_CATCH_THROW(
"VTK::write_cell_data_elementwise: Cannot evaluate data.");
1912 write_item_to_file(File, value);
1916 write_item_to_file(File, value);
1917 write_item_to_file(File, value);
1925 template <
typename TFunction,
typename TData>
1930 const std::string&
name,
1933 spData->set_function_pattern(u.function_pattern());
1937 File <<
" <DataArray type=\"Float32\" Name=\""<<
name<<
"\" "
1938 "NumberOfComponents=\""<<numCmp<<
"\" format="
1939 << (m_bBinary ?
"\"binary\"":
"\"ascii\"") <<
">\n";
1941 int n =
sizeof(float) * numElem * numCmp;
1946 for(
size_t i = 0; i < ssGrp.
size(); i++)
1949 case 1: write_cell_data_elementwise<RegularEdge,TFunction,TData>(File, u, time, spData, grid, ssGrp[i]);
1950 write_cell_data_elementwise<ConstrainingEdge,TFunction,TData>(File, u, time, spData, grid, ssGrp[i]);
break;
1951 case 2: write_cell_data_elementwise<Triangle,TFunction,TData>(File, u, time, spData, grid, ssGrp[i]);
1952 write_cell_data_elementwise<Quadrilateral,TFunction,TData>(File, u, time, spData, grid, ssGrp[i]);
1953 write_cell_data_elementwise<ConstrainingTriangle,TFunction,TData>(File, u, time, spData, grid, ssGrp[i]);
1954 write_cell_data_elementwise<ConstrainingQuadrilateral,TFunction,TData>(File, u, time, spData, grid, ssGrp[i]);
break;
1955 case 3: write_cell_data_elementwise<Tetrahedron,TFunction,TData>(File, u, time, spData, grid, ssGrp[i]);
1956 write_cell_data_elementwise<Pyramid,TFunction,TData>(File, u, time, spData, grid, ssGrp[i]);
1957 write_cell_data_elementwise<Prism,TFunction,TData>(File, u, time, spData, grid, ssGrp[i]);
1958 write_cell_data_elementwise<Octahedron,TFunction,TData>(File, u, time, spData, grid, ssGrp[i]);
1959 write_cell_data_elementwise<Hexahedron,TFunction,TData>(File, u, time, spData, grid, ssGrp[i]);
break;
1960 default:
UG_THROW(
"VTK::write_cell_data: Dimension " <<
dim <<
1961 " is not supported.");
1966 File <<
"\n </DataArray>\n";
1971 template <
typename TElem,
typename TFunction>
1974 const std::vector<size_t>& vFct,
1975 Grid& grid,
const int si)
1984 static const size_t numCo = ref_elem_type::numCorners;
1987 std::vector<DoFIndex> vMultInd;
2006 if(iterBegin == iterEnd)
return;
2008 std::vector<std::vector<number> > vvShape(vFct.size());
2009 std::vector<size_t> vNsh(vFct.size());
2011 for(
size_t f = 0; f < vFct.size(); ++f)
2013 const LFEID lfeID = u.local_finite_element_id(vFct[f]);
2015 = LocalFiniteElementProvider::get<dim>(roid, lfeID);
2018 lsfs.
shapes(vvShape[f], localIP);
2022 for( ; iterBegin != iterEnd; ++iterBegin)
2025 TElem *elem = *iterBegin;
2028 for(
size_t f = 0; f < vFct.size(); ++f)
2031 if(u.dof_indices(elem, vFct[f], vMultInd) != vNsh[f])
2032 UG_THROW(
"VTK:write_cell_values_elementwise: "
2033 "Number of shape functions for component "<<vFct[f]<<
2034 " does not match number of DoFs");
2037 for(
size_t sh = 0; sh < vNsh[f]; ++sh)
2039 ipVal +=
DoFRef(u, vMultInd[sh]) * vvShape[f][sh];
2043 write_item_to_file(File, ipVal);
2047 write_item_to_file(File, ipVal);
2051 if(vFct.size() != 1){
2052 for(
size_t i = vFct.size(); i < 3; ++i) {
2053 write_item_to_file(File, 0.f);
2057 write_item_to_file(File, 0.f);
2067 template <
typename TFunction>
2070 const std::vector<size_t>& vFct,
const std::string&
name,
2075 File <<
" <DataArray type=\"Float32\" Name=\""<<
name<<
"\" "
2076 "NumberOfComponents=\""<<(vFct.size() == 1 ? 1 : 3)<<
"\" format="
2077 << (m_bBinary ?
"\"binary\"":
"\"ascii\"") <<
">\n";
2079 int n =
sizeof(float) * numElem * (vFct.size() == 1 ? 1 : 3);
2084 for(
size_t i = 0; i < ssGrp.
size(); i++)
2087 case 1: write_cell_values_elementwise<RegularEdge>(File, u, vFct, grid, ssGrp[i]);
2088 write_cell_values_elementwise<ConstrainingEdge>(File, u, vFct, grid, ssGrp[i]);
break;
2089 case 2: write_cell_values_elementwise<Triangle>(File, u, vFct, grid, ssGrp[i]);
2090 write_cell_values_elementwise<Quadrilateral>(File, u, vFct, grid, ssGrp[i]);
2091 write_cell_values_elementwise<ConstrainingTriangle>(File, u, vFct, grid, ssGrp[i]);
2092 write_cell_values_elementwise<ConstrainingQuadrilateral>(File, u, vFct, grid, ssGrp[i]);
break;
2093 case 3: write_cell_values_elementwise<Tetrahedron>(File, u, vFct, grid, ssGrp[i]);
2094 write_cell_values_elementwise<Pyramid>(File, u, vFct, grid, ssGrp[i]);
2095 write_cell_values_elementwise<Prism>(File, u, vFct, grid, ssGrp[i]);
2096 write_cell_values_elementwise<Octahedron>(File, u, vFct, grid, ssGrp[i]);
2097 write_cell_values_elementwise<Hexahedron>(File, u, vFct, grid, ssGrp[i]);
break;
2098 default:
UG_THROW(
"VTK::write_cell_values: Dimension " <<
dim <<
2099 " is not supported.");
2104 File <<
"\n </DataArray>\n";
2108 template <
typename TFunction>
2113 if(!m_vSymbFct.empty()){
2114 for(std::map<std::string, std::vector<std::string> >::const_iterator iter =
2115 m_vSymbFct.begin(); iter != m_vSymbFct.end(); ++iter){
2116 const std::vector<std::string>& symbNames = (*iter).second;
2117 const std::string& vtkName = (*iter).first;
2119 bool bContinuous =
true;
2120 for(
size_t i = 0; i < symbNames.size(); ++i){
2121 size_t fct = u.fct_id_by_name(symbNames[i].c_str());
2123 bContinuous =
false;
break;
2128 m_vSymbFctElem[vtkName] = symbNames;
2134 if(m_vSymbFctElem.empty() && m_vScalarElemData.empty() && m_vVectorElemData.empty())
2139 File <<
" <CellData>\n";
2143 iter != m_vSymbFctElem.end(); ++iter)
2146 const std::vector<std::string>& symbNames = (*iter).second;
2147 const std::string& vtkName = (*iter).first;
2150 std::vector<size_t> fctGrp(symbNames.size());
2151 for(
size_t i = 0; i < symbNames.size(); ++i)
2152 fctGrp[i] = u.fct_id_by_name(symbNames[i].c_str());
2155 bool bContained =
true;
2156 for(
size_t i = 0; i < fctGrp.size(); ++i)
2157 for(
size_t j = 0; j < ssGrp.
size(); ++j)
2158 if(!u.is_def_in_subset(fctGrp[i], ssGrp[j]))
2161 if(!bContained)
continue;
2165 write_cell_values(File, u, fctGrp, vtkName, grid, ssGrp,
dim, numElem);
2172 iter != m_vScalarElemData.end(); ++iter)
2176 const std::string& vtkName = (*iter).first;
2180 write_cell_data<TFunction,number>
2181 (File, u, time, spData, 1, vtkName, grid, ssGrp,
dim, numElem);
2183 UG_CATCH_THROW(
"VTK::write_piece: Failed to write cell scalar Data.");
2188 iter != m_vVectorElemData.end(); ++iter)
2192 const std::string& vtkName = (*iter).first;
2196 write_cell_data<TFunction,MathVector<TDim> >
2197 (File, u, time, spData, 3, vtkName, grid, ssGrp,
dim, numElem);
2199 UG_CATCH_THROW(
"VTK::write_piece: Failed to write cell vector Data.");
2204 iter != m_vMatrixElemData.end(); ++iter)
2208 const std::string& vtkName = (*iter).first;
2212 write_cell_data<TFunction,MathMatrix<TDim,TDim> >
2213 (File, u, time, spData, 9, vtkName, grid, ssGrp,
dim, numElem);
2215 UG_CATCH_THROW(
"VTK::write_piece: Failed to write cell matrix Data.");
2220 File <<
" </CellData>\n";
2228 template <
typename TFunction>
2230 write_pvtu(TFunction& u,
const std::string& filename,
2231 int si,
int step,
number time)
2242 if(numProcs == 1)
return;
2248 int maxSi = u.num_subsets() - 1;
2254 pvtu_filename(
name, filename, si, maxSi, step);
2257 file = fopen(
name.c_str(),
"w");
2259 UG_THROW(
"VTKOutput: Cannot print to file.");
2262 fprintf(file,
"<?xml version=\"1.0\"?>\n");
2265 write_comment_printf(file);
2267 fprintf(file,
"<VTKFile type=\"PUnstructuredGrid\" version=\"0.1\">\n");
2268 fprintf(file,
" <Time timestep=\"%.17g\"/>\n", time);
2269 fprintf(file,
" <PUnstructuredGrid GhostLevel=\"0\">\n");
2270 fprintf(file,
" <PPoints>\n");
2271 fprintf(file,
" <PDataArray type=\"Float32\" NumberOfComponents=\"3\"/>\n");
2272 fprintf(file,
" </PPoints>\n");
2275 if(!m_vSymbFctNodal.empty() || !m_vScalarNodalData.empty() || !m_vVectorNodalData.empty())
2277 fprintf(file,
" <PPointData>\n");
2280 iter != m_vSymbFctNodal.end(); ++iter)
2283 const std::vector<std::string>& symbNames = (*iter).second;
2284 const std::string& vtkName = (*iter).first;
2287 std::vector<size_t> fctGrp(symbNames.size());
2288 for(
size_t i = 0; i < symbNames.size(); ++i)
2289 fctGrp[i] = u.fct_id_by_name(symbNames[i].c_str());
2292 bool bContained =
true;
2293 for(
size_t i = 0; i < fctGrp.size(); ++i)
2294 if(!u.is_def_in_subset(fctGrp[i], si))
2297 if(!bContained)
continue;
2299 fprintf(file,
" <PDataArray type=\"Float32\" Name=\"%s\" "
2300 "NumberOfComponents=\"%d\"/>\n",
2301 vtkName.c_str(), (fctGrp.size() == 1 ? 1 : 3));
2306 iter != m_vScalarNodalData.end(); ++iter)
2309 const std::string& vtkName = (*iter).first;
2311 fprintf(file,
" <PDataArray type=\"Float32\" Name=\"%s\" "
2312 "NumberOfComponents=\"%d\"/>\n",
2313 vtkName.c_str(), 1);
2318 iter != m_vVectorNodalData.end(); ++iter)
2321 const std::string& vtkName = (*iter).first;
2323 fprintf(file,
" <PDataArray type=\"Float32\" Name=\"%s\" "
2324 "NumberOfComponents=\"%d\"/>\n",
2325 vtkName.c_str(), 3);
2330 iter != m_vMatrixNodalData.end(); ++iter)
2333 const std::string& vtkName = (*iter).first;
2335 fprintf(file,
" <PDataArray type=\"Float32\" Name=\"%s\" "
2336 "NumberOfComponents=\"%d\"/>\n",
2337 vtkName.c_str(), 9);
2339 fprintf(file,
" </PPointData>\n");
2343 if(!m_vSymbFctElem.empty() || !m_vScalarElemData.empty() || !m_vVectorElemData.empty() || m_bWriteSubsetIndices || m_bWriteProcRanks)
2345 fprintf(file,
" <PCellData>\n");
2348 iter != m_vSymbFctElem.end(); ++iter)
2351 const std::vector<std::string>& symbNames = (*iter).second;
2352 const std::string& vtkName = (*iter).first;
2355 std::vector<size_t> fctGrp(symbNames.size());
2356 for(
size_t i = 0; i < symbNames.size(); ++i)
2357 fctGrp[i] = u.fct_id_by_name(symbNames[i].c_str());
2360 bool bContained =
true;
2361 for(
size_t i = 0; i < fctGrp.size(); ++i)
2362 if(!u.is_def_in_subset(fctGrp[i], si))
2365 if(!bContained)
continue;
2367 fprintf(file,
" <PDataArray type=\"Float32\" Name=\"%s\" "
2368 "NumberOfComponents=\"%d\"/>\n",
2369 vtkName.c_str(), (fctGrp.size() == 1 ? 1 : 3));
2374 iter != m_vScalarElemData.end(); ++iter)
2377 const std::string& vtkName = (*iter).first;
2379 fprintf(file,
" <PDataArray type=\"Float32\" Name=\"%s\" "
2380 "NumberOfComponents=\"%d\"/>\n",
2381 vtkName.c_str(), 1);
2385 if(m_bWriteSubsetIndices){
2386 fprintf(file,
" <DataArray type=\"Int8\" Name=\"regions\" "
2387 "NumberOfComponents=\"1\"/>\n");
2389 if(m_bWriteProcRanks){
2390 fprintf(file,
" <DataArray type=\"Int8\" Name=\"proc_ranks\" "
2391 "NumberOfComponents=\"1\"/>\n");
2396 iter != m_vVectorElemData.end(); ++iter)
2399 const std::string& vtkName = (*iter).first;
2401 fprintf(file,
" <PDataArray type=\"Float32\" Name=\"%s\" "
2402 "NumberOfComponents=\"%d\"/>\n",
2403 vtkName.c_str(), 3);
2408 iter != m_vMatrixElemData.end(); ++iter)
2411 const std::string& vtkName = (*iter).first;
2413 fprintf(file,
" <PDataArray type=\"Float32\" Name=\"%s\" "
2414 "NumberOfComponents=\"%d\"/>\n",
2415 vtkName.c_str(), 9);
2417 fprintf(file,
" </PCellData>\n");
2421 for (
int i = 0; i < numProcs; i++) {
2422 vtu_filename(
name, filename, i, si, maxSi, step);
2424 fprintf(file,
" <Piece Source=\"%s\"/>\n",
name.c_str());
2428 fprintf(file,
" </PUnstructuredGrid>\n");
2429 fprintf(file,
"</VTKFile>\n");
2439 template <
typename TFunction>
2457 std::vector<number>& vTimestep = m_mTimestep[filename];
2460 char* oldLocale = setlocale (LC_ALL, NULL);
2461 setlocale(LC_NUMERIC,
"C");
2466 pvd_filename(
name, filename);
2469 file = fopen(
name.c_str(),
"w");
2474 fprintf(file,
"<?xml version=\"1.0\"?>\n");
2477 write_comment_printf(file);
2479 fprintf(file,
"<VTKFile type=\"Collection\" version=\"0.1\">\n");
2480 fprintf(file,
" <Collection>\n");
2483 bool bEverywhere =
true;
2484 for(
size_t fct = 0; fct < u.num_fct(); ++fct)
2487 if(!u.is_def_everywhere(fct))
2488 bEverywhere =
false;
2494 for(
int step = 0; step < (int)vTimestep.size(); ++step)
2496 vtu_filename(
name, filename, 0, -1, 0, step);
2497 if(numProcs > 1) pvtu_filename(
name, filename, -1, 0, step);
2500 fprintf(file,
" <DataSet timestep=\"%.17g\" part=\"%d\" file=\"%s\"/>\n",
2501 vTimestep[step], 0,
name.c_str());
2506 for(
int step = 0; step < (int)vTimestep.size(); ++step)
2507 for(
int si = 0; si < u.num_subsets(); ++si)
2509 vtu_filename(
name, filename, 0, si, u.num_subsets()-1, step);
2510 if(numProcs > 1) pvtu_filename(
name, filename, si, u.num_subsets()-1, step);
2513 fprintf(file,
" <DataSet timestep=\"%.17g\" part=\"%d\" file=\"%s\"/>\n",
2514 vTimestep[step], si,
name.c_str());
2519 fprintf(file,
" </Collection>\n");
2520 fprintf(file,
"</VTKFile>\n");
2525 setlocale(LC_NUMERIC, oldLocale);
2534 template <
typename TFunction>
2552 std::vector<number>& vTimestep = m_mTimestep[filename];
2555 char* oldLocale = setlocale (LC_ALL, NULL);
2556 setlocale(LC_NUMERIC,
"C");
2558 if (isOutputProc && numProcs > 1)
2561 std::string procName = filename;
2562 procName.append(
"_processwise");
2563 pvd_filename(
name, procName);
2566 file = fopen(
name.c_str(),
"w");
2571 fprintf(file,
"<?xml version=\"1.0\"?>\n");
2574 write_comment_printf(file);
2576 fprintf(file,
"<VTKFile type=\"Collection\" version=\"0.1\">\n");
2577 fprintf(file,
" <Collection>\n");
2580 for(
int step = 0; step < (int)vTimestep.size(); ++step)
2581 for (
int rank = 0; rank < numProcs; rank++)
2582 for(
int si = 0; si < u.num_subsets(); ++si)
2584 vtu_filename(
name, filename, rank, si, u.num_subsets()-1, step);
2585 if(numProcs > 1) pvtu_filename(
name, filename, si, u.num_subsets()-1, step);
2588 fprintf(file,
" <DataSet timestep=\"%.17g\" part=\"%d\" file=\"%s\"/>\n",
2589 vTimestep[step], rank,
name.c_str());
2593 fprintf(file,
" </Collection>\n");
2594 fprintf(file,
"</VTKFile>\n");
2599 setlocale(LC_NUMERIC, oldLocale);
2609 template <
typename TFunction>
2627 std::vector<number>& vTimestep = m_mTimestep[filename];
2630 char* oldLocale = setlocale (LC_ALL, NULL);
2631 setlocale(LC_NUMERIC,
"C");
2636 pvd_filename(
name, filename);
2639 file = fopen(
name.c_str(),
"w");
2644 fprintf(file,
"<?xml version=\"1.0\"?>\n");
2647 write_comment_printf(file);
2649 fprintf(file,
"<VTKFile type=\"Collection\" version=\"0.1\">\n");
2650 fprintf(file,
" <Collection>\n");
2653 for(
int step = 0; step < (int)vTimestep.size(); ++step)
2655 vtu_filename(
name, filename, 0, si, u.num_subsets()-1, step);
2656 if(numProcs > 1) pvtu_filename(
name, filename, si, u.num_subsets()-1, step);
2659 fprintf(file,
" <DataSet timestep=\"%g\" part=\"%d\" file=\"%s\"/>\n",
2660 vTimestep[step], si,
name.c_str());
2664 fprintf(file,
" </Collection>\n");
2665 fprintf(file,
"</VTKFile>\n");
2670 setlocale(LC_NUMERIC, oldLocale);
location name
Definition: checkpoint_util.lua:128
Definition: smart_pointer.h:108
File writer allowing selective base64 encoding of arbitrary data.
Definition: base64_file_writer.h:75
bool access(Grid &grid, TAttachment &a)
Definition: grid.h:189
Manages the elements of a grid and their interconnection.
Definition: grid.h:132
void end_marking()
ends a marking sequence. Call this method when you're done with marking.
Definition: grid.cpp:1285
bool is_marked(GridObject *obj) const
returns true if the object is marked, false if not.
Definition: grid_impl.hpp:843
void mark(GridObject *obj)
marks the object. Calls are only valid between calls to Grid::begin_marking and Grid::end_marking.
Definition: grid_impl.hpp:773
void begin_marking()
begin marking.
Definition: grid.cpp:1262
void detach_from_vertices(IAttachment &attachment)
Definition: grid.h:787
void attach_to_vertices(IAttachment &attachment, bool passOnValues)
Definition: grid.h:728
const char * get_subset_name(int subsetIndex) const
returns the name of a subset
Definition: subset_handler_interface.cpp:438
int get_subset_index(GridObject *elem) const
Definition: subset_handler_interface.cpp:560
int num_subsets() const
returns the number of subset-infos (return value is int, since SubsetIndices are of type int)
Definition: subset_handler_interface.h:317
Identifier for Local Finite Elements.
Definition: local_finite_element_id.h:98
virtual size_t num_sh() const
Definition: local_dof_set.cpp:46
static bool continuous(const LFEID &id, bool bCreate=true)
returns if a Local Shape Function Set is continuous
Definition: local_finite_element_provider.cpp:749
Definition: local_algebra.h:50
virtual base class for local shape function sets
Definition: local_shape_function_set.h:70
virtual void shapes(shape_type *vShape, const MathVector< dim > &x) const =0
returns all shape functions evaluated at a point
Definition: local_algebra.h:198
void resize(const LocalIndices &ind)
resize for current local indices
Definition: local_algebra.h:214
bool is_output_process()
returns true if the current process is an output process.
Definition: log.cpp:277
A class for fixed size, dense matrices.
Definition: math_matrix.h:52
a mathematical Vector with N entries.
Definition: math_vector.h:97
Handles subsets on a per level basis.
Definition: subset_handler_multi_grid.h:60
static TClass & get()
returns a singleton based on the identifier
Definition: provider.h:54
Group of subsets.
Definition: subset_group.h:51
size_t size() const
number of subsets in this group
Definition: subset_group.h:122
void add_all()
select all subsets of underlying subset handler
Definition: subset_group.cpp:133
void add(int si)
adds a subset by number to this group
Definition: subset_group.cpp:64
Type based UserData.
Definition: user_data.h:143
void count_sizes(Grid &grid, const T &iterContainer, const int si, int &numVert, int &numElem, int &numConn)
Definition: vtkoutput_impl.h:655
void write_nodal_data_elementwise(VTKFileWriter &File, TFunction &u, number time, SmartPtr< UserData< TData, TDim > > spData, Grid &grid, const int si)
Definition: vtkoutput_impl.h:1441
std::map< std::string, SmartPtr< UserData< MathVector< TDim >, TDim > > >::iterator VectorDataIterator
Definition: vtkoutput.h:937
void write_time_processwise_pvd(const char *filename, TFunction &u)
Definition: vtkoutput_impl.h:2536
void write_cell_values(VTKFileWriter &File, TFunction &u, const std::vector< size_t > &vFct, const std::string &name, Grid &grid, const SubsetGroup &ssGrp, const int dim, const int numElem)
Definition: vtkoutput_impl.h:2069
std::map< std::string, std::vector< std::string > >::iterator ComponentsIterator
Definition: vtkoutput.h:925
void write_item_to_file(VTKFileWriter &File, float data)
writes data to stream
Definition: vtkoutput_impl.h:87
void write_pvtu(TFunction &u, const std::string &filename, int si, int step, number time)
writes a grouping *.pvtu file
Definition: vtkoutput_impl.h:2230
void write_nodal_values_elementwise(VTKFileWriter &File, TFunction &u, const std::vector< size_t > &vFct, Grid &grid, const int si)
Definition: vtkoutput_impl.h:1593
void write_nodal_values_piece(VTKFileWriter &File, TFunction &u, number time, Grid &grid, const SubsetGroup &ssGrp, const int dim, const int numVert)
Definition: vtkoutput_impl.h:1710
void write_cell_offsets(VTKFileWriter &File, const T &iterContainer, const int si, int &n)
Definition: vtkoutput_impl.h:1059
void write_time_pvd(const char *filename, TFunction &u)
Definition: vtkoutput_impl.h:2441
void write_cell_subsets(VTKFileWriter &File, const T &iterContainer, const int si, MGSubsetHandler &sh)
Definition: vtkoutput_impl.h:1277
void write_grid_piece(VTKFileWriter &File, Grid::VertexAttachmentAccessor< Attachment< int > > &aaVrtIndex, const Grid::VertexAttachmentAccessor< Attachment< MathVector< TDim > > > &aaPos, Grid &grid, const T &iterContainer, SubsetGroup &ssGrp, int dim)
Definition: vtkoutput_impl.h:563
void write_cell_values_piece(VTKFileWriter &File, TFunction &u, number time, Grid &grid, const SubsetGroup &ssGrp, const int dim, const int numElem)
Definition: vtkoutput_impl.h:2110
void write_cell_values_elementwise(VTKFileWriter &File, TFunction &u, const std::vector< size_t > &vFct, Grid &grid, const int si)
Definition: vtkoutput_impl.h:1973
void print_subsets(const char *filename, TFunction &u, const SubsetGroup &ssGrp, int step=-1, number time=0.0, bool makeConsistent=true)
Definition: vtkoutput_impl.h:382
void write_nodal_data(VTKFileWriter &File, TFunction &u, number time, SmartPtr< UserData< TData, TDim > > spData, const int numCmp, const std::string &name, Grid &grid, const SubsetGroup &ssGrp, const int dim, const int numVert)
Definition: vtkoutput_impl.h:1536
void count_piece_sizes(Grid &grid, const T &iterContainer, const SubsetGroup &ssGrp, const int dim, int &numVert, int &numElem, int &numConn)
Definition: vtkoutput_impl.h:713
void write_cell_data_elementwise(VTKFileWriter &File, TFunction &u, number time, SmartPtr< UserData< TData, TDim > > spData, Grid &grid, const int si)
Definition: vtkoutput_impl.h:1831
void write_time_pvd_subset(const char *filename, TFunction &u, int si)
Definition: vtkoutput_impl.h:2611
void write_nodal_values(VTKFileWriter &File, TFunction &u, const std::vector< size_t > &vFct, const std::string &name, Grid &grid, const int si, const int dim, const int numVert)
void write_cell_connectivity(VTKFileWriter &File, Grid::VertexAttachmentAccessor< Attachment< int > > &aaVrtIndex, Grid &grid, const T &iterContainer, const int si)
Definition: vtkoutput_impl.h:920
void print_subset(const char *filename, TFunction &u, int si, int step, number time, bool makeConsistent)
Definition: vtkoutput_impl.h:247
std::map< std::string, SmartPtr< UserData< MathMatrix< TDim, TDim >, TDim > > >::iterator MatrixDataIterator
Definition: vtkoutput.h:943
void print(const char *filename, TFunction &u, int step, number time, bool makeConsistent)
Definition: vtkoutput_impl.h:184
void write_points_elementwise(VTKFileWriter &File, Grid::VertexAttachmentAccessor< Attachment< int > > &aaVrtIndex, const Grid::VertexAttachmentAccessor< Attachment< MathVector< TDim > > > &aaPos, Grid &grid, const T &iterContainer, const int si, int &n)
Definition: vtkoutput_impl.h:760
void write_points(VTKFileWriter &File, Grid::VertexAttachmentAccessor< Attachment< int > > &aaVrtIndex, const Grid::VertexAttachmentAccessor< Attachment< MathVector< TDim > > > &aaPos, Grid &grid, const T &iterContainer, const SubsetGroup &ssGrp, const int dim, const int numVert)
Definition: vtkoutput_impl.h:811
void write_cells(VTKFileWriter &File, Grid::VertexAttachmentAccessor< Attachment< int > > &aaVrtIndex, Grid &grid, const T &iterContainer, const SubsetGroup &ssGrp, const int dim, const int numElem, const int numConn)
Definition: vtkoutput_impl.h:888
void write_cell_subset_names(VTKFileWriter &File, MGSubsetHandler &sh)
Definition: vtkoutput_impl.h:872
void write_cell_proc_ranks(VTKFileWriter &File, const T &iterContainer, const int si, MGSubsetHandler &sh)
Definition: vtkoutput_impl.h:1359
void write_cell_data(VTKFileWriter &File, TFunction &u, number time, SmartPtr< UserData< TData, TDim > > spData, const int numCmp, const std::string &name, Grid &grid, const SubsetGroup &ssGrp, const int dim, const int numElem)
Definition: vtkoutput_impl.h:1927
void write_points_cells_piece(VTKFileWriter &File, Grid::VertexAttachmentAccessor< Attachment< int > > &aaVrtIndex, const Grid::VertexAttachmentAccessor< Attachment< MathVector< TDim > > > &aaPos, Grid &grid, const T &iterContainer, const SubsetGroup &ssGrp, const int dim, const int numVert, const int numElem, const int numConn)
Definition: vtkoutput_impl.h:538
std::map< std::string, SmartPtr< UserData< number, TDim > > >::iterator ScalarDataIterator
Definition: vtkoutput.h:931
VTKFileWriter & write_asc_float(VTKFileWriter &File, float data)
prints ascii representation of a float in the Float32 format (a protection against the denormalized f...
Definition: vtkoutput_impl.h:69
void write_grid_solution_piece(VTKFileWriter &File, Grid::VertexAttachmentAccessor< Attachment< int > > &aaVrtIndex, Grid &grid, TFunction &u, number time, const SubsetGroup &ssGrp, const int dim)
Definition: vtkoutput_impl.h:600
void write_cell_types(VTKFileWriter &File, const T &iterContainer, const int si)
Definition: vtkoutput_impl.h:1163
Base-class for all vertex-types.
Definition: grid_base_objects.h:231
@ PST_CONSISTENT
Definition: parallel_storage_type.h:68
void CollectCornerCoordinates(std::vector< typename TAAPos::ValueType > &vCornerCoordsOut, const TElem &elem, const TAAPos &aaPos, bool clearContainer=true)
returns the corner coordinates of a geometric object
Definition: domain_util_impl.h:75
Vertex * GetVertex(Vertex *v, size_t i)
returns the i'th vertex of a vertex
Definition: grid_util_impl.hpp:99
int ProcRank()
returns the rank of the process
Definition: pcl_base.cpp:83
int NumProcs()
returns the number of processes
Definition: pcl_base.cpp:91
@ base64_binary
encode given values in binary base64
Definition: base64_file_writer.h:85
@ normal
behaves as usual std::ofstream
Definition: base64_file_writer.h:87
bool IsLittleEndian()
Definition: endian_detection.h:49
#define UG_CATCH_THROW(msg)
Definition: error.h:64
LogAssistant & GetLogAssistant()
Definition: log_impl.h:69
#define UG_THROW(msg)
Definition: error.h:57
double number
Definition: types.h:124
ReferenceObjectID
these ids are used to identify the shape of a geometric object.
Definition: grid_base_objects.h:74
@ ROID_TETRAHEDRON
Definition: grid_base_objects.h:80
@ ROID_QUADRILATERAL
Definition: grid_base_objects.h:79
@ ROID_PYRAMID
Definition: grid_base_objects.h:83
@ ROID_PRISM
Definition: grid_base_objects.h:82
@ ROID_EDGE
Definition: grid_base_objects.h:77
@ ROID_OCTAHEDRON
Definition: grid_base_objects.h:84
@ ROID_HEXAHEDRON
Definition: grid_base_objects.h:81
@ ROID_TRIANGLE
Definition: grid_base_objects.h:78
string FilenameWithoutPath(const string &str)
Definition: string_util.cpp:195
number & DoFRef(TMatrix &mat, const DoFIndex &iInd, const DoFIndex &jInd)
Definition: multi_index.h:276
void TokenizeTrimString(const string &str, vector< string > &vToken, const char delimiter)
Definition: string_util.cpp:83
void GetLocalVector(LocalVector &lvec, const TVector &vec)
Definition: local_algebra.h:739
int DimensionOfSubset(const ISubsetHandler &sh, int si)
returns the current dimension of the subset
Definition: subset_dim_util.cpp:89
void AveragePositions(TPosition &vOut, const TPosition *vCornerCoords, size_t num)
averages positions by arithmetic mean
Definition: fv_util.h:59
#define PCL_DEBUG_BARRIER_ALL()
Definition: pcl_util.h:57
#define PROFILE_FUNC()
Definition: profiler.h:257
Definition: vtkoutput.h:56
traits for reference elements
Definition: reference_element_traits.h:48