]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
second test
authorheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 1 Mar 2013 20:21:24 +0000 (20:21 +0000)
committerheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 1 Mar 2013 20:21:24 +0000 (20:21 +0000)
git-svn-id: https://svn.dealii.org/branches/branch_unify_linear_algebra@28705 0785d39b-7218-0410-832d-ea1e28bc413d

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

index dd511d9d8ed4ef5a1fb5b16422e80d7fe3dd94dc..e50cd7559f116d5f0fc86e8e065b929814f9dfa2 100644 (file)
@@ -54,7 +54,13 @@ class LA_Dummy
              {return 0;}
            
            
-           const Vector & operator*=(const double factor)
+           const Vector & operator=(const double number)
+             {
+               return *this;
+             }
+           
+
+             const Vector & operator*=(const double factor)
              {
                return *this;
              }
index a97f7d7e03abec66af3e61d03b81b55ff6319d9b..187b80b76279de02e7da1569c35c6f62a0967e5b 100644 (file)
@@ -12,6 +12,7 @@
 //---------------------------------------------------------------------------
 
 
+// creation and size and ghost elements of LA::MPI::Vector
 
 #include "../tests.h"
 #include <deal.II/lac/abstract_linear_algebra.h>
@@ -89,7 +90,7 @@ int main (int argc, char **argv)
 
   if (myid == 0)
     {
-      std::ofstream logfile(output_file_for_mpi("ghost_01").c_str());
+      std::ofstream logfile(output_file_for_mpi("vec_01").c_str());
       deallog.attach(logfile);
       deallog << std::setprecision(4);
       deallog.depth_console(0);
diff --git a/tests/gla/vec_02.cc b/tests/gla/vec_02.cc
new file mode 100644 (file)
index 0000000..60d02e4
--- /dev/null
@@ -0,0 +1,135 @@
+//---------------------------------------------------------------------------
+//    $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/abstract_linear_algebra.h>
+#include <deal.II/base/index_set.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(MPI_COMM_WORLD, local_active);
+  typename LA::MPI::Vector v(MPI_COMM_WORLD, local_active, local_relevant);
+  typename LA::MPI::Vector v2(MPI_COMM_WORLD, local_active, local_relevant);
+
+  vb = 1.0;
+  v2 = vb;
+
+                                  // 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
+  if (Utilities::MPI::this_mpi_process (MPI_COMM_WORLD) == 0)
+    {
+      deallog << myid*2 << ":" << v(myid*2) << std::endl;
+      deallog << myid*2+1 << ":" << v(myid*2+1) << std::endl;
+    }
+  
+                                  //assignment from ghosted to ghosted
+  v2 = v;
+  Assert(v2(1) == 2.0, ExcInternalError());
+  Assert(v2(myid*2) == myid*4.0, ExcInternalError());
+  Assert(v2(myid*2+1) == myid*4.0+2.0, ExcInternalError());
+
+
+  
+  Assert(v(myid*2) == myid*4.0, ExcInternalError());
+  Assert(v(myid*2+1) == myid*4.0+2.0, ExcInternalError());
+  
+
+                                  // check ghost values
+  if (Utilities::MPI::this_mpi_process (MPI_COMM_WORLD) == 0)
+    deallog << "ghost: " << v(1) << std::endl;
+  Assert(v(1) == 2.0, ExcInternalError());
+
+                                  // done
+  if (myid==0)
+    deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc, char **argv)
+{
+  Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv);
+  unsigned int myid = Utilities::MPI::this_mpi_process (MPI_COMM_WORLD);
+
+  deallog.push(Utilities::int_to_string(myid));
+
+  if (myid == 0)
+    {
+      std::ofstream logfile(output_file_for_mpi("vec_02").c_str());
+      deallog.attach(logfile);
+      deallog << std::setprecision(4);
+      deallog.depth_console(0);
+      deallog.threshold_double(1.e-10);
+
+      {        
+       deallog.push("PETSc");
+       test<LA_PETSc>();
+       deallog.pop();  
+       deallog.push("Trilinos");
+       test<LA_Trilinos>();
+       deallog.pop();  
+      }
+      
+    }
+  else
+      {        
+       deallog.push("PETSc");
+       test<LA_PETSc>();
+       deallog.pop();  
+       deallog.push("Trilinos");
+       test<LA_Trilinos>();
+       deallog.pop();  
+      }
+
+  if (myid==9999)
+    test<LA_Dummy>();
+  
+
+}
diff --git a/tests/gla/vec_02/ncpu_10/cmp/generic b/tests/gla/vec_02/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_02/ncpu_4/cmp/generic b/tests/gla/vec_02/ncpu_4/cmp/generic
new file mode 100644 (file)
index 0000000..391c391
--- /dev/null
@@ -0,0 +1,11 @@
+
+DEAL:0:PETSc::numproc=4
+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=4
+DEAL:0:Trilinos::0:0.000
+DEAL:0:Trilinos::1:2.000
+DEAL:0:Trilinos::ghost: 2.000
+DEAL:0:Trilinos::OK

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.