]> https://gitweb.dealii.org/ - dealii.git/commitdiff
fix petsc_complex/parallel_sparse_matrix_01
authorDenis Davydov <davydden@gmail.com>
Mon, 7 Mar 2016 10:15:14 +0000 (11:15 +0100)
committerDenis Davydov <davydden@gmail.com>
Sat, 12 Mar 2016 18:55:08 +0000 (19:55 +0100)
tests/petsc_complex/fe_get_function_values.cc
tests/petsc_complex/parallel_sparse_matrix_01.cc
tests/petsc_complex/parallel_sparse_matrix_01.mpirun=3.output

index 9aca85dff68c14026998416b1eb4082bde9b713e..f7b01896abdf86650ff3a84faf4656afdf20c0a1 100644 (file)
@@ -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;
index 5eb530915e52bcc8779097278d7ac8edf3f514e2..52cca9918fd06162f9fef9230d8a9e83432ae601 100644 (file)
@@ -39,6 +39,8 @@
 #include <deal.II/lac/vector.h>
 #include <deal.II/lac/full_matrix.h>
 #include <deal.II/lac/constraint_matrix.h>
+#include <deal.II/lac/dynamic_sparsity_pattern.h>
+#include <deal.II/lac/sparsity_tools.h>
 
 #include <deal.II/lac/petsc_parallel_vector.h>
 #include <deal.II/lac/petsc_parallel_sparse_matrix.h>
@@ -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<dim> quadrature_formula(poly_degree+1);
     FEValues<dim> 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)<<std::endl;
-  deallog<<"hermitian: "<<(mass_matrix.is_hermitian()==PETSC_TRUE)<<std::endl;
-
   PETScWrappers::MPI::Vector tmp(vector);
   mass_matrix.vmult (tmp, vector);
+  //mass_matrix.Tvmult (tmp, vector);
 
   const std::complex<double> norm1 = vector*tmp;
   deallog<<"(conj(vector),M vector): "<<std::endl;
@@ -188,11 +193,35 @@ int main (int argc, char *argv[])
 {
   std::ofstream logfile("output");
   deallog.attach(logfile);
-  deallog.depth_console(0);
   deallog.threshold_double(1.e-10);
 
-  Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
-  {
-    test<2>();
-  }
+  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;
+    };
 }
index a75f75beb6ab9232917f73752eac83cc7b14e84d..f7d89f6afca3a8b580acf312058d94f8e2ded56d 100644 (file)
@@ -1,6 +1,4 @@
 
-DEAL::symmetric: 1
-DEAL::hermitian: 1
 DEAL::(conj(vector),M vector): 
 DEAL::real part:      337.563
 DEAL::imaginary part: 0

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.