]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Test output of a simplex cell with n_subdivisions=2. 14661/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Tue, 10 Jan 2023 17:03:09 +0000 (10:03 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Tue, 10 Jan 2023 17:03:09 +0000 (10:03 -0700)
tests/data_out/write_subdivided_simplex_vtu.cc [new file with mode: 0644]
tests/data_out/write_subdivided_simplex_vtu.output [new file with mode: 0644]

diff --git a/tests/data_out/write_subdivided_simplex_vtu.cc b/tests/data_out/write_subdivided_simplex_vtu.cc
new file mode 100644 (file)
index 0000000..f05b089
--- /dev/null
@@ -0,0 +1,91 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2020 - 2021 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// Test DataOut::write_vtu() for a single simplex subdivided more than once.
+
+#include <deal.II/dofs/dof_handler.h>
+
+#include <deal.II/fe/fe_simplex_p.h>
+#include <deal.II/fe/mapping_fe.h>
+
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/tria.h>
+
+#include <deal.II/numerics/data_out.h>
+#include <deal.II/numerics/vector_tools.h>
+
+#include "../tests.h"
+
+using namespace dealii;
+
+template <int dim>
+class RightHandSideFunction : public Function<dim>
+{
+public:
+  virtual double
+  value(const Point<dim> &p, const unsigned int component = 0) const
+  {
+    return p * p;
+  }
+};
+
+
+template <int dim, int spacedim = dim>
+void
+test()
+{
+  Triangulation<dim, spacedim> tria;
+  GridGenerator::reference_cell(tria, ReferenceCells::get_simplex<dim>());
+
+  // Use a quadratic element; this can correctly represent the
+  // quadratic function we are interpolating
+  FE_SimplexP<dim> fe(2);
+  DoFHandler<dim>  dof_handler(tria);
+
+  dof_handler.distribute_dofs(fe);
+
+  Vector<double> solution(dof_handler.n_dofs());
+
+  MappingFE<dim> mapping(FE_SimplexP<dim>(1));
+
+  VectorTools::interpolate(mapping,
+                           dof_handler,
+                           RightHandSideFunction<dim>(),
+                           solution);
+
+  // Switch off compression to make the resulting file easier to read
+  // as a human
+  DataOutBase::VtkFlags flags;
+  flags.compression_level = DataOutBase::CompressionLevel::plain_text;
+
+  DataOut<dim> data_out;
+  data_out.attach_dof_handler(dof_handler);
+  data_out.add_data_vector(solution, "solution");
+  data_out.build_patches(mapping, 2);
+
+  data_out.set_flags(flags);
+  data_out.write_vtu(deallog.get_file_stream());
+}
+
+int
+main()
+{
+  initlog();
+
+  test<2>();
+  test<3>();
+}
diff --git a/tests/data_out/write_subdivided_simplex_vtu.output b/tests/data_out/write_subdivided_simplex_vtu.output
new file mode 100644 (file)
index 0000000..da841b3
--- /dev/null
@@ -0,0 +1,67 @@
+
+<?xml version="1.0" ?> 
+<!-- 
+# vtk DataFile Version 3.0
+#This file was generated 
+-->
+<VTKFile type="UnstructuredGrid" version="0.1" byte_order="LittleEndian">
+<UnstructuredGrid>
+<Piece NumberOfPoints="6" NumberOfCells="1" >
+  <Points>
+    <DataArray type="Float32" NumberOfComponents="3" format="ascii">
+0 0 0 1 0 0 0 1 0 0.5 0 0 0.5 0.5 0 0 0.5 0 
+    </DataArray>
+  </Points>
+
+  <Cells>
+    <DataArray type="Int32" Name="connectivity" format="ascii">
+       0       1       2       3       4       5
+    </DataArray>
+    <DataArray type="Int32" Name="offsets" format="ascii">
+6 
+    </DataArray>
+    <DataArray type="UInt8" Name="types" format="ascii">
+22 
+    </DataArray>
+  </Cells>
+  <PointData Scalars="scalars">
+    <DataArray type="Float32" Name="solution" format="ascii">
+0 1 1 0.25 0.5 0.25 
+    </DataArray>
+  </PointData>
+ </Piece>
+ </UnstructuredGrid>
+</VTKFile>
+<?xml version="1.0" ?> 
+<!-- 
+# vtk DataFile Version 3.0
+#This file was generated 
+-->
+<VTKFile type="UnstructuredGrid" version="0.1" byte_order="LittleEndian">
+<UnstructuredGrid>
+<Piece NumberOfPoints="10" NumberOfCells="1" >
+  <Points>
+    <DataArray type="Float32" NumberOfComponents="3" format="ascii">
+0 0 0 1 0 0 0 1 0 0 0 1 0.5 0 0 0.5 0.5 0 0 0.5 0 0 0 0.5 0.5 0 0.5 0 0.5 0.5 
+    </DataArray>
+  </Points>
+
+  <Cells>
+    <DataArray type="Int32" Name="connectivity" format="ascii">
+       0       1       2       3       4       5       6       7       8       9
+    </DataArray>
+    <DataArray type="Int32" Name="offsets" format="ascii">
+10 
+    </DataArray>
+    <DataArray type="UInt8" Name="types" format="ascii">
+24 
+    </DataArray>
+  </Cells>
+  <PointData Scalars="scalars">
+    <DataArray type="Float32" Name="solution" format="ascii">
+0 1 1 1 0.25 0.5 0.25 0.25 0.5 0.5 
+    </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.