// With this, the `output_results()` function becomes relatively
- // straightforward: We use the DataOut class as we have in almost every one of
- // the previous tutorial programs to output the solution (the "electric
- // potential") and we use the postprocessor defined above to also output its
- // gradient (the "electric field"). This all is then written into a file in
- // VTU format after also associating the current time and time step number
- // with this file.
+ // straightforward: We use the DataOut class as we have in almost
+ // every one of the previous tutorial programs to output the
+ // solution (the "electric potential") and we use the postprocessor
+ // defined above to also output its gradient (the "electric
+ // field"). This all is then written into a file in VTU format after
+ // also associating the current time and time step number with this
+ // file, and providing physical units for the two fields to be
+ // output.
template <int dim>
void CathodeRaySimulator<dim>::output_results() const
{
data_out.add_data_vector(solution, electric_field);
data_out.build_patches();
- data_out.set_flags(
- DataOutBase::VtkFlags(time.get_current_time(), time.get_step_number()));
+ DataOutBase::VtkFlags output_flags;
+ output_flags.time = time.get_current_time();
+ output_flags.cycle = time.get_step_number();
+ output_flags.physical_units["electric_potential"] = "V";
+ output_flags.physical_units["electric_field"] = "V/m";
+
+ data_out.set_flags(output_flags);
std::ofstream output("solution-" +
Utilities::int_to_string(time.get_step_number(), 4) +
std::vector<DataComponentInterpretation::DataComponentInterpretation>(
dim, DataComponentInterpretation::component_is_part_of_vector));
- particle_out.set_flags(
- DataOutBase::VtkFlags(time.get_current_time(), time.get_step_number()));
+ DataOutBase::VtkFlags output_flags;
+ output_flags.time = time.get_current_time();
+ output_flags.cycle = time.get_step_number();
+ output_flags.physical_units["velocity"] = "m/s";
+
+ particle_out.set_flags(output_flags);
std::ofstream output("particles-" +
Utilities::int_to_string(time.get_step_number(), 4) +
// $[\rho,\textbf{m},E]$.
//
// The purpose of the class members <code>component_names</code>,
+ // <code>component_physical_units</code>,
// <code>pressure</code>, and <code>speed_of_sound</code> is evident from
// their names. We also provide a function
// <code>compute_lambda_max()</code>, that computes the wave speed
using flux_type = Tensor<1, problem_dimension, Tensor<1, dim>>;
const static std::array<std::string, problem_dimension> component_names;
+ const static std::array<std::string, problem_dimension>
+ component_physical_units;
static constexpr double gamma = 7. / 5.;
}
// We conclude this section by defining static arrays
- // <code>component_names</code> that contain strings describing the
- // component names of our state vector. We have template specializations
- // for dimensions one, two and three, that are used later in DataOut for
- // naming the corresponding components:
+ // <code>component_names</code> and <code>component_physical_units</code>
+ // that contain strings describing the
+ // components of our state vector, as well as the physical units of
+ // these quantities that can be used to annotate the VTU output
+ // files we generate for visualization and postprocessing. We have
+ // template specializations for dimensions one, two and three, that
+ // are used later in DataOut for naming the corresponding
+ // components:
template <>
const std::array<std::string, 3> ProblemDescription<1>::component_names{
{"rho", "m", "E"}};
+ template <>
+ const std::array<std::string, 3>
+ ProblemDescription<1>::component_physical_units{
+ {"kg/m", "kg*m/s/m", "J/m"}};
+
+
template <>
const std::array<std::string, 4> ProblemDescription<2>::component_names{
{"rho", "m_1", "m_2", "E"}};
+ template <>
+ const std::array<std::string, 4>
+ ProblemDescription<2>::component_physical_units{
+ {"kg/m/m", "kg*m/s/m/m", "kg*m/s/m/m", "J/m/m"}};
+
template <>
const std::array<std::string, 5> ProblemDescription<3>::component_names{
{"rho", "m_1", "m_2", "m_3", "E"}};
+ template <>
+ const std::array<std::string, 5>
+ ProblemDescription<3>::component_physical_units{
+ {"kg/m/m/m", "kg*m/s/m/m/m", "kg*m/s/m/m/m", "kg*m/s/m/m/m", "J/m/m/m"}};
+
// @sect4{Initial values}
// The last preparatory step, before we discuss the implementation of the
oa << it2;
}
- DataOutBase::VtkFlags flags(t,
- cycle,
- true,
- DataOutBase::VtkFlags::best_speed);
- data_out->set_flags(flags);
+ DataOutBase::VtkFlags output_flags;
+ output_flags.time = t;
+ output_flags.cycle = cycle;
+ output_flags.compression_level = DataOutBase::VtkFlags::best_speed;
+ for (unsigned int i = 0;
+ i < ProblemDescription<dim>::component_names.size();
+ ++i)
+ output_flags
+ .physical_units[ProblemDescription<dim>::component_names[i]] =
+ ProblemDescription<dim>::component_physical_units[i];
+
+ data_out->set_flags(output_flags);
data_out->write_vtu_with_pvtu_record(
"", name + "-solution", cycle, mpi_communicator, 6);