]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add tests.
authorWolfgang Bangerth <bangerth@colostate.edu>
Fri, 9 Jul 2021 19:25:16 +0000 (13:25 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Thu, 15 Jul 2021 16:35:54 +0000 (10:35 -0600)
tests/data_out/pvtu_physical_units_01.cc [new file with mode: 0644]
tests/data_out/pvtu_physical_units_01.with_zlib=true.output [new file with mode: 0644]
tests/data_out/pvtu_physical_units_02.cc [new file with mode: 0644]
tests/data_out/pvtu_physical_units_02.with_zlib=true.output [new file with mode: 0644]
tests/data_out/vtu_physical_units_01.cc [new file with mode: 0644]
tests/data_out/vtu_physical_units_01.with_zlib=true.output [new file with mode: 0644]
tests/data_out/vtu_physical_units_02.cc [new file with mode: 0644]
tests/data_out/vtu_physical_units_02.with_zlib=true.output [new file with mode: 0644]

diff --git a/tests/data_out/pvtu_physical_units_01.cc b/tests/data_out/pvtu_physical_units_01.cc
new file mode 100644 (file)
index 0000000..4111242
--- /dev/null
@@ -0,0 +1,81 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2006 - 2020 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE.md at
+// the top level directory of deal.II.
+//
+// ---------------------------------------------------------------------
+
+
+// Check that one can output physical units along with output
+// fields. This test is for scalar quantities and checks the
+// pvtu writer.
+
+
+#include <deal.II/base/data_out_base.h>
+
+#include <string>
+#include <vector>
+
+#include "../tests.h"
+
+#include "patches.h"
+
+// Output data on repetitions of the unit hypercube
+
+template <int dim, int spacedim>
+void
+check(DataOutBase::VtkFlags flags, std::ostream &out)
+{
+  std::vector<std::string> names(5);
+  names[0] = "x1";
+  names[1] = "x2";
+  names[2] = "x3";
+  names[3] = "x4";
+  names[4] = "i";
+
+  std::vector<
+    std::tuple<unsigned int,
+               unsigned int,
+               std::string,
+               DataComponentInterpretation::DataComponentInterpretation>>
+    vectors;
+  DataOutBase::write_pvtu_record(out, {"abc.vtu"}, names, vectors, flags);
+}
+
+
+template <int dim, int spacedim>
+void
+check_all(std::ostream &log)
+{
+  DataOutBase::VtkFlags flags;
+
+  // Set the units of some but not all output quantities
+  flags.physical_units["x1"] = "kg/s";
+  flags.physical_units["x3"] = "N/m";
+  flags.physical_units["i"]  = "J/K";
+
+  log << "==============================" << std::endl
+      << dim << spacedim << ".vtu" << std::endl
+      << "==============================" << std::endl;
+  check<dim, spacedim>(flags, log);
+}
+
+int
+main()
+{
+  initlog();
+
+  check_all<1, 1>(deallog.get_file_stream());
+  check_all<1, 2>(deallog.get_file_stream());
+  check_all<2, 2>(deallog.get_file_stream());
+  check_all<2, 3>(deallog.get_file_stream());
+  check_all<3, 3>(deallog.get_file_stream());
+}
diff --git a/tests/data_out/pvtu_physical_units_01.with_zlib=true.output b/tests/data_out/pvtu_physical_units_01.with_zlib=true.output
new file mode 100644 (file)
index 0000000..a1e3403
--- /dev/null
@@ -0,0 +1,111 @@
+
+==============================
+11.vtu
+==============================
+<?xml version="1.0"?>
+<!--
+#This file was generated 
+-->
+<VTKFile type="PUnstructuredGrid" version="0.1" byte_order="LittleEndian">
+  <PUnstructuredGrid GhostLevel="0">
+    <PPointData Scalars="scalars">
+    <PDataArray type="Float32" Name="x1" format="ascii" units="kg/s"/>
+    <PDataArray type="Float32" Name="x2" format="ascii"/>
+    <PDataArray type="Float32" Name="x3" format="ascii" units="N/m"/>
+    <PDataArray type="Float32" Name="x4" format="ascii"/>
+    <PDataArray type="Float32" Name="i" format="ascii" units="J/K"/>
+    </PPointData>
+    <PPoints>
+      <PDataArray type="Float32" NumberOfComponents="3"/>
+    </PPoints>
+    <Piece Source="abc.vtu"/>
+  </PUnstructuredGrid>
+</VTKFile>
+==============================
+12.vtu
+==============================
+<?xml version="1.0"?>
+<!--
+#This file was generated 
+-->
+<VTKFile type="PUnstructuredGrid" version="0.1" byte_order="LittleEndian">
+  <PUnstructuredGrid GhostLevel="0">
+    <PPointData Scalars="scalars">
+    <PDataArray type="Float32" Name="x1" format="ascii" units="kg/s"/>
+    <PDataArray type="Float32" Name="x2" format="ascii"/>
+    <PDataArray type="Float32" Name="x3" format="ascii" units="N/m"/>
+    <PDataArray type="Float32" Name="x4" format="ascii"/>
+    <PDataArray type="Float32" Name="i" format="ascii" units="J/K"/>
+    </PPointData>
+    <PPoints>
+      <PDataArray type="Float32" NumberOfComponents="3"/>
+    </PPoints>
+    <Piece Source="abc.vtu"/>
+  </PUnstructuredGrid>
+</VTKFile>
+==============================
+22.vtu
+==============================
+<?xml version="1.0"?>
+<!--
+#This file was generated 
+-->
+<VTKFile type="PUnstructuredGrid" version="0.1" byte_order="LittleEndian">
+  <PUnstructuredGrid GhostLevel="0">
+    <PPointData Scalars="scalars">
+    <PDataArray type="Float32" Name="x1" format="ascii" units="kg/s"/>
+    <PDataArray type="Float32" Name="x2" format="ascii"/>
+    <PDataArray type="Float32" Name="x3" format="ascii" units="N/m"/>
+    <PDataArray type="Float32" Name="x4" format="ascii"/>
+    <PDataArray type="Float32" Name="i" format="ascii" units="J/K"/>
+    </PPointData>
+    <PPoints>
+      <PDataArray type="Float32" NumberOfComponents="3"/>
+    </PPoints>
+    <Piece Source="abc.vtu"/>
+  </PUnstructuredGrid>
+</VTKFile>
+==============================
+23.vtu
+==============================
+<?xml version="1.0"?>
+<!--
+#This file was generated 
+-->
+<VTKFile type="PUnstructuredGrid" version="0.1" byte_order="LittleEndian">
+  <PUnstructuredGrid GhostLevel="0">
+    <PPointData Scalars="scalars">
+    <PDataArray type="Float32" Name="x1" format="ascii" units="kg/s"/>
+    <PDataArray type="Float32" Name="x2" format="ascii"/>
+    <PDataArray type="Float32" Name="x3" format="ascii" units="N/m"/>
+    <PDataArray type="Float32" Name="x4" format="ascii"/>
+    <PDataArray type="Float32" Name="i" format="ascii" units="J/K"/>
+    </PPointData>
+    <PPoints>
+      <PDataArray type="Float32" NumberOfComponents="3"/>
+    </PPoints>
+    <Piece Source="abc.vtu"/>
+  </PUnstructuredGrid>
+</VTKFile>
+==============================
+33.vtu
+==============================
+<?xml version="1.0"?>
+<!--
+#This file was generated 
+-->
+<VTKFile type="PUnstructuredGrid" version="0.1" byte_order="LittleEndian">
+  <PUnstructuredGrid GhostLevel="0">
+    <PPointData Scalars="scalars">
+    <PDataArray type="Float32" Name="x1" format="ascii" units="kg/s"/>
+    <PDataArray type="Float32" Name="x2" format="ascii"/>
+    <PDataArray type="Float32" Name="x3" format="ascii" units="N/m"/>
+    <PDataArray type="Float32" Name="x4" format="ascii"/>
+    <PDataArray type="Float32" Name="i" format="ascii" units="J/K"/>
+    </PPointData>
+    <PPoints>
+      <PDataArray type="Float32" NumberOfComponents="3"/>
+    </PPoints>
+    <Piece Source="abc.vtu"/>
+  </PUnstructuredGrid>
+</VTKFile>
diff --git a/tests/data_out/pvtu_physical_units_02.cc b/tests/data_out/pvtu_physical_units_02.cc
new file mode 100644 (file)
index 0000000..f2cf11b
--- /dev/null
@@ -0,0 +1,87 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2006 - 2020 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE.md at
+// the top level directory of deal.II.
+//
+// ---------------------------------------------------------------------
+
+
+// Check that one can output physical units along with output
+// fields. This test is for vector-valued quantities and checks the
+// pvtu writer.
+
+
+#include <deal.II/base/data_out_base.h>
+
+#include <string>
+#include <vector>
+
+#include "../tests.h"
+
+#include "patches.h"
+
+// Output data on repetitions of the unit hypercube
+
+template <int dim, int spacedim>
+void
+check(DataOutBase::VtkFlags flags, std::ostream &out)
+{
+  std::vector<std::string> names(5);
+  names[0] = "x1";
+  names[1] = "x2";
+  names[2] = "x3";
+  names[3] = "x4";
+  names[4] = "i";
+  for (unsigned int i = 1; i < 1 + dim; ++i)
+    names[i] = "v";
+
+  std::vector<
+    std::tuple<unsigned int,
+               unsigned int,
+               std::string,
+               DataComponentInterpretation::DataComponentInterpretation>>
+    vectors{{1,
+             1 + dim - 1,
+             "v",
+             DataComponentInterpretation::component_is_part_of_vector}};
+  DataOutBase::write_pvtu_record(out, {"abc.vtu"}, names, vectors, flags);
+}
+
+
+template <int dim, int spacedim>
+void
+check_all(std::ostream &log)
+{
+  DataOutBase::VtkFlags flags;
+
+  // Set the units of some but not all output quantities
+  flags.physical_units["x1"] = "kg/s";
+  flags.physical_units["v"]  = "m/s";
+
+  log << "==============================" << std::endl
+      << dim << spacedim << ".vtu" << std::endl
+      << "==============================" << std::endl;
+  check<dim, spacedim>(flags, log);
+}
+
+int
+main()
+{
+  std::stringstream ss;
+  check_all<1, 1>(ss);
+  check_all<1, 2>(ss);
+  check_all<2, 2>(ss);
+  check_all<2, 3>(ss);
+  check_all<3, 3>(ss);
+
+  std::ofstream logfile("output");
+  filter_out_xml_key(ss, "DataArray", logfile);
+}
diff --git a/tests/data_out/pvtu_physical_units_02.with_zlib=true.output b/tests/data_out/pvtu_physical_units_02.with_zlib=true.output
new file mode 100644 (file)
index 0000000..d72b903
--- /dev/null
@@ -0,0 +1,106 @@
+==============================
+11.vtu
+==============================
+<?xml version="1.0"?>
+<!--
+#This file was generated 
+-->
+<VTKFile type="PUnstructuredGrid" version="0.1" byte_order="LittleEndian">
+  <PUnstructuredGrid GhostLevel="0">
+    <PPointData Scalars="scalars">
+    <PDataArray type="Float32" Name="v" NumberOfComponents="3" format="ascii" units="m/s"/>
+    <PDataArray type="Float32" Name="x1" format="ascii" units="kg/s"/>
+    <PDataArray type="Float32" Name="x3" format="ascii"/>
+    <PDataArray type="Float32" Name="x4" format="ascii"/>
+    <PDataArray type="Float32" Name="i" format="ascii"/>
+    </PPointData>
+    <PPoints>
+      <PDataArray type="Float32" NumberOfComponents="3"/>
+    </PPoints>
+    <Piece Source="abc.vtu"/>
+  </PUnstructuredGrid>
+</VTKFile>
+==============================
+12.vtu
+==============================
+<?xml version="1.0"?>
+<!--
+#This file was generated 
+-->
+<VTKFile type="PUnstructuredGrid" version="0.1" byte_order="LittleEndian">
+  <PUnstructuredGrid GhostLevel="0">
+    <PPointData Scalars="scalars">
+    <PDataArray type="Float32" Name="v" NumberOfComponents="3" format="ascii" units="m/s"/>
+    <PDataArray type="Float32" Name="x1" format="ascii" units="kg/s"/>
+    <PDataArray type="Float32" Name="x3" format="ascii"/>
+    <PDataArray type="Float32" Name="x4" format="ascii"/>
+    <PDataArray type="Float32" Name="i" format="ascii"/>
+    </PPointData>
+    <PPoints>
+      <PDataArray type="Float32" NumberOfComponents="3"/>
+    </PPoints>
+    <Piece Source="abc.vtu"/>
+  </PUnstructuredGrid>
+</VTKFile>
+==============================
+22.vtu
+==============================
+<?xml version="1.0"?>
+<!--
+#This file was generated 
+-->
+<VTKFile type="PUnstructuredGrid" version="0.1" byte_order="LittleEndian">
+  <PUnstructuredGrid GhostLevel="0">
+    <PPointData Scalars="scalars">
+    <PDataArray type="Float32" Name="v" NumberOfComponents="3" format="ascii" units="m/s"/>
+    <PDataArray type="Float32" Name="x1" format="ascii" units="kg/s"/>
+    <PDataArray type="Float32" Name="x4" format="ascii"/>
+    <PDataArray type="Float32" Name="i" format="ascii"/>
+    </PPointData>
+    <PPoints>
+      <PDataArray type="Float32" NumberOfComponents="3"/>
+    </PPoints>
+    <Piece Source="abc.vtu"/>
+  </PUnstructuredGrid>
+</VTKFile>
+==============================
+23.vtu
+==============================
+<?xml version="1.0"?>
+<!--
+#This file was generated 
+-->
+<VTKFile type="PUnstructuredGrid" version="0.1" byte_order="LittleEndian">
+  <PUnstructuredGrid GhostLevel="0">
+    <PPointData Scalars="scalars">
+    <PDataArray type="Float32" Name="v" NumberOfComponents="3" format="ascii" units="m/s"/>
+    <PDataArray type="Float32" Name="x1" format="ascii" units="kg/s"/>
+    <PDataArray type="Float32" Name="x4" format="ascii"/>
+    <PDataArray type="Float32" Name="i" format="ascii"/>
+    </PPointData>
+    <PPoints>
+      <PDataArray type="Float32" NumberOfComponents="3"/>
+    </PPoints>
+    <Piece Source="abc.vtu"/>
+  </PUnstructuredGrid>
+</VTKFile>
+==============================
+33.vtu
+==============================
+<?xml version="1.0"?>
+<!--
+#This file was generated 
+-->
+<VTKFile type="PUnstructuredGrid" version="0.1" byte_order="LittleEndian">
+  <PUnstructuredGrid GhostLevel="0">
+    <PPointData Scalars="scalars">
+    <PDataArray type="Float32" Name="v" NumberOfComponents="3" format="ascii" units="m/s"/>
+    <PDataArray type="Float32" Name="x1" format="ascii" units="kg/s"/>
+    <PDataArray type="Float32" Name="i" format="ascii"/>
+    </PPointData>
+    <PPoints>
+      <PDataArray type="Float32" NumberOfComponents="3"/>
+    </PPoints>
+    <Piece Source="abc.vtu"/>
+  </PUnstructuredGrid>
+</VTKFile>
diff --git a/tests/data_out/vtu_physical_units_01.cc b/tests/data_out/vtu_physical_units_01.cc
new file mode 100644 (file)
index 0000000..6196ff1
--- /dev/null
@@ -0,0 +1,86 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2006 - 2020 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE.md at
+// the top level directory of deal.II.
+//
+// ---------------------------------------------------------------------
+
+
+// Check that one can output physical units along with output fields
+
+
+#include <deal.II/base/data_out_base.h>
+
+#include <string>
+#include <vector>
+
+#include "../tests.h"
+
+#include "patches.h"
+
+// Output data on repetitions of the unit hypercube
+
+template <int dim, int spacedim>
+void
+check(DataOutBase::VtkFlags flags, std::ostream &out)
+{
+  const unsigned int np = 4;
+
+  std::vector<DataOutBase::Patch<dim, spacedim>> patches(np);
+
+  create_patches(patches);
+
+  std::vector<std::string> names(5);
+  names[0] = "x1";
+  names[1] = "x2";
+  names[2] = "x3";
+  names[3] = "x4";
+  names[4] = "i";
+  std::vector<
+    std::tuple<unsigned int,
+               unsigned int,
+               std::string,
+               DataComponentInterpretation::DataComponentInterpretation>>
+    vectors;
+  DataOutBase::write_vtu(patches, names, vectors, flags, out);
+}
+
+
+template <int dim, int spacedim>
+void
+check_all(std::ostream &log)
+{
+  DataOutBase::VtkFlags flags;
+
+  // Set the units of some but not all output quantities
+  flags.physical_units["x1"] = "kg/s";
+  flags.physical_units["x3"] = "N/m";
+  flags.physical_units["i"]  = "J/K";
+
+  log << "==============================" << std::endl
+      << dim << spacedim << ".vtu" << std::endl
+      << "==============================" << std::endl;
+  check<dim, spacedim>(flags, log);
+}
+
+int
+main()
+{
+  std::stringstream ss;
+  check_all<1, 1>(ss);
+  check_all<1, 2>(ss);
+  check_all<2, 2>(ss);
+  check_all<2, 3>(ss);
+  check_all<3, 3>(ss);
+
+  std::ofstream logfile("output");
+  filter_out_xml_key(ss, "DataArray", logfile);
+}
diff --git a/tests/data_out/vtu_physical_units_01.with_zlib=true.output b/tests/data_out/vtu_physical_units_01.with_zlib=true.output
new file mode 100644 (file)
index 0000000..af283a0
--- /dev/null
@@ -0,0 +1,195 @@
+==============================
+11.vtu
+==============================
+<?xml version="1.0" ?> 
+<!-- 
+# vtk DataFile Version 3.0
+#This file was generated 
+-->
+<VTKFile type="UnstructuredGrid" version="0.1" compressor="vtkZLibDataCompressor" byte_order="LittleEndian">
+<UnstructuredGrid>
+<Piece NumberOfPoints="14" NumberOfCells="10" >
+  <Points>
+    <DataArray type="Float32" NumberOfComponents="3" format="binary">
+</DataArray>
+  </Points>
+
+  <Cells>
+    <DataArray type="Int32" Name="connectivity" format="binary">
+</DataArray>
+    <DataArray type="Int32" Name="offsets" format="binary">
+</DataArray>
+    <DataArray type="UInt8" Name="types" format="binary">
+</DataArray>
+  </Cells>
+  <PointData Scalars="scalars">
+    <DataArray type="Float32" Name="x1" format="binary" units="kg/s">
+</DataArray>
+    <DataArray type="Float32" Name="x2" format="binary">
+</DataArray>
+    <DataArray type="Float32" Name="x3" format="binary" units="N/m">
+</DataArray>
+    <DataArray type="Float32" Name="x4" format="binary">
+</DataArray>
+    <DataArray type="Float32" Name="i" format="binary" units="J/K">
+</DataArray>
+  </PointData>
+ </Piece>
+ </UnstructuredGrid>
+</VTKFile>
+==============================
+12.vtu
+==============================
+<?xml version="1.0" ?> 
+<!-- 
+# vtk DataFile Version 3.0
+#This file was generated 
+-->
+<VTKFile type="UnstructuredGrid" version="0.1" compressor="vtkZLibDataCompressor" byte_order="LittleEndian">
+<UnstructuredGrid>
+<Piece NumberOfPoints="14" NumberOfCells="10" >
+  <Points>
+    <DataArray type="Float32" NumberOfComponents="3" format="binary">
+</DataArray>
+  </Points>
+
+  <Cells>
+    <DataArray type="Int32" Name="connectivity" format="binary">
+</DataArray>
+    <DataArray type="Int32" Name="offsets" format="binary">
+</DataArray>
+    <DataArray type="UInt8" Name="types" format="binary">
+</DataArray>
+  </Cells>
+  <PointData Scalars="scalars">
+    <DataArray type="Float32" Name="x1" format="binary" units="kg/s">
+</DataArray>
+    <DataArray type="Float32" Name="x2" format="binary">
+</DataArray>
+    <DataArray type="Float32" Name="x3" format="binary" units="N/m">
+</DataArray>
+    <DataArray type="Float32" Name="x4" format="binary">
+</DataArray>
+    <DataArray type="Float32" Name="i" format="binary" units="J/K">
+</DataArray>
+  </PointData>
+ </Piece>
+ </UnstructuredGrid>
+</VTKFile>
+==============================
+22.vtu
+==============================
+<?xml version="1.0" ?> 
+<!-- 
+# vtk DataFile Version 3.0
+#This file was generated 
+-->
+<VTKFile type="UnstructuredGrid" version="0.1" compressor="vtkZLibDataCompressor" byte_order="LittleEndian">
+<UnstructuredGrid>
+<Piece NumberOfPoints="54" NumberOfCells="30" >
+  <Points>
+    <DataArray type="Float32" NumberOfComponents="3" format="binary">
+</DataArray>
+  </Points>
+
+  <Cells>
+    <DataArray type="Int32" Name="connectivity" format="binary">
+</DataArray>
+    <DataArray type="Int32" Name="offsets" format="binary">
+</DataArray>
+    <DataArray type="UInt8" Name="types" format="binary">
+</DataArray>
+  </Cells>
+  <PointData Scalars="scalars">
+    <DataArray type="Float32" Name="x1" format="binary" units="kg/s">
+</DataArray>
+    <DataArray type="Float32" Name="x2" format="binary">
+</DataArray>
+    <DataArray type="Float32" Name="x3" format="binary" units="N/m">
+</DataArray>
+    <DataArray type="Float32" Name="x4" format="binary">
+</DataArray>
+    <DataArray type="Float32" Name="i" format="binary" units="J/K">
+</DataArray>
+  </PointData>
+ </Piece>
+ </UnstructuredGrid>
+</VTKFile>
+==============================
+23.vtu
+==============================
+<?xml version="1.0" ?> 
+<!-- 
+# vtk DataFile Version 3.0
+#This file was generated 
+-->
+<VTKFile type="UnstructuredGrid" version="0.1" compressor="vtkZLibDataCompressor" byte_order="LittleEndian">
+<UnstructuredGrid>
+<Piece NumberOfPoints="54" NumberOfCells="30" >
+  <Points>
+    <DataArray type="Float32" NumberOfComponents="3" format="binary">
+</DataArray>
+  </Points>
+
+  <Cells>
+    <DataArray type="Int32" Name="connectivity" format="binary">
+</DataArray>
+    <DataArray type="Int32" Name="offsets" format="binary">
+</DataArray>
+    <DataArray type="UInt8" Name="types" format="binary">
+</DataArray>
+  </Cells>
+  <PointData Scalars="scalars">
+    <DataArray type="Float32" Name="x1" format="binary" units="kg/s">
+</DataArray>
+    <DataArray type="Float32" Name="x2" format="binary">
+</DataArray>
+    <DataArray type="Float32" Name="x3" format="binary" units="N/m">
+</DataArray>
+    <DataArray type="Float32" Name="x4" format="binary">
+</DataArray>
+    <DataArray type="Float32" Name="i" format="binary" units="J/K">
+</DataArray>
+  </PointData>
+ </Piece>
+ </UnstructuredGrid>
+</VTKFile>
+==============================
+33.vtu
+==============================
+<?xml version="1.0" ?> 
+<!-- 
+# vtk DataFile Version 3.0
+#This file was generated 
+-->
+<VTKFile type="UnstructuredGrid" version="0.1" compressor="vtkZLibDataCompressor" byte_order="LittleEndian">
+<UnstructuredGrid>
+<Piece NumberOfPoints="224" NumberOfCells="100" >
+  <Points>
+    <DataArray type="Float32" NumberOfComponents="3" format="binary">
+</DataArray>
+  </Points>
+
+  <Cells>
+    <DataArray type="Int32" Name="connectivity" format="binary">
+</DataArray>
+    <DataArray type="Int32" Name="offsets" format="binary">
+</DataArray>
+    <DataArray type="UInt8" Name="types" format="binary">
+</DataArray>
+  </Cells>
+  <PointData Scalars="scalars">
+    <DataArray type="Float32" Name="x1" format="binary" units="kg/s">
+</DataArray>
+    <DataArray type="Float32" Name="x2" format="binary">
+</DataArray>
+    <DataArray type="Float32" Name="x3" format="binary" units="N/m">
+</DataArray>
+    <DataArray type="Float32" Name="x4" format="binary">
+</DataArray>
+    <DataArray type="Float32" Name="i" format="binary" units="J/K">
+</DataArray>
+  </PointData>
+ </Piece>
+ </UnstructuredGrid>
+</VTKFile>
diff --git a/tests/data_out/vtu_physical_units_02.cc b/tests/data_out/vtu_physical_units_02.cc
new file mode 100644 (file)
index 0000000..93a3676
--- /dev/null
@@ -0,0 +1,92 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2006 - 2020 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE.md at
+// the top level directory of deal.II.
+//
+// ---------------------------------------------------------------------
+
+
+// Check that one can output physical units along with output
+// fields. This test is for vector-valued quantities
+
+
+#include <deal.II/base/data_out_base.h>
+
+#include <string>
+#include <vector>
+
+#include "../tests.h"
+
+#include "patches.h"
+
+// Output data on repetitions of the unit hypercube
+
+template <int dim, int spacedim>
+void
+check(DataOutBase::VtkFlags flags, std::ostream &out)
+{
+  const unsigned int np = 4;
+
+  std::vector<DataOutBase::Patch<dim, spacedim>> patches(np);
+
+  create_patches(patches);
+
+  std::vector<std::string> names(5);
+  names[0] = "x1";
+  names[1] = "x2";
+  names[2] = "x3";
+  names[3] = "x4";
+  names[4] = "i";
+  for (unsigned int i = 1; i < 1 + dim; ++i)
+    names[i] = "v";
+
+  std::vector<
+    std::tuple<unsigned int,
+               unsigned int,
+               std::string,
+               DataComponentInterpretation::DataComponentInterpretation>>
+    vectors{{1,
+             1 + dim - 1,
+             "v",
+             DataComponentInterpretation::component_is_part_of_vector}};
+  DataOutBase::write_vtu(patches, names, vectors, flags, out);
+}
+
+
+template <int dim, int spacedim>
+void
+check_all(std::ostream &log)
+{
+  DataOutBase::VtkFlags flags;
+
+  // Set the units of some but not all output quantities
+  flags.physical_units["x1"] = "kg/s";
+  flags.physical_units["v"]  = "m/s";
+
+  log << "==============================" << std::endl
+      << dim << spacedim << ".vtu" << std::endl
+      << "==============================" << std::endl;
+  check<dim, spacedim>(flags, log);
+}
+
+int
+main()
+{
+  std::stringstream ss;
+  check_all<1, 1>(ss);
+  check_all<1, 2>(ss);
+  check_all<2, 2>(ss);
+  check_all<2, 3>(ss);
+  check_all<3, 3>(ss);
+
+  std::ofstream logfile("output");
+  filter_out_xml_key(ss, "DataArray", logfile);
+}
diff --git a/tests/data_out/vtu_physical_units_02.with_zlib=true.output b/tests/data_out/vtu_physical_units_02.with_zlib=true.output
new file mode 100644 (file)
index 0000000..0281f15
--- /dev/null
@@ -0,0 +1,187 @@
+==============================
+11.vtu
+==============================
+<?xml version="1.0" ?> 
+<!-- 
+# vtk DataFile Version 3.0
+#This file was generated 
+-->
+<VTKFile type="UnstructuredGrid" version="0.1" compressor="vtkZLibDataCompressor" byte_order="LittleEndian">
+<UnstructuredGrid>
+<Piece NumberOfPoints="14" NumberOfCells="10" >
+  <Points>
+    <DataArray type="Float32" NumberOfComponents="3" format="binary">
+</DataArray>
+  </Points>
+
+  <Cells>
+    <DataArray type="Int32" Name="connectivity" format="binary">
+</DataArray>
+    <DataArray type="Int32" Name="offsets" format="binary">
+</DataArray>
+    <DataArray type="UInt8" Name="types" format="binary">
+</DataArray>
+  </Cells>
+  <PointData Scalars="scalars">
+    <DataArray type="Float32" Name="v" NumberOfComponents="3" format="binary" units="m/s">
+</DataArray>
+    <DataArray type="Float32" Name="x1" format="binary" units="kg/s">
+</DataArray>
+    <DataArray type="Float32" Name="x3" format="binary">
+</DataArray>
+    <DataArray type="Float32" Name="x4" format="binary">
+</DataArray>
+    <DataArray type="Float32" Name="i" format="binary">
+</DataArray>
+  </PointData>
+ </Piece>
+ </UnstructuredGrid>
+</VTKFile>
+==============================
+12.vtu
+==============================
+<?xml version="1.0" ?> 
+<!-- 
+# vtk DataFile Version 3.0
+#This file was generated 
+-->
+<VTKFile type="UnstructuredGrid" version="0.1" compressor="vtkZLibDataCompressor" byte_order="LittleEndian">
+<UnstructuredGrid>
+<Piece NumberOfPoints="14" NumberOfCells="10" >
+  <Points>
+    <DataArray type="Float32" NumberOfComponents="3" format="binary">
+</DataArray>
+  </Points>
+
+  <Cells>
+    <DataArray type="Int32" Name="connectivity" format="binary">
+</DataArray>
+    <DataArray type="Int32" Name="offsets" format="binary">
+</DataArray>
+    <DataArray type="UInt8" Name="types" format="binary">
+</DataArray>
+  </Cells>
+  <PointData Scalars="scalars">
+    <DataArray type="Float32" Name="v" NumberOfComponents="3" format="binary" units="m/s">
+</DataArray>
+    <DataArray type="Float32" Name="x1" format="binary" units="kg/s">
+</DataArray>
+    <DataArray type="Float32" Name="x3" format="binary">
+</DataArray>
+    <DataArray type="Float32" Name="x4" format="binary">
+</DataArray>
+    <DataArray type="Float32" Name="i" format="binary">
+</DataArray>
+  </PointData>
+ </Piece>
+ </UnstructuredGrid>
+</VTKFile>
+==============================
+22.vtu
+==============================
+<?xml version="1.0" ?> 
+<!-- 
+# vtk DataFile Version 3.0
+#This file was generated 
+-->
+<VTKFile type="UnstructuredGrid" version="0.1" compressor="vtkZLibDataCompressor" byte_order="LittleEndian">
+<UnstructuredGrid>
+<Piece NumberOfPoints="54" NumberOfCells="30" >
+  <Points>
+    <DataArray type="Float32" NumberOfComponents="3" format="binary">
+</DataArray>
+  </Points>
+
+  <Cells>
+    <DataArray type="Int32" Name="connectivity" format="binary">
+</DataArray>
+    <DataArray type="Int32" Name="offsets" format="binary">
+</DataArray>
+    <DataArray type="UInt8" Name="types" format="binary">
+</DataArray>
+  </Cells>
+  <PointData Scalars="scalars">
+    <DataArray type="Float32" Name="v" NumberOfComponents="3" format="binary" units="m/s">
+</DataArray>
+    <DataArray type="Float32" Name="x1" format="binary" units="kg/s">
+</DataArray>
+    <DataArray type="Float32" Name="x4" format="binary">
+</DataArray>
+    <DataArray type="Float32" Name="i" format="binary">
+</DataArray>
+  </PointData>
+ </Piece>
+ </UnstructuredGrid>
+</VTKFile>
+==============================
+23.vtu
+==============================
+<?xml version="1.0" ?> 
+<!-- 
+# vtk DataFile Version 3.0
+#This file was generated 
+-->
+<VTKFile type="UnstructuredGrid" version="0.1" compressor="vtkZLibDataCompressor" byte_order="LittleEndian">
+<UnstructuredGrid>
+<Piece NumberOfPoints="54" NumberOfCells="30" >
+  <Points>
+    <DataArray type="Float32" NumberOfComponents="3" format="binary">
+</DataArray>
+  </Points>
+
+  <Cells>
+    <DataArray type="Int32" Name="connectivity" format="binary">
+</DataArray>
+    <DataArray type="Int32" Name="offsets" format="binary">
+</DataArray>
+    <DataArray type="UInt8" Name="types" format="binary">
+</DataArray>
+  </Cells>
+  <PointData Scalars="scalars">
+    <DataArray type="Float32" Name="v" NumberOfComponents="3" format="binary" units="m/s">
+</DataArray>
+    <DataArray type="Float32" Name="x1" format="binary" units="kg/s">
+</DataArray>
+    <DataArray type="Float32" Name="x4" format="binary">
+</DataArray>
+    <DataArray type="Float32" Name="i" format="binary">
+</DataArray>
+  </PointData>
+ </Piece>
+ </UnstructuredGrid>
+</VTKFile>
+==============================
+33.vtu
+==============================
+<?xml version="1.0" ?> 
+<!-- 
+# vtk DataFile Version 3.0
+#This file was generated 
+-->
+<VTKFile type="UnstructuredGrid" version="0.1" compressor="vtkZLibDataCompressor" byte_order="LittleEndian">
+<UnstructuredGrid>
+<Piece NumberOfPoints="224" NumberOfCells="100" >
+  <Points>
+    <DataArray type="Float32" NumberOfComponents="3" format="binary">
+</DataArray>
+  </Points>
+
+  <Cells>
+    <DataArray type="Int32" Name="connectivity" format="binary">
+</DataArray>
+    <DataArray type="Int32" Name="offsets" format="binary">
+</DataArray>
+    <DataArray type="UInt8" Name="types" format="binary">
+</DataArray>
+  </Cells>
+  <PointData Scalars="scalars">
+    <DataArray type="Float32" Name="v" NumberOfComponents="3" format="binary" units="m/s">
+</DataArray>
+    <DataArray type="Float32" Name="x1" format="binary" units="kg/s">
+</DataArray>
+    <DataArray type="Float32" Name="i" format="binary">
+</DataArray>
+  </PointData>
+ </Piece>
+ </UnstructuredGrid>
+</VTKFile>

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.