]> https://gitweb.dealii.org/ - dealii.git/commitdiff
add test
authorTimo Heister <timo.heister@gmail.com>
Thu, 6 Jun 2013 21:38:11 +0000 (21:38 +0000)
committerTimo Heister <timo.heister@gmail.com>
Thu, 6 Jun 2013 21:38:11 +0000 (21:38 +0000)
git-svn-id: https://svn.dealii.org/branches/branch_unify_linear_algebra@29787 0785d39b-7218-0410-832d-ea1e28bc413d

tests/gla/vec_03.cc [new file with mode: 0644]
tests/gla/vec_03/ncpu_10/cmp/generic [new file with mode: 0644]
tests/gla/vec_03/ncpu_4/cmp/generic [new file with mode: 0644]

diff --git a/tests/gla/vec_03.cc b/tests/gla/vec_03.cc
new file mode 100644 (file)
index 0000000..ef79708
--- /dev/null
@@ -0,0 +1,104 @@
+//---------------------------------------------------------------------------
+//    $Id: ghost_01.cc 28440 2013-02-17 14:35:08Z heister $
+//    Version: $Name$ 
+//
+//    Copyright (C) 2004, 2005, 2010 by the deal.II authors
+//
+//    This file is subject to QPL and may not be  distributed
+//    without copyright and license information. Please refer
+//    to the file deal.II/doc/license.html for the  text  and
+//    further information on this license.
+//
+//---------------------------------------------------------------------------
+
+
+// assignment of ghost vectors
+
+#include "../tests.h"
+#include <deal.II/lac/generic_linear_algebra.h>
+#include <deal.II/base/index_set.h>
+#include <deal.II/lac/constraint_matrix.h>
+#include <fstream>
+#include <iostream>
+#include <iomanip>
+#include <vector>
+
+#include "gla.h"
+
+template <class LA> 
+void test ()
+{
+  unsigned int myid = Utilities::MPI::this_mpi_process (MPI_COMM_WORLD);
+  unsigned int numproc = Utilities::MPI::n_mpi_processes (MPI_COMM_WORLD);
+  
+  if (myid==0)
+    deallog << "numproc=" << numproc << std::endl;
+
+                                  // each processor owns 2 indices and all
+                                  // are ghosting Element 1 (the second)
+
+  IndexSet local_active(numproc*2);
+  local_active.add_range(myid*2,myid*2+2);
+  IndexSet local_relevant(numproc*2);
+  local_relevant.add_range(1,2);
+
+  typename LA::MPI::Vector vb(local_active);
+  typename LA::MPI::Vector v(local_active, local_relevant);
+
+  vb = 1.0;
+
+                                  // set local values
+  vb(myid*2)=myid*2.0;
+  vb(myid*2+1)=myid*2.0+1.0;
+
+  vb.compress(VectorOperation::insert);
+  vb*=2.0;
+  v=vb;
+
+  Assert(vb.size() == numproc*2, ExcInternalError());
+  Assert(v.size() == numproc*2, ExcInternalError());
+
+  Assert(!vb.has_ghost_elements(), ExcInternalError());
+  Assert(v.has_ghost_elements(), ExcInternalError());
+  
+                                  // check local values
+    {
+      deallog << myid*2 << ": " << v(myid*2) << std::endl;
+      deallog << myid*2+1 << ": " << v(myid*2+1) << std::endl;
+    }
+  
+  Assert(v(myid*2) == myid*4.0, ExcInternalError());
+  Assert(v(myid*2+1) == myid*4.0+2.0, ExcInternalError());
+
+  ConstraintMatrix cm;
+  cm.add_line(1);
+  cm.add_entry(1 ,2, 3.0);
+  cm.close();
+  
+  if (myid==0)
+    deallog << "before: " << vb(1) << std::endl;
+  cm.distribute(vb); // this should set x(1)= 3.0 * x(2) = 12.0
+  if (myid==0)
+    deallog << "after: " << vb(1) << std::endl;
+  
+                                  // done
+  if (myid==0)
+    deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc, char **argv)
+{
+  Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+  MPILogInitAll log(__FILE__);
+  {
+    deallog.push("PETSc");
+    test<LA_PETSc>();
+    deallog.pop();
+    deallog.push("Trilinos");
+    test<LA_Trilinos>();
+    deallog.pop();
+  }
+
+}
diff --git a/tests/gla/vec_03/ncpu_10/cmp/generic b/tests/gla/vec_03/ncpu_10/cmp/generic
new file mode 100644 (file)
index 0000000..eb8100b
--- /dev/null
@@ -0,0 +1,11 @@
+
+DEAL:0:PETSc::numproc=10
+DEAL:0:PETSc::0:0.000
+DEAL:0:PETSc::1:2.000
+DEAL:0:PETSc::ghost: 2.000
+DEAL:0:PETSc::OK
+DEAL:0:Trilinos::numproc=10
+DEAL:0:Trilinos::0:0.000
+DEAL:0:Trilinos::1:2.000
+DEAL:0:Trilinos::ghost: 2.000
+DEAL:0:Trilinos::OK
diff --git a/tests/gla/vec_03/ncpu_4/cmp/generic b/tests/gla/vec_03/ncpu_4/cmp/generic
new file mode 100644 (file)
index 0000000..17a7739
--- /dev/null
@@ -0,0 +1,31 @@
+
+DEAL:0:PETSc::numproc=4
+DEAL:0:PETSc::0: 0.00000
+DEAL:0:PETSc::1: 2.00000
+DEAL:0:PETSc::before: 2.00000
+DEAL:0:PETSc::after: 12.0000
+DEAL:0:PETSc::OK
+DEAL:0:Trilinos::numproc=4
+DEAL:0:Trilinos::0: 0.00000
+DEAL:0:Trilinos::1: 2.00000
+DEAL:0:Trilinos::before: 2.00000
+DEAL:0:Trilinos::after: 12.0000
+DEAL:0:Trilinos::OK
+
+DEAL:1:PETSc::2: 4.00000
+DEAL:1:PETSc::3: 6.00000
+DEAL:1:Trilinos::2: 4.00000
+DEAL:1:Trilinos::3: 6.00000
+
+
+DEAL:2:PETSc::4: 8.00000
+DEAL:2:PETSc::5: 10.0000
+DEAL:2:Trilinos::4: 8.00000
+DEAL:2:Trilinos::5: 10.0000
+
+
+DEAL:3:PETSc::6: 12.0000
+DEAL:3:PETSc::7: 14.0000
+DEAL:3:Trilinos::6: 12.0000
+DEAL:3:Trilinos::7: 14.0000
+

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.