Closed luca-heltai closed 2 weeks ago
Update: after introducing the ParameterHandler, the solution files are now ok. Only the .pvd issue is still present.
--- a/source/project.cc
+++ b/source/project.cc
@@ -458,15 +458,18 @@ HeatEquation<dim>::output_results(const Vector<double> &sol,
data_out.build_patches();
- const std::string filename = "output_" + std::to_string(dim) + "d/solution-" +
- Utilities::int_to_string(step_no, 3) + ".vtu";
- std::ofstream output(filename);
+ const std::string dirname = "output_" + std::to_string(dim) + "d/";
+
+ const std::string filename =
+ "solution-" + Utilities::int_to_string(step_no, 3) + ".vtu";
+
+ std::ofstream output(dirname + filename);
data_out.write_vtu(output);
static std::vector<std::pair<double, std::string>> times_and_names;
times_and_names.push_back({step_no, filename});
- std::ofstream pvd_output("output_" + std::to_string(dim) + "d/solution.pvd");
+ std::ofstream pvd_output(dirname + "solution.pvd");
DataOutBase::write_pvd_record(pvd_output, times_and_names);
}
The above changes should fix this. The pvd
file uses relative paths. If you write in the same output directory of the .vtu
files, then you need to write relative paths.
The changes above should fix this.
Thanks a lot! This solved the problem.
Initializing the solution vector with VectorTools::interpolate seems to generate an invalid solution-000.vtu file, which also makes Paraview unable to open the .pvd record. How is this possible?