]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Instantiate distribute_local_to_global for another combination of PETScWrapper objects 6322/head
authorDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Tue, 24 Apr 2018 22:33:13 +0000 (00:33 +0200)
committerDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Tue, 24 Apr 2018 22:33:56 +0000 (00:33 +0200)
source/lac/constraint_matrix.cc
tests/petsc_complex/assemble_01.cc [new file with mode: 0644]
tests/petsc_complex/assemble_01.with_mpi=true.mpirun=1.output [new file with mode: 0644]

index d4290717457a80fbd6f8bf50ec39d54607b83941..60f5876caa4e5ec65eed85dccccff86b903b3318 100644 (file)
@@ -1383,6 +1383,7 @@ MATRIX_FUNCTIONS(PETScWrappers::SparseMatrix,PetscScalar);
 MATRIX_FUNCTIONS(PETScWrappers::MPI::SparseMatrix,PetscScalar);
 BLOCK_MATRIX_FUNCTIONS(PETScWrappers::MPI::BlockSparseMatrix);
 MATRIX_VECTOR_FUNCTIONS(PETScWrappers::MPI::SparseMatrix, PETScWrappers::MPI::Vector);
+MATRIX_VECTOR_FUNCTIONS(PETScWrappers::SparseMatrix, PETScWrappers::MPI::Vector);
 BLOCK_MATRIX_VECTOR_FUNCTIONS(PETScWrappers::MPI::BlockSparseMatrix,PETScWrappers::MPI::BlockVector);
 #endif
 
diff --git a/tests/petsc_complex/assemble_01.cc b/tests/petsc_complex/assemble_01.cc
new file mode 100644 (file)
index 0000000..bcb1987
--- /dev/null
@@ -0,0 +1,69 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2018 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 that all the functionality needed for calling
+// ConstraintMatrix::distribute_local_to_global on mutiple combinations of
+// PETScWrappers objects is correctly instantiated and works.
+
+#include <deal.II/lac/petsc_sparse_matrix.h>
+#include <deal.II/lac/petsc_parallel_sparse_matrix.h>
+#include <deal.II/lac/petsc_parallel_vector.h>
+#include <deal.II/lac/full_matrix.h>
+#include <deal.II/lac/vector.h>
+#include <deal.II/lac/constraint_matrix.h>
+
+#include "../tests.h"
+
+
+int main (int argc,char **argv)
+{
+  Utilities::MPI::MPI_InitFinalize mpi_initialization (argc, argv, 1);
+  mpi_initlog();
+
+  const unsigned int n=4;
+
+  PETScWrappers::SparseMatrix      serial_matrix (n,n,n);
+  PETScWrappers::MPI::SparseMatrix mpi_matrix (MPI_COMM_WORLD,n,n,n,n,n);
+  PETScWrappers::MPI::Vector       mpi_vector (MPI_COMM_WORLD,n,n);
+
+  FullMatrix<PetscScalar>          cell_matrix (n, n);
+  Vector<PetscScalar>              cell_rhs (n);
+
+  ConstraintMatrix                 constraints;
+  constraints.close();
+
+  std::vector<types::global_dof_index> gdi(n);
+  std::iota(gdi.begin(), gdi.end(), 0);
+  std::iota(cell_rhs.begin(), cell_rhs.end(), 0);
+
+  for (unsigned int i=0; i<n; ++i)
+    for (unsigned int j=0; j<n; ++j)
+      cell_matrix(i,j) = i*n+j;
+
+  constraints.distribute_local_to_global (cell_matrix, cell_rhs, gdi,
+                                          serial_matrix, mpi_vector);
+  mpi_vector.compress(VectorOperation::add);
+  serial_matrix.compress(VectorOperation::add);
+  mpi_vector.print(deallog.get_file_stream());
+  serial_matrix.print(deallog.get_file_stream());
+
+  constraints.distribute_local_to_global (cell_matrix, cell_rhs, gdi,
+                                          mpi_matrix, mpi_vector);
+  mpi_vector.compress(VectorOperation::add);
+  mpi_matrix.compress(VectorOperation::add);
+  mpi_vector.print(deallog.get_file_stream());
+  mpi_matrix.print(deallog.get_file_stream());
+}
diff --git a/tests/petsc_complex/assemble_01.with_mpi=true.mpirun=1.output b/tests/petsc_complex/assemble_01.with_mpi=true.mpirun=1.output
new file mode 100644 (file)
index 0000000..ac7b985
--- /dev/null
@@ -0,0 +1,33 @@
+
+[Proc0 0-3] (0.000e+00,0.000e+00) (1.000e+00,0.000e+00) (2.000e+00,0.000e+00) (3.000e+00,0.000e+00) 
+(0,1) (1.00000,0.00000)
+(0,2) (2.00000,0.00000)
+(0,3) (3.00000,0.00000)
+(1,0) (4.00000,0.00000)
+(1,1) (5.00000,0.00000)
+(1,2) (6.00000,0.00000)
+(1,3) (7.00000,0.00000)
+(2,0) (8.00000,0.00000)
+(2,1) (9.00000,0.00000)
+(2,2) (10.0000,0.00000)
+(2,3) (11.0000,0.00000)
+(3,0) (12.0000,0.00000)
+(3,1) (13.0000,0.00000)
+(3,2) (14.0000,0.00000)
+(3,3) (15.0000,0.00000)
+[Proc0 0-3] (0.000e+00,0.000e+00) (2.000e+00,0.000e+00) (4.000e+00,0.000e+00) (6.000e+00,0.000e+00) 
+(0,1) (1.00000,0.00000)
+(0,2) (2.00000,0.00000)
+(0,3) (3.00000,0.00000)
+(1,0) (4.00000,0.00000)
+(1,1) (5.00000,0.00000)
+(1,2) (6.00000,0.00000)
+(1,3) (7.00000,0.00000)
+(2,0) (8.00000,0.00000)
+(2,1) (9.00000,0.00000)
+(2,2) (10.0000,0.00000)
+(2,3) (11.0000,0.00000)
+(3,0) (12.0000,0.00000)
+(3,1) (13.0000,0.00000)
+(3,2) (14.0000,0.00000)
+(3,3) (15.0000,0.00000)

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.