Skip to content
Snippets Groups Projects
Commit d9f41bd6 authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Plugged VTKWriter to 1d meshes

parent 14ce1a73
No related branches found
No related tags found
No related merge requests found
...@@ -30,7 +30,6 @@ public: ...@@ -30,7 +30,6 @@ public:
std::ostringstream sout; std::ostringstream sout;
sout << m_base_filename << '.' << std::setfill('0') << std::setw(4) << m_file_number << ".vtu" << std::ends; sout << m_base_filename << '.' << std::setfill('0') << std::setw(4) << m_file_number << ".vtu" << std::ends;
std::ofstream fout(sout.str()); std::ofstream fout(sout.str());
if constexpr(MeshType::dimension ==2) {
fout << "<?xml version=\"1.0\"?>\n"; fout << "<?xml version=\"1.0\"?>\n";
fout << "<VTKFile type=\"UnstructuredGrid\">\n"; fout << "<VTKFile type=\"UnstructuredGrid\">\n";
fout << "<UnstructuredGrid>\n"; fout << "<UnstructuredGrid>\n";
...@@ -39,7 +38,15 @@ public: ...@@ -39,7 +38,15 @@ public:
fout << "<Points>\n"; fout << "<Points>\n";
fout << "<DataArray Name=\"Positions\" NumberOfComponents=\"3\" type=\"Float64\" format=\"ascii\">\n"; fout << "<DataArray Name=\"Positions\" NumberOfComponents=\"3\" type=\"Float64\" format=\"ascii\">\n";
if constexpr(MeshType::dimension ==1) {
const Kokkos::View<const TinyVector<1>*> xr = mesh.xr();
for (unsigned int r=0; r<mesh.numberOfNodes(); ++r) {
for (unsigned short i=0; i<1; ++i) {
fout << xr[r][i] << ' ';
}
fout << "0 0 "; // VTK requires 3 components
}
} else if (MeshType::dimension ==2) {
const Kokkos::View<const TinyVector<2>*> xr = mesh.xr(); const Kokkos::View<const TinyVector<2>*> xr = mesh.xr();
for (unsigned int r=0; r<mesh.numberOfNodes(); ++r) { for (unsigned int r=0; r<mesh.numberOfNodes(); ++r) {
for (unsigned short i=0; i<2; ++i) { for (unsigned short i=0; i<2; ++i) {
...@@ -47,11 +54,15 @@ public: ...@@ -47,11 +54,15 @@ public:
} }
fout << "0 "; // VTK requires 3 components fout << "0 "; // VTK requires 3 components
} }
} else {
std::cerr << "VTKWriter not implemented in dimension " << MeshType::dimension << '\n';
std::exit(1);
}
fout << '\n'; fout << '\n';
fout << "</DataArray>\n"; fout << "</DataArray>\n";
fout << "</Points>\n"; fout << "</Points>\n";
fout << "<Cells>\n";
fout << "<Cells>\n";
const Kokkos::View<const unsigned int**> cell_nodes = mesh.connectivity().cellNodes(); const Kokkos::View<const unsigned int**> cell_nodes = mesh.connectivity().cellNodes();
const Kokkos::View<const unsigned short*> cell_nb_nodes = mesh.connectivity().cellNbNodes(); const Kokkos::View<const unsigned short*> cell_nb_nodes = mesh.connectivity().cellNbNodes();
...@@ -78,6 +89,10 @@ public: ...@@ -78,6 +89,10 @@ public:
fout << "<DataArray type=\"Int8\" Name=\"types\" NumberOfComponents=\"1\" format=\"ascii\">\n"; fout << "<DataArray type=\"Int8\" Name=\"types\" NumberOfComponents=\"1\" format=\"ascii\">\n";
for (unsigned int j=0; j<mesh.numberOfCells(); ++j) { for (unsigned int j=0; j<mesh.numberOfCells(); ++j) {
switch (cell_nb_nodes[j]) { switch (cell_nb_nodes[j]) {
case 2: {
fout << "3 ";
break;
}
case 3: { case 3: {
fout << "5 "; fout << "5 ";
break; break;
...@@ -99,10 +114,7 @@ public: ...@@ -99,10 +114,7 @@ public:
fout << "</Piece>\n"; fout << "</Piece>\n";
fout << "</UnstructuredGrid>\n"; fout << "</UnstructuredGrid>\n";
fout << "</VTKFile>\n"; fout << "</VTKFile>\n";
} else {
std::cerr << "VTKWriter not implemented in dimension " << MeshType::dimension << '\n';
std::exit(1);
}
m_file_number++; m_file_number++;
} }
VTKWriter(const std::string& base_filename, VTKWriter(const std::string& base_filename,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment