]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add another test, this time for parallel triangulations. 765/head
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Tue, 14 Apr 2015 01:41:47 +0000 (20:41 -0500)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Tue, 14 Apr 2015 01:41:47 +0000 (20:41 -0500)
tests/mpi/active_cell_index_01.cc [new file with mode: 0644]
tests/mpi/active_cell_index_01.mpirun=3.output [new file with mode: 0644]

diff --git a/tests/mpi/active_cell_index_01.cc b/tests/mpi/active_cell_index_01.cc
new file mode 100644 (file)
index 0000000..6fbfc6d
--- /dev/null
@@ -0,0 +1,76 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2010 - 2015 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 at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check that cell->active_cell_index() works as advertised
+
+#include "../tests.h"
+
+#include <deal.II/base/geometry_info.h>
+#include <deal.II/base/logstream.h>
+#include <deal.II/base/quadrature_lib.h>
+#include <deal.II/dofs/dof_accessor.h>
+#include <deal.II/distributed/tria.h>
+#include <deal.II/grid/tria_accessor.h>
+#include <deal.II/grid/grid_generator.h>
+
+#include <fstream>
+
+
+
+template <int dim>
+void check (const parallel::distributed::Triangulation<dim> &tria)
+{
+  unsigned int index = 0;
+  for (typename Triangulation<dim>::active_cell_iterator cell=tria.begin_active();
+      cell!=tria.end(); ++cell, ++index)
+    AssertThrow (cell->active_cell_index() == index, ExcInternalError());
+
+  AssertThrow (index == tria.n_active_cells(), ExcInternalError());
+  AssertThrow (index >= tria.n_locally_owned_active_cells(), ExcInternalError());
+}
+
+
+
+
+
+template <int dim>
+void check ()
+{
+  parallel::distributed::Triangulation<dim> tria(MPI_COMM_WORLD);
+  GridGenerator::hyper_cube (tria);
+  tria.refine_global (3);
+
+  DoFHandler<dim> dof_handler (tria);
+
+  check (tria);
+
+  if (Utilities::MPI::this_mpi_process (MPI_COMM_WORLD) == 0)
+    deallog << "OK for " << dim << "d" << std::endl;
+}
+
+
+int main (int argc, char *argv[])
+{
+  Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+  MPILogInitAll log;
+
+  check<2> ();
+  check<3> ();
+}
+
+
+
diff --git a/tests/mpi/active_cell_index_01.mpirun=3.output b/tests/mpi/active_cell_index_01.mpirun=3.output
new file mode 100644 (file)
index 0000000..cef4e00
--- /dev/null
@@ -0,0 +1,7 @@
+
+DEAL:0::OK for 2d
+DEAL:0::OK for 3d
+
+
+
+

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.