]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add test
authorRene Gassmoeller <rene.gassmoeller@mailbox.org>
Thu, 19 Jul 2018 00:48:48 +0000 (17:48 -0700)
committerRene Gassmoeller <rene.gassmoeller@mailbox.org>
Thu, 19 Jul 2018 00:48:48 +0000 (17:48 -0700)
tests/data_out/data_out_filter_02.cc [new file with mode: 0644]
tests/data_out/data_out_filter_02.with_hdf5=true.output [new file with mode: 0644]

diff --git a/tests/data_out/data_out_filter_02.cc b/tests/data_out/data_out_filter_02.cc
new file mode 100644 (file)
index 0000000..b48aaf0
--- /dev/null
@@ -0,0 +1,70 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2017 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.
+//
+// ---------------------------------------------------------------------
+
+// This test checks that writing empty vectors does not access unallocated memory.
+
+#include <deal.II/dofs/dof_handler.h>
+
+#include <deal.II/fe/fe_q.h>
+
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/tria.h>
+
+#include <deal.II/lac/sparsity_pattern.h>
+
+#include <deal.II/numerics/data_out.h>
+
+#include "../tests.h"
+
+
+
+template <int dim>
+void
+test()
+{
+  Triangulation<dim> tria(Triangulation<dim>::MeshSmoothing::none, true);
+  GridGenerator::hyper_cube(tria, 1., 2.);
+  tria.refine_global(1);
+
+  FE_Q<dim> fe1(1);
+
+  DoFHandler<dim> dof1(tria);
+  dof1.distribute_dofs(fe1);
+
+  Vector<double> v1(dof1.n_dofs());
+
+  DataOut<dim> data_out;
+  data_out.add_data_vector(dof1, v1, "linear");
+
+  DataOutBase::DataOutFilter data_filter(
+    DataOutBase::DataOutFilterFlags(true, false));
+
+  data_out.write_filtered_data(data_filter);
+
+  deallog << "Number of filtered nodes: " << data_filter.n_nodes() << std::endl;
+
+  deallog << "ok" << std::endl;
+}
+
+
+int
+main(int argc, char *argv[])
+{
+  initlog();
+  test<2>();
+  test<3>();
+
+  return 0;
+}
diff --git a/tests/data_out/data_out_filter_02.with_hdf5=true.output b/tests/data_out/data_out_filter_02.with_hdf5=true.output
new file mode 100644 (file)
index 0000000..1bb8db8
--- /dev/null
@@ -0,0 +1,5 @@
+
+DEAL::Number of filtered nodes: 0
+DEAL::ok
+DEAL::Number of filtered nodes: 0
+DEAL::ok

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.