From: Martin Kronbichler Date: Thu, 16 Apr 2015 06:49:10 +0000 (+0200) Subject: Add test for empty processors (communicated by D. Arndt). X-Git-Tag: v8.3.0-rc1~268^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F810%2Fhead;p=dealii.git Add test for empty processors (communicated by D. Arndt). --- diff --git a/tests/trilinos/trilinos_sparsity_pattern.cc b/tests/trilinos/trilinos_sparsity_pattern_01.cc similarity index 100% rename from tests/trilinos/trilinos_sparsity_pattern.cc rename to tests/trilinos/trilinos_sparsity_pattern_01.cc diff --git a/tests/trilinos/trilinos_sparsity_pattern.output b/tests/trilinos/trilinos_sparsity_pattern_01.output similarity index 100% rename from tests/trilinos/trilinos_sparsity_pattern.output rename to tests/trilinos/trilinos_sparsity_pattern_01.output diff --git a/tests/trilinos/trilinos_sparsity_pattern_02.cc b/tests/trilinos/trilinos_sparsity_pattern_02.cc new file mode 100644 index 0000000000..b1ec23b980 --- /dev/null +++ b/tests/trilinos/trilinos_sparsity_pattern_02.cc @@ -0,0 +1,201 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2009 - 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. +// +// --------------------------------------------------------------------- + + + +// tests setup of Trilinos sparsity patterns when some processors do not have +// any cells. + +#include "../tests.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Step22 +{ + using namespace dealii; + + template + class StokesProblem + { + public: + StokesProblem (const unsigned int degree); + void run (); + + private: + void setup_dofs (); + + const unsigned int degree; + + MPI_Comm mpi_communicator; + + HyperShellBoundary boundary; + parallel::distributed::Triangulation triangulation; + FESystem fe; + DoFHandler dof_handler; + + ConstraintMatrix constraints; + std::vector owned_partitioning; + std::vector relevant_partitioning; + }; + + + + + + template + StokesProblem::StokesProblem (const unsigned int degree) + : + degree (degree), + mpi_communicator (MPI_COMM_WORLD), + triangulation (mpi_communicator/*, + Triangulation::maximum_smoothing*/), + fe (FE_Q(degree+1), dim, + FE_Q(degree) , 1), + dof_handler (triangulation) +{} + + + + + template + void StokesProblem::setup_dofs () + { + dof_handler.distribute_dofs (fe); + + std::vector block_component (dim+1,0); + block_component[dim] = 1; + DoFRenumbering::component_wise (dof_handler, block_component); + + std::vector dofs_per_block (2); + DoFTools::count_dofs_per_block (dof_handler, dofs_per_block, block_component); + const unsigned int n_u = dofs_per_block[0], + n_p = dofs_per_block[1]; + + { + owned_partitioning.clear(); + IndexSet locally_owned_dofs = dof_handler.locally_owned_dofs(); + owned_partitioning.push_back(locally_owned_dofs.get_view(0, n_u)); + owned_partitioning.push_back(locally_owned_dofs.get_view(n_u, n_u+n_p)); + + relevant_partitioning.clear(); + IndexSet locally_relevant_dofs; + DoFTools::extract_locally_relevant_dofs (dof_handler, locally_relevant_dofs); + relevant_partitioning.push_back(locally_relevant_dofs.get_view(0, n_u)); + relevant_partitioning.push_back(locally_relevant_dofs.get_view(n_u, n_u+n_p)); + } + + ConstraintMatrix new_constraints; + new_constraints.close(); + { + TrilinosWrappers::BlockSparsityPattern bsp + (owned_partitioning, owned_partitioning, + relevant_partitioning, mpi_communicator); + DoFTools::make_sparsity_pattern (dof_handler, bsp, + new_constraints, + false, Utilities::MPI::this_mpi_process(mpi_communicator)); + + bsp.compress(); + } + } + + + + + template + void StokesProblem::run () + { + Point center; + const double inner_radius = .5; + const double outer_radius = 1.; + + GridGenerator::quarter_hyper_shell (triangulation, + center, + inner_radius, + outer_radius, + 0, + true); + + triangulation.set_boundary(0, boundary); + triangulation.set_boundary(1, boundary); + setup_dofs (); + + + deallog << "OK" << std::endl; + } +} + + + +int main (int argc, char *argv[]) +{ + try + { + using namespace dealii; + using namespace Step22; + + Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1); + deallog.depth_console (0); + + if (Utilities::MPI::this_mpi_process (MPI_COMM_WORLD)==0) + { + std::ofstream logfile("output"); + deallog.attach(logfile, false); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + { + StokesProblem<3> flow_problem(1); + flow_problem.run (); + } + } + else + { + StokesProblem<3> flow_problem(1); + flow_problem.run (); + } + } + 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/trilinos/trilinos_sparsity_pattern_02.mpirun=4.output b/tests/trilinos/trilinos_sparsity_pattern_02.mpirun=4.output new file mode 100644 index 0000000000..559e3f5f1a --- /dev/null +++ b/tests/trilinos/trilinos_sparsity_pattern_02.mpirun=4.output @@ -0,0 +1 @@ +DEAL::OK