From 163e826540fe280427989679ceafe11ec64ca822 Mon Sep 17 00:00:00 2001 From: heister Date: Fri, 7 Jun 2013 21:58:14 +0000 Subject: [PATCH] add test documenting a crash git-svn-id: https://svn.dealii.org/branches/branch_unify_linear_algebra@29799 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/gla/mat_03.cc | 128 +++++++++++++++++++++++++++ tests/gla/mat_03/ncpu_1/cmp/generic | 5 ++ tests/gla/mat_03/ncpu_10/cmp/generic | 27 ++++++ tests/gla/mat_03/ncpu_2/cmp/generic | 15 ++++ 4 files changed, 175 insertions(+) create mode 100644 tests/gla/mat_03.cc create mode 100644 tests/gla/mat_03/ncpu_1/cmp/generic create mode 100644 tests/gla/mat_03/ncpu_10/cmp/generic create mode 100644 tests/gla/mat_03/ncpu_2/cmp/generic diff --git a/tests/gla/mat_03.cc b/tests/gla/mat_03.cc new file mode 100644 index 0000000000..da21a88705 --- /dev/null +++ b/tests/gla/mat_03.cc @@ -0,0 +1,128 @@ +//--------------------------------------------------------------------------- +// $Id: ghost_01.cc 28440 2013-02-17 14:35:08Z heister $ +// Version: $Name$ +// +// Copyright (C) 2004, 2005, 2010 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. +// +//--------------------------------------------------------------------------- + + +// document bug in assembling a LA::MPI::SparseMatrix + +#include "../tests.h" +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "gla.h" + +template +void test () +{ + unsigned int myid = Utilities::MPI::this_mpi_process (MPI_COMM_WORLD); + unsigned int numproc = Utilities::MPI::n_mpi_processes (MPI_COMM_WORLD); + + if (myid==0) + deallog << "numproc=" << numproc << std::endl; + + ConstraintMatrix cm; + cm.close(); + + parallel::distributed::Triangulation + triangulation (MPI_COMM_WORLD, + typename Triangulation::MeshSmoothing + (Triangulation::smoothing_on_refinement | + Triangulation::smoothing_on_coarsening)); + const double R0 = 6371000.-2890000; + const double R1 = 6371000.- 35000.; + GridGenerator::hyper_shell (triangulation, + Point(), + R0, + R1, + (dim==3) ? 96 : 12, + true); + + FE_Q temperature_fe(2); + + DoFHandler dof_handler(triangulation); + dof_handler.distribute_dofs (temperature_fe); + + IndexSet owned = dof_handler.locally_owned_dofs(); + IndexSet relevant; + DoFTools::extract_locally_relevant_dofs (dof_handler, relevant); + + CompressedSimpleSparsityPattern sp (owned); + typename LA::MPI::SparseMatrix matrix; + DoFTools::make_sparsity_pattern (dof_handler, sp, + cm, false, + Utilities::MPI:: + this_mpi_process(MPI_COMM_WORLD)); + SparsityTools::distribute_sparsity_pattern(sp, + dof_handler.n_locally_owned_dofs_per_processor(), + MPI_COMM_WORLD, relevant); + sp.compress(); + matrix.reinit (owned, owned, sp, MPI_COMM_WORLD); + + FullMatrix local_mat(9,9); + for (unsigned int i=0;i<9;++i) + for (unsigned int j=0;j<9;++j) + local_mat(i,j)=1 + i + 100*j; + std::vector local_dofs; + + if (myid==0) + { + unsigned int v[]={0, 1, 2, 3, 4, 5, 6, 7, 8}; + local_dofs.assign(v,v+9); + } + else + { + unsigned int v[]={21, 39, 22, 40, 23, 41, 42, 43, 44}; + local_dofs.assign(v,v+9); + } + cm.distribute_local_to_global (local_mat, local_dofs, matrix); + matrix.compress(VectorOperation::add); + + // done + if (myid==0) + deallog << "OK" << std::endl; +} + + + +int main (int argc, char **argv) +{ + Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1); + MPILogInitAll log(__FILE__); + + { + deallog.push("PETSc"); + test(); + deallog.pop(); + deallog.push("Trilinos"); + test(); + deallog.pop(); + } + + // compile, don't run + //if (myid==9999) + // test(); + + +} diff --git a/tests/gla/mat_03/ncpu_1/cmp/generic b/tests/gla/mat_03/ncpu_1/cmp/generic new file mode 100644 index 0000000000..21c3eab003 --- /dev/null +++ b/tests/gla/mat_03/ncpu_1/cmp/generic @@ -0,0 +1,5 @@ + +DEAL:0:PETSc::numproc=1 +DEAL:0:PETSc::OK +DEAL:0:Trilinos::numproc=1 +DEAL:0:Trilinos::OK diff --git a/tests/gla/mat_03/ncpu_10/cmp/generic b/tests/gla/mat_03/ncpu_10/cmp/generic new file mode 100644 index 0000000000..2992115b7d --- /dev/null +++ b/tests/gla/mat_03/ncpu_10/cmp/generic @@ -0,0 +1,27 @@ + +DEAL:0:PETSc::numproc=10 +DEAL:0:PETSc::(0,0) = 0.00000 +DEAL:0:PETSc::(1,1) = 13.0000 +DEAL:0:PETSc::OK +DEAL:0:Trilinos::numproc=10 +DEAL:0:Trilinos::(0,0) = 0.00000 +DEAL:0:Trilinos::(1,1) = 13.0000 +DEAL:0:Trilinos::OK + + + + + + + + + + + + + + + + + + diff --git a/tests/gla/mat_03/ncpu_2/cmp/generic b/tests/gla/mat_03/ncpu_2/cmp/generic new file mode 100644 index 0000000000..2f892b4d09 --- /dev/null +++ b/tests/gla/mat_03/ncpu_2/cmp/generic @@ -0,0 +1,15 @@ + +DEAL:0:PETSc::numproc=4 +DEAL:0:PETSc::(0,0) = 0.00000 +DEAL:0:PETSc::(1,1) = 5.20000 +DEAL:0:PETSc::OK +DEAL:0:Trilinos::numproc=4 +DEAL:0:Trilinos::(0,0) = 0.00000 +DEAL:0:Trilinos::(1,1) = 5.20000 +DEAL:0:Trilinos::OK + + + + + + -- 2.39.5