22#ifndef DUMUX_TEST_WRITE_TRIANGULATION_HH
23#define DUMUX_TEST_WRITE_TRIANGULATION_HH
32template<
class TriangleVector>
34 const std::string& filename)
36 std::ofstream fout(filename +
".vtp");
37 fout <<
"<?xml version=\"1.0\"?>\n"
38 <<
"<VTKFile type=\"PolyData\" version=\"0.1\" byte_order=\"LittleEndian\">\n"
40 <<
" <Piece NumberOfPoints=\"" << triangles.size()*3 <<
"\" NumberOfLines=\"" << triangles.size()*3 <<
"\">\n"
42 <<
" <DataArray type=\"Float32\" Name=\"Coordinates\" NumberOfComponents=\"3\" format=\"ascii\">\n";
44 for (
const auto& t : triangles)
46 for (
const auto& p : t)
51 else if (p.size() == 2)
58 fout <<
" </DataArray>\n"
61 <<
" <DataArray type=\"Int32\" Name=\"connectivity\" NumberOfComponents=\"1\" format=\"ascii\">\n";
64 for (
const auto& t : triangles)
66 for (std::size_t i = 0; i < t.size()-1; ++i)
67 fout << i + offset*3 <<
" " << i+1 + offset*3 <<
" ";
68 fout << t.size()-1 + offset*3 <<
" " << offset*3 <<
" ";
72 fout <<
" </DataArray>\n";
73 fout <<
" <DataArray type=\"Int32\" Name=\"offsets\" NumberOfComponents=\"1\" format=\"ascii\">\n";
76 for (
const auto& t : triangles)
78 for (std::size_t i = 1; i <= t.size(); ++i)
79 fout << i*2 + offset*6 <<
" ";
84 fout <<
" </DataArray>\n"
make the local view function available whenever we use the grid geometry
Definition: adapt.hh:29
void writeVTKPolyDataTriangle(const TriangleVector &triangles, const std::string &filename)
TriangleVector has to be a nested vector of triangles in 3d.
Definition: writetriangulation.hh:33