]> https://gitweb.dealii.org/ - dealii.git/commitdiff
extend mpi/petsc_distribute_01_block to complex-valued PETSc
authorDenis Davydov <davydden@gmail.com>
Mon, 28 Mar 2016 18:28:36 +0000 (20:28 +0200)
committerDenis Davydov <davydden@gmail.com>
Tue, 29 Mar 2016 18:48:46 +0000 (20:48 +0200)
tests/mpi/petsc_distribute_01_block.cc

index 441480e2a9b2f08f80fc8354217e5fa3518fd9d3..fc176c4afc79d62b1c5e541f4083d0c92145a76d 100644 (file)
@@ -112,19 +112,19 @@ void test()
 
   // verify correctness
   if (myid != 0)
-    AssertThrow (vec(vec.block(0).local_range().first+10) == vec.block(0).local_range().first-25,
+    AssertThrow (PetscRealPart(vec(vec.block(0).local_range().first+10)) == vec.block(0).local_range().first-25,
                  ExcInternalError());
 
   if (myid != n_processes-1)
-    AssertThrow (vec(vec.block(0).local_range().first+90) == vec.block(0).local_range().first+105,
+    AssertThrow (PetscRealPart(vec(vec.block(0).local_range().first+90)) == vec.block(0).local_range().first+105,
                  ExcInternalError());
 
   if (myid != 0)
-    AssertThrow (vec(vec.block(0).size()+vec.block(1).local_range().first+10) == vec.block(1).local_range().first-25,
+    AssertThrow (PetscRealPart(vec(vec.block(0).size()+vec.block(1).local_range().first+10)) == vec.block(1).local_range().first-25,
                  ExcInternalError());
 
   if (myid != n_processes-1)
-    AssertThrow (vec(vec.block(0).size()+vec.block(1).local_range().first+90) == vec.block(1).local_range().first+105,
+    AssertThrow (PetscRealPart(vec(vec.block(0).size()+vec.block(1).local_range().first+90)) == vec.block(1).local_range().first+105,
                  ExcInternalError());
 
 
@@ -134,8 +134,9 @@ void test()
           &&
           (i != vec.block(0).local_range().first+90))
         {
-          double val = vec.block(0)(i);
-          AssertThrow (std::fabs(val - i) <= 1e-6, ExcInternalError());
+          PetscScalar val = vec.block(0)(i);
+          AssertThrow (std::fabs(PetscRealPart(val) - i) <= 1e-6, ExcInternalError());
+          AssertThrow (PetscImaginaryPart(val) == 0.0, ExcInternalError());
         }
     }
   for (unsigned int i=vec.block(1).local_range().first; i<vec.block(1).local_range().second; ++i)
@@ -144,8 +145,9 @@ void test()
           &&
           (i != vec.block(1).local_range().first+90))
         {
-          double val = vec.block(1)(i);
-          AssertThrow (std::fabs(val - i) <= 1e-6, ExcInternalError());
+          PetscScalar val = vec.block(1)(i);
+          AssertThrow (std::fabs(PetscRealPart(val) - i) <= 1e-6, ExcInternalError());
+          AssertThrow ( PetscImaginaryPart(val) == 0.0, ExcInternalError());
         }
     }
 

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.