]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add a test for shared::Triangulation. 17316/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Fri, 19 Jul 2024 21:13:54 +0000 (15:13 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Sat, 20 Jul 2024 03:03:52 +0000 (21:03 -0600)
tests/sharedtria/boundary_dofs_01.cc [new file with mode: 0644]
tests/sharedtria/boundary_dofs_01.with_metis=true.mpirun=1.output [new file with mode: 0644]
tests/sharedtria/boundary_dofs_01.with_metis=true.mpirun=2.output [new file with mode: 0644]
tests/sharedtria/boundary_dofs_01.with_metis=true.mpirun=4.output [new file with mode: 0644]

diff --git a/tests/sharedtria/boundary_dofs_01.cc b/tests/sharedtria/boundary_dofs_01.cc
new file mode 100644 (file)
index 0000000..f800cc6
--- /dev/null
@@ -0,0 +1,100 @@
+// ------------------------------------------------------------------------
+//
+// SPDX-License-Identifier: LGPL-2.1-or-later
+// Copyright (C) 2017 - 2022 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// Part of the source code is dual licensed under Apache-2.0 WITH
+// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
+// governing the source code and code contributions can be found in
+// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
+//
+// ------------------------------------------------------------------------
+
+// Check DoFTools::extract_boundary_dofs() with shared triangulations.
+
+#include <deal.II/distributed/shared_tria.h>
+
+#include <deal.II/dofs/dof_handler.h>
+#include <deal.II/dofs/dof_tools.h>
+
+#include <deal.II/fe/fe_q.h>
+
+#include <deal.II/grid/grid_generator.h>
+
+#include "../tests.h"
+
+
+
+template <int dim>
+void
+test()
+{
+  const MPI_Comm                       mpi_communicator = MPI_COMM_WORLD;
+  parallel::shared::Triangulation<dim> triangulation(mpi_communicator);
+
+  GridGenerator::hyper_cube(triangulation, 0, 1);
+  triangulation.refine_global(4);
+
+  FE_Q<dim>       fe(1);
+  DoFHandler<dim> dof_handler(triangulation);
+  dof_handler.distribute_dofs(fe);
+
+  deallog << "On process " << Utilities::MPI::this_mpi_process(mpi_communicator)
+          << std::endl;
+  deallog << "  centers of locally owned cells=";
+  for (const auto &cell : triangulation.active_cell_iterators())
+    if (cell->is_locally_owned())
+      deallog << cell->center() << ' ';
+  deallog << "\n  locally_owned_dofs=";
+  for (const auto i : dof_handler.locally_owned_dofs())
+    deallog << i << ' ';
+  deallog << "\n  boundary_dofs=";
+  for (const auto i : DoFTools::extract_boundary_dofs(dof_handler))
+    deallog << i << ' ';
+  deallog << std::endl;
+  deallog << std::endl;
+}
+
+
+int
+main(int argc, char **argv)
+{
+  try
+    {
+      Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+
+      MPILogInitAll all;
+
+      test<1>();
+    }
+  catch (std::exception &exc)
+    {
+      std::cerr << std::endl
+                << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Exception on processing: " << std::endl
+                << exc.what() << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+
+      return 1;
+    }
+  catch (...)
+    {
+      std::cerr << std::endl
+                << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Unknown exception!" << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      return 1;
+    }
+
+  return 0;
+}
diff --git a/tests/sharedtria/boundary_dofs_01.with_metis=true.mpirun=1.output b/tests/sharedtria/boundary_dofs_01.with_metis=true.mpirun=1.output
new file mode 100644 (file)
index 0000000..4e1e9fb
--- /dev/null
@@ -0,0 +1,6 @@
+
+DEAL:0::On process 0
+DEAL:0::  centers of locally owned cells=0.0312500 0.0937500 0.156250 0.218750 0.281250 0.343750 0.406250 0.468750 0.531250 0.593750 0.656250 0.718750 0.781250 0.843750 0.906250 0.968750 
+  locally_owned_dofs=0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 
+  boundary_dofs=0 16 
+DEAL:0::
diff --git a/tests/sharedtria/boundary_dofs_01.with_metis=true.mpirun=2.output b/tests/sharedtria/boundary_dofs_01.with_metis=true.mpirun=2.output
new file mode 100644 (file)
index 0000000..c058e7e
--- /dev/null
@@ -0,0 +1,13 @@
+
+DEAL:0::On process 0
+DEAL:0::  centers of locally owned cells=0.531250 0.593750 0.656250 0.718750 0.781250 0.843750 0.906250 0.968750 
+  locally_owned_dofs=0 1 2 3 4 5 6 7 8 
+  boundary_dofs=8 9 
+DEAL:0::
+
+DEAL:1::On process 1
+DEAL:1::  centers of locally owned cells=0.0312500 0.0937500 0.156250 0.218750 0.281250 0.343750 0.406250 0.468750 
+  locally_owned_dofs=9 10 11 12 13 14 15 16 
+  boundary_dofs=8 9 
+DEAL:1::
+
diff --git a/tests/sharedtria/boundary_dofs_01.with_metis=true.mpirun=4.output b/tests/sharedtria/boundary_dofs_01.with_metis=true.mpirun=4.output
new file mode 100644 (file)
index 0000000..8beb262
--- /dev/null
@@ -0,0 +1,27 @@
+
+DEAL:0::On process 0
+DEAL:0::  centers of locally owned cells=0.781250 0.843750 0.906250 0.968750 
+  locally_owned_dofs=0 1 2 3 4 
+  boundary_dofs=4 13 
+DEAL:0::
+
+DEAL:1::On process 1
+DEAL:1::  centers of locally owned cells=0.531250 0.593750 0.656250 0.718750 
+  locally_owned_dofs=5 6 7 8 
+  boundary_dofs=4 13 
+DEAL:1::
+
+
+DEAL:2::On process 2
+DEAL:2::  centers of locally owned cells=0.281250 0.343750 0.406250 0.468750 
+  locally_owned_dofs=9 10 11 12 
+  boundary_dofs=4 13 
+DEAL:2::
+
+
+DEAL:3::On process 3
+DEAL:3::  centers of locally owned cells=0.0312500 0.0937500 0.156250 0.218750 
+  locally_owned_dofs=13 14 15 16 
+  boundary_dofs=4 13 
+DEAL:3::
+

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.