]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
New test.
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 9 Jan 2013 17:18:38 +0000 (17:18 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 9 Jan 2013 17:18:38 +0000 (17:18 +0000)
git-svn-id: https://svn.dealii.org/trunk@27997 0785d39b-7218-0410-832d-ea1e28bc413d

tests/mpi/constraint_matrix_condense_01.cc [new file with mode: 0644]
tests/mpi/constraint_matrix_condense_01/ncpu_1/cmp/generic [new file with mode: 0644]
tests/mpi/constraint_matrix_condense_01/ncpu_10/cmp/generic [new file with mode: 0644]
tests/mpi/constraint_matrix_condense_01/ncpu_4/cmp/generic [new file with mode: 0644]

diff --git a/tests/mpi/constraint_matrix_condense_01.cc b/tests/mpi/constraint_matrix_condense_01.cc
new file mode 100644 (file)
index 0000000..48c458f
--- /dev/null
@@ -0,0 +1,99 @@
+//---------------------------------------------------------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 2013 by the deal.II authors
+//
+//    This file is subject to QPL and may not be  distributed
+//    without copyright and license information. Please refer
+//    to the file deal.II/doc/license.html for the  text  and
+//    further information on this license.
+//
+//---------------------------------------------------------------------------
+
+
+// check ConstraintMatrix::condense(Vector) for parallel vectors. this
+// function used to crash
+//
+// original test case by Daniel Arndt
+
+#include "../tests.h"
+#include <deal.II/base/logstream.h>
+#include <deal.II/lac/petsc_parallel_vector.h>
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/dofs/dof_tools.h>
+#include <deal.II/fe/fe_q.h>
+#include <fstream>
+
+
+void test ()
+{
+  MPI_Comm mpi_communicator (MPI_COMM_WORLD);
+  parallel::distributed::Triangulation<3> triangulation(mpi_communicator);
+
+  FE_Q<3>          fe(1);
+
+  DoFHandler<3>    dof_handler(triangulation);
+  GridGenerator::hyper_cube (triangulation);
+  triangulation.refine_global (1);
+
+  dof_handler.distribute_dofs (fe);
+
+  IndexSet           locally_owned_dofs;
+  locally_owned_dofs = dof_handler.locally_owned_dofs();
+  IndexSet           locally_relevant_dofs;
+  DoFTools::extract_locally_relevant_dofs (dof_handler,locally_relevant_dofs);
+
+  PETScWrappers::MPI::Vector force;
+  force.reinit (mpi_communicator, locally_owned_dofs, locally_relevant_dofs);
+
+  ConstraintMatrix constraints (locally_relevant_dofs);
+  constraints.clear();
+  {
+    constraints.reinit (locally_relevant_dofs);
+    IndexSet boundary_dofs (dof_handler.n_dofs());
+    DoFTools::extract_boundary_dofs
+      (dof_handler, std::vector<bool>(1,true),boundary_dofs);
+
+    unsigned int first_nboundary_dof = 0;
+    while(boundary_dofs.is_element(first_nboundary_dof))
+      first_nboundary_dof++;
+
+    constraints.add_line (first_nboundary_dof);
+    for (unsigned int i=0; i<dof_handler.n_dofs();++i)
+      if (boundary_dofs.is_element(i) == true)
+       constraints.add_entry (first_nboundary_dof, i, -1);
+  }
+  constraints.close();
+
+  force=0.;
+  force.compress();
+  constraints.condense(force);
+}
+
+
+int main(int argc, char *argv[])
+{
+  Utilities::MPI::MPI_InitFinalize mpi (argc, argv);
+  PetscInitialize(&argc,&argv,0,0);
+
+  unsigned int myid = Utilities::MPI::this_mpi_process (MPI_COMM_WORLD);
+
+  if (myid == 0)
+    {
+      std::ofstream logfile(output_file_for_mpi("constraint_matrix_condense_01").c_str());
+      deallog.attach(logfile);
+      deallog << std::setprecision(4);
+      deallog.depth_console(0);
+      deallog.threshold_double(1.e-10);
+
+      test();
+
+      deallog << "OK" << std::endl;
+    }
+  else
+    test();
+
+  PetscFinalize();
+  return 0;
+}
diff --git a/tests/mpi/constraint_matrix_condense_01/ncpu_1/cmp/generic b/tests/mpi/constraint_matrix_condense_01/ncpu_1/cmp/generic
new file mode 100644 (file)
index 0000000..0fd8fc1
--- /dev/null
@@ -0,0 +1,2 @@
+
+DEAL::OK
diff --git a/tests/mpi/constraint_matrix_condense_01/ncpu_10/cmp/generic b/tests/mpi/constraint_matrix_condense_01/ncpu_10/cmp/generic
new file mode 100644 (file)
index 0000000..3e957eb
--- /dev/null
@@ -0,0 +1,6 @@
+
+DEAL:mpi::Running on 10 CPU(s).
+DEAL:mpi::sum: 0 avg: 0 min: 0 @0 max: 0 @0
+DEAL:mpi::sum: 10.0000 avg: 1.00000 min: 1.00000 @0 max: 1.00000 @0
+DEAL:mpi::sum: 1.00000 avg: 0.100000 min: 0 @1 max: 1.00000 @0
+DEAL:mpi::done
diff --git a/tests/mpi/constraint_matrix_condense_01/ncpu_4/cmp/generic b/tests/mpi/constraint_matrix_condense_01/ncpu_4/cmp/generic
new file mode 100644 (file)
index 0000000..8499f78
--- /dev/null
@@ -0,0 +1,6 @@
+
+DEAL:mpi::Running on 4 CPU(s).
+DEAL:mpi::sum: 0 avg: 0 min: 0 @0 max: 0 @0
+DEAL:mpi::sum: 4.00000 avg: 1.00000 min: 1.00000 @0 max: 1.00000 @0
+DEAL:mpi::sum: 1.00000 avg: 0.250000 min: 0 @1 max: 1.00000 @0
+DEAL:mpi::done

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.