From: Denis Davydov Date: Mon, 7 Mar 2016 10:15:14 +0000 (+0100) Subject: fix petsc_complex/parallel_sparse_matrix_01 X-Git-Tag: v8.5.0-rc1~1217^2~5 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=04a22bb05085ddddf4791ed662f806975d08a43f;p=dealii.git fix petsc_complex/parallel_sparse_matrix_01 --- diff --git a/tests/petsc_complex/fe_get_function_values.cc b/tests/petsc_complex/fe_get_function_values.cc index 9aca85dff6..f7b01896ab 100644 --- a/tests/petsc_complex/fe_get_function_values.cc +++ b/tests/petsc_complex/fe_get_function_values.cc @@ -105,7 +105,7 @@ void test () DoFTools::make_hanging_node_constraints (dof_handler, constraints); constraints.close (); //set vector: - unsigned int myid = Utilities::MPI::this_mpi_process (MPI_COMM_WORLD); + unsigned int myid = Utilities::MPI::this_mpi_process (mpi_communicator); for (unsigned int i = 0; i < locally_owned_dofs.n_elements(); i++) { const PetscScalar val = 1.0+myid+ (myid+i%2)*2.0*PETSC_i; diff --git a/tests/petsc_complex/parallel_sparse_matrix_01.cc b/tests/petsc_complex/parallel_sparse_matrix_01.cc index 5eb530915e..52cca9918f 100644 --- a/tests/petsc_complex/parallel_sparse_matrix_01.cc +++ b/tests/petsc_complex/parallel_sparse_matrix_01.cc @@ -39,6 +39,8 @@ #include #include #include +#include +#include #include #include @@ -78,21 +80,27 @@ void test (const unsigned int poly_degree = 1) vector.reinit(locally_owned_dofs, mpi_communicator); - const types::global_dof_index n_local_dofs = locally_owned_dofs.n_elements(); - mass_matrix.reinit (mpi_communicator, - dof_handler.n_dofs(), - dof_handler.n_dofs(), - n_local_dofs, - n_local_dofs, - dof_handler.max_couplings_between_dofs()); ConstraintMatrix constraints; constraints.reinit(locally_relevant_dofs); DoFTools::make_hanging_node_constraints (dof_handler, constraints); constraints.close (); + DynamicSparsityPattern dsp (locally_relevant_dofs); + DoFTools::make_sparsity_pattern (dof_handler, dsp, + constraints, false); + SparsityTools::distribute_sparsity_pattern (dsp, + dof_handler.n_locally_owned_dofs_per_processor(), + mpi_communicator, + locally_relevant_dofs); + + mass_matrix.reinit (locally_owned_dofs, + locally_owned_dofs, + dsp, + mpi_communicator); + //assemble mass matrix: - mass_matrix = 0.0; + mass_matrix = PetscScalar(); { QGauss quadrature_formula(poly_degree+1); FEValues fe_values (fe, quadrature_formula, @@ -125,12 +133,11 @@ void test (const unsigned int poly_degree = 1) } cell->get_dof_indices (local_dof_indices); - - constraints - .distribute_local_to_global (cell_mass_matrix, - local_dof_indices, - mass_matrix); + constraints.distribute_local_to_global (cell_mass_matrix, + local_dof_indices, + mass_matrix); } + mass_matrix.compress (VectorOperation::add); } @@ -159,11 +166,9 @@ void test (const unsigned int poly_degree = 1) vector.compress(VectorOperation::insert); constraints.distribute(vector); - deallog<<"symmetric: "<<(mass_matrix.is_symmetric()==PETSC_TRUE)< norm1 = vector*tmp; deallog<<"(conj(vector),M vector): "<(); - } + try + { + Utilities::MPI::MPI_InitFinalize mpi_initialization (argc, argv, 1); + test<2>(); + } + 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; + }; } diff --git a/tests/petsc_complex/parallel_sparse_matrix_01.mpirun=3.output b/tests/petsc_complex/parallel_sparse_matrix_01.mpirun=3.output index a75f75beb6..f7d89f6afc 100644 --- a/tests/petsc_complex/parallel_sparse_matrix_01.mpirun=3.output +++ b/tests/petsc_complex/parallel_sparse_matrix_01.mpirun=3.output @@ -1,6 +1,4 @@ -DEAL::symmetric: 1 -DEAL::hermitian: 1 DEAL::(conj(vector),M vector): DEAL::real part: 337.563 DEAL::imaginary part: 0