From: Wolfgang Bangerth Date: Thu, 11 Jan 2018 14:11:14 +0000 (-0700) Subject: Add another test. X-Git-Tag: v9.0.0-rc1~579^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e7e1914499b0a653f160a064b87fc3e06393acb2;p=dealii.git Add another test. --- diff --git a/tests/trilinos/n_nonzeros_02_parallel.cc b/tests/trilinos/n_nonzeros_02_parallel.cc new file mode 100644 index 0000000000..ffd3025942 --- /dev/null +++ b/tests/trilinos/n_nonzeros_02_parallel.cc @@ -0,0 +1,106 @@ +// --------------------------------------------------------------------- +// +// 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 at +// the top level of the deal.II distribution. +// +// --------------------------------------------------------------------- + + + +// check n_nonzero_elements() for an empty matrix + +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include +#include + + +void test () +{ + parallel::distributed::Triangulation<2> tria (MPI_COMM_WORLD); + GridGenerator::hyper_cube (tria); + tria.refine_global (3); + + FE_Q<2> fe(1); + DoFHandler<2> dof_handler (tria); + dof_handler.distribute_dofs(fe); + + Table<2,DoFTools::Coupling> coupling (1,1); + coupling.fill (DoFTools::none); + + const IndexSet system_partitioning = dof_handler.locally_owned_dofs(); + IndexSet system_relevant_set; + DoFTools::extract_locally_relevant_dofs (dof_handler, + system_relevant_set); + + + // create an empty sparsity pattern + TrilinosWrappers::SparsityPattern sparsity; + sparsity.reinit (system_partitioning, + system_partitioning, + system_relevant_set, + MPI_COMM_WORLD); + DoFTools::make_sparsity_pattern (dof_handler, + coupling, sparsity, + ConstraintMatrix(), false, + Utilities::MPI:: + this_mpi_process(MPI_COMM_WORLD)); + sparsity.compress (); + + // attach a sparse matrix to it + TrilinosWrappers::SparseMatrix A; + A.reinit(sparsity); + + // see how many nonzero elements it reports + deallog << A.n_nonzero_elements() << std::endl; +} + + + +int main (int argc, char **argv) +{ + Utilities::MPI::MPI_InitFinalize mpi_initialization (argc, argv, 1); + MPILogInitAll log; + + try + { + test (); + } + catch (std::exception &exc) + { + deallog << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + deallog << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + deallog << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + deallog << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} diff --git a/tests/trilinos/n_nonzeros_02_parallel.mpirun=9.with_trilinos=true.with_mpi=true.output b/tests/trilinos/n_nonzeros_02_parallel.mpirun=9.with_trilinos=true.with_mpi=true.output new file mode 100644 index 0000000000..6c072d8b3d --- /dev/null +++ b/tests/trilinos/n_nonzeros_02_parallel.mpirun=9.with_trilinos=true.with_mpi=true.output @@ -0,0 +1,26 @@ + +DEAL:0::0 + +DEAL:1::0 + + +DEAL:2::0 + + +DEAL:3::0 + + +DEAL:4::0 + + +DEAL:5::0 + + +DEAL:6::0 + + +DEAL:7::0 + + +DEAL:8::0 +