]> https://gitweb.dealii.org/ - dealii.git/commitdiff
use get_real_assert_zero_imag() instead of PetscRealPart()
authorDenis Davydov <davydden@gmail.com>
Tue, 29 Mar 2016 21:02:58 +0000 (23:02 +0200)
committerDenis Davydov <davydden@gmail.com>
Tue, 29 Mar 2016 21:02:58 +0000 (23:02 +0200)
tests/mpi/ghost_01.cc
tests/mpi/ghost_02.cc
tests/mpi/p4est_save_02.cc
tests/mpi/p4est_save_03.cc
tests/mpi/p4est_save_04.cc
tests/mpi/periodicity_01.cc
tests/mpi/petsc_bug_ghost_vector_01.cc
tests/mpi/petsc_distribute_01.cc
tests/mpi/petsc_distribute_01_block.cc
tests/mpi/petsc_distribute_01_inhomogenous.cc

index 71578edf2b4bd2e396d248410096da099a684ddf..5a917805c7d4335c9a58ce759a994305a15bb565 100644 (file)
@@ -59,18 +59,18 @@ void test ()
   // check local values
   if (Utilities::MPI::this_mpi_process (MPI_COMM_WORLD) == 0)
     {
-      deallog << myid*2 << ":" << PetscRealPart(v(myid*2)) << std::endl;
-      deallog << myid*2+1 << ":" << PetscRealPart(v(myid*2+1)) << std::endl;
+      deallog << myid*2 << ":" << get_real_assert_zero_imag(v(myid*2)) << std::endl;
+      deallog << myid*2+1 << ":" << get_real_assert_zero_imag(v(myid*2+1)) << std::endl;
     }
 
-  Assert(PetscRealPart(v(myid*2)) == myid*4.0, ExcInternalError());
-  Assert(PetscRealPart(v(myid*2+1)) == myid*4.0+2.0, ExcInternalError());
+  Assert(get_real_assert_zero_imag(v(myid*2)) == myid*4.0, ExcInternalError());
+  Assert(get_real_assert_zero_imag(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: " << PetscRealPart(v(1)) << std::endl;
-  Assert(PetscRealPart(v(1)) == 2.0, ExcInternalError());
+    deallog << "ghost: " << get_real_assert_zero_imag(v(1)) << std::endl;
+  Assert(get_real_assert_zero_imag(v(1)) == 2.0, ExcInternalError());
 
   // done
   if (myid==0)
index 63c02e9863473284eda8e91da877bb7d038517dc..eaa877b5c6fd4a238cc48022cd1ce42c197f1ee1 100644 (file)
@@ -52,10 +52,10 @@ void test ()
   vb = a;
   v2 = vb;
   if (Utilities::MPI::this_mpi_process (MPI_COMM_WORLD) == 0)
-    deallog << "ghost: " << PetscRealPart(v2(1)) << std::endl;
-  Assert(PetscRealPart(v2(1)) == 1.5, ExcInternalError());
-  Assert(PetscRealPart(v2(myid*2)) == 1.5, ExcInternalError());
-  Assert(PetscRealPart(v2(myid*2+1)) == 1.5, ExcInternalError());
+    deallog << "ghost: " << get_real_assert_zero_imag(v2(1)) << std::endl;
+  Assert(get_real_assert_zero_imag(v2(1)) == 1.5, ExcInternalError());
+  Assert(get_real_assert_zero_imag(v2(myid*2)) == 1.5, ExcInternalError());
+  Assert(get_real_assert_zero_imag(v2(myid*2+1)) == 1.5, ExcInternalError());
 
   // set local values
   vb(myid*2)=b;
@@ -69,26 +69,26 @@ void test ()
   // check local values
   if (Utilities::MPI::this_mpi_process (MPI_COMM_WORLD) == 0)
     {
-      deallog << myid*2 << ":" << PetscRealPart(v(myid*2)) << std::endl;
-      deallog << myid*2+1 << ":" << PetscRealPart(v(myid*2+1)) << std::endl;
+      deallog << myid*2 << ":" << get_real_assert_zero_imag(v(myid*2)) << std::endl;
+      deallog << myid*2+1 << ":" << get_real_assert_zero_imag(v(myid*2+1)) << std::endl;
     }
 
-  Assert(PetscRealPart(v(myid*2)) == myid*4.0, ExcInternalError());
-  Assert(PetscRealPart(v(myid*2+1)) == myid*4.0+2.0, ExcInternalError());
+  Assert(get_real_assert_zero_imag(v(myid*2)) == myid*4.0, ExcInternalError());
+  Assert(get_real_assert_zero_imag(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: " << PetscRealPart(v(1)) << std::endl;
-  Assert(PetscRealPart(v(1)) == 2.0, ExcInternalError());
+    deallog << "ghost: " << get_real_assert_zero_imag(v(1)) << std::endl;
+  Assert(get_real_assert_zero_imag(v(1)) == 2.0, ExcInternalError());
 
   //assignment from ghosted to ghosted
   v2 = v;
-  Assert(PetscRealPart(v2(1)) == 2.0, ExcInternalError());
-  Assert(PetscRealPart(v2(myid*2)) == myid*4.0, ExcInternalError());
-  Assert(PetscRealPart(v2(myid*2+1)) == myid*4.0+2.0, ExcInternalError());
+  Assert(get_real_assert_zero_imag(v2(1)) == 2.0, ExcInternalError());
+  Assert(get_real_assert_zero_imag(v2(myid*2)) == myid*4.0, ExcInternalError());
+  Assert(get_real_assert_zero_imag(v2(myid*2+1)) == myid*4.0+2.0, ExcInternalError());
   if (Utilities::MPI::this_mpi_process (MPI_COMM_WORLD) == 0)
-    deallog << "ghost: " << PetscRealPart(v2(1)) << std::endl;
+    deallog << "ghost: " << get_real_assert_zero_imag(v2(1)) << std::endl;
 
   // done
   if (myid==0)
index 26592aab9ad353a0d9bea7bdb87bedf855d6bc37..05676d3e44f3552e768f0503b9385662ea8b9823 100644 (file)
@@ -134,7 +134,7 @@ void test()
       {
         unsigned int idx = locally_owned_dofs.nth_index_in_set(i);
         //std::cout << '[' << idx << ']' << ' ' << solution(idx) << std::endl;
-        Assert(idx == PetscRealPart(solution(idx)),ExcInternalError());
+        Assert(idx == get_real_assert_zero_imag(solution(idx)),ExcInternalError());
 
       }
 
index 723556e71f4af44b375f49c0602d838edbd14f29..bbadf28e9eeb18cc0a4fa081019773f0d0773902 100644 (file)
@@ -146,8 +146,8 @@ void test()
       {
         unsigned int idx = locally_owned_dofs.nth_index_in_set (i);
         //std::cout << '[' << idx << ']' << ' ' << solution(idx) << std::endl;
-        AssertThrow (idx == PetscRealPart(solution (idx)), ExcInternalError());
-        AssertThrow (2*idx == PetscRealPart(solution2 (idx)), ExcInternalError());
+        AssertThrow (idx == get_real_assert_zero_imag(solution (idx)), ExcInternalError());
+        AssertThrow (2*idx == get_real_assert_zero_imag(solution2 (idx)), ExcInternalError());
       }
 
     double norm = solution.l1_norm();
index 57d9f278ba28bec10fb35eee835b92c71c679ccb..28086449d6243b4ba786612b90dc0442130a3365 100644 (file)
@@ -88,7 +88,7 @@ void test()
         {
           unsigned int idx = locally_owned_dofs.nth_index_in_set (i);
           x (idx) = idx;
-          deallog << '[' << idx << ']' << ' ' << PetscRealPart(x(idx)) << std::endl;
+          deallog << '[' << idx << ']' << ' ' << get_real_assert_zero_imag(x(idx)) << std::endl;
         }
 
 
@@ -132,7 +132,7 @@ void test()
     for (unsigned int i = 0; i < locally_owned_dofs.n_elements(); ++i)
       {
         unsigned int idx = locally_owned_dofs.nth_index_in_set (i);
-        deallog << '[' << idx << ']' << ' ' << PetscRealPart(solution(idx)) << std::endl;
+        deallog << '[' << idx << ']' << ' ' << get_real_assert_zero_imag(solution(idx)) << std::endl;
       }
 
     deallog << "#cells = " << tr.n_global_active_cells() << std::endl;
index fae79441fbb00bdb39e0de856ec438ee0ca2dc71..d645d559dee6d434991dd6ba8a2542c9b553941e 100644 (file)
@@ -317,7 +317,7 @@ namespace Step40
 
     for (unsigned int i=0; i<value.size(); ++i)
       {
-        tmp[i]=PetscRealPart(value[i]);
+        tmp[i]=get_real_assert_zero_imag(value[i]);
         tmpI[i]=PetscImaginaryPart(value[i]);
       }
 #else
@@ -369,15 +369,13 @@ namespace Step40
 
         if (Utilities::MPI::this_mpi_process(mpi_communicator)==0)
           {
-            pcout << point1 << "\t" << PetscRealPart(value1[0]) << std::endl;
+            pcout << point1 << "\t" << get_real_assert_zero_imag(value1[0]) << std::endl;
             if (std::abs(value2[0]-value1[0])>1e-8)
               {
                 std::cout<<point1<< "\t" << value1[0] << std::endl;
                 std::cout<<point2<< "\t" << value2[0] << std::endl;
                 Assert(false, ExcInternalError());
               }
-            Assert(std::fabs(PetscImaginaryPart(value1[0]))<1e-10,
-                   ExcInternalError());
           }
       }
   }
@@ -421,24 +419,20 @@ namespace Step40
 
           if (Utilities::MPI::this_mpi_process(mpi_communicator)==0)
             {
-              pcout << point1 << "\t" << PetscRealPart(value1[0]) << std::endl;
+              pcout << point1 << "\t" << get_real_assert_zero_imag(value1[0]) << std::endl;
               if (std::abs(value2[0]-value1[0])>1e-8)
                 {
                   std::cout<<point1<< "\t" << value1[0] << std::endl;
                   std::cout<<point2<< "\t" << value2[0] << std::endl;
                   Assert(false, ExcInternalError());
                 }
-              Assert(std::fabs(PetscImaginaryPart(value1[0]))<1e-10,
-                     ExcInternalError());
-              pcout << point3 << "\t" << PetscRealPart(value3[0]) << std::endl;
+              pcout << point3 << "\t" << get_real_assert_zero_imag(value3[0]) << std::endl;
               if (std::abs(value4[0]-value3[0])>1e-8)
                 {
                   std::cout<<point3<< "\t" << value3[0] << std::endl;
                   std::cout<<point4<< "\t" << value4[0] << std::endl;
                   Assert(false, ExcInternalError());
                 }
-              Assert(std::fabs(PetscImaginaryPart(value3[0]))<1e-10,
-                     ExcInternalError());
             }
         }
   }
index 38d56d85856dbea49fb2cf11f736ce1b5186c3df..fb07d83c3562a9dadde19cb30b342165673fc7cc 100644 (file)
@@ -229,14 +229,14 @@ void test ()
     // zero. check this first for the locally owned elements...
     for (unsigned int i=0; i<handler.n_dofs(); ++i)
       if (locally_owned_dofs.is_element(i))
-        AssertThrow (PetscRealPart(vector(i)) == 0,
+        AssertThrow (get_real_assert_zero_imag(vector(i)) == 0,
                      ExcInternalError());
     // ...end then also for the ghost elements
     for (unsigned int i=0; i<handler.n_dofs(); ++i)
       if (locally_relevant_dofs.is_element(i)
           &&
           !locally_owned_dofs.is_element(i))
-        AssertThrow (PetscRealPart(vector(i)) == 0,
+        AssertThrow (get_real_assert_zero_imag(vector(i)) == 0,
                      ExcInternalError());
   }
 }
index 38c0120a16564c8f6205d1544d852c2c4f16569c..87164feaa8923a3ccaf83c6804a77e32fb46ba57 100644 (file)
@@ -99,11 +99,11 @@ void test()
 
   // verify correctness
   if (myid != 0)
-    AssertThrow (PetscRealPart(vec(vec.local_range().first+10)) == vec.local_range().first-25,
+    AssertThrow (get_real_assert_zero_imag(vec(vec.local_range().first+10)) == vec.local_range().first-25,
                  ExcInternalError());
 
   if (myid != n_processes-1)
-    AssertThrow (PetscRealPart(vec(vec.local_range().first+90)) == vec.local_range().first+105,
+    AssertThrow (get_real_assert_zero_imag(vec(vec.local_range().first+90)) == vec.local_range().first+105,
                  ExcInternalError());
 
   for (unsigned int i=vec.local_range().first; i<vec.local_range().second; ++i)
@@ -113,8 +113,7 @@ void test()
           (i != vec.local_range().first+90))
         {
           PetscScalar val = vec(i);
-          AssertThrow (std::fabs(PetscRealPart(val) - i) <= 1e-6, ExcInternalError());
-          AssertThrow (std::fabs(PetscImaginaryPart(val)) <= 1e-6, ExcInternalError());
+          AssertThrow (std::fabs(get_real_assert_zero_imag(val) - i) <= 1e-6, ExcInternalError());
         }
     }
 
index fc176c4afc79d62b1c5e541f4083d0c92145a76d..209517cfeecf5b214efbb1794f3e2dc49682f0b2 100644 (file)
@@ -112,19 +112,19 @@ void test()
 
   // verify correctness
   if (myid != 0)
-    AssertThrow (PetscRealPart(vec(vec.block(0).local_range().first+10)) == vec.block(0).local_range().first-25,
+    AssertThrow (get_real_assert_zero_imag(vec(vec.block(0).local_range().first+10)) == vec.block(0).local_range().first-25,
                  ExcInternalError());
 
   if (myid != n_processes-1)
-    AssertThrow (PetscRealPart(vec(vec.block(0).local_range().first+90)) == vec.block(0).local_range().first+105,
+    AssertThrow (get_real_assert_zero_imag(vec(vec.block(0).local_range().first+90)) == vec.block(0).local_range().first+105,
                  ExcInternalError());
 
   if (myid != 0)
-    AssertThrow (PetscRealPart(vec(vec.block(0).size()+vec.block(1).local_range().first+10)) == vec.block(1).local_range().first-25,
+    AssertThrow (get_real_assert_zero_imag(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 (PetscRealPart(vec(vec.block(0).size()+vec.block(1).local_range().first+90)) == vec.block(1).local_range().first+105,
+    AssertThrow (get_real_assert_zero_imag(vec(vec.block(0).size()+vec.block(1).local_range().first+90)) == vec.block(1).local_range().first+105,
                  ExcInternalError());
 
 
@@ -135,8 +135,7 @@ void test()
           (i != vec.block(0).local_range().first+90))
         {
           PetscScalar val = vec.block(0)(i);
-          AssertThrow (std::fabs(PetscRealPart(val) - i) <= 1e-6, ExcInternalError());
-          AssertThrow (PetscImaginaryPart(val) == 0.0, ExcInternalError());
+          AssertThrow (std::fabs(get_real_assert_zero_imag(val) - i) <= 1e-6, ExcInternalError());
         }
     }
   for (unsigned int i=vec.block(1).local_range().first; i<vec.block(1).local_range().second; ++i)
@@ -146,8 +145,7 @@ void test()
           (i != vec.block(1).local_range().first+90))
         {
           PetscScalar val = vec.block(1)(i);
-          AssertThrow (std::fabs(PetscRealPart(val) - i) <= 1e-6, ExcInternalError());
-          AssertThrow ( PetscImaginaryPart(val) == 0.0, ExcInternalError());
+          AssertThrow (std::fabs(get_real_assert_zero_imag(val) - i) <= 1e-6, ExcInternalError());
         }
     }
 
index eaa56a3904e4aa12d9efe603da7bb300e0712805..bb92a31878c27eae26016e8bf0488335b93dcbe0 100644 (file)
@@ -93,20 +93,12 @@ void test()
 
   // verify correctness
   if (myid != 0)
-    {
-      AssertThrow (PetscRealPart(vec(vec.local_range().first+10)) == vec.local_range().first-25+1,
-                   ExcInternalError());
-      AssertThrow (PetscImaginaryPart(vec(vec.local_range().first+10)) == 0.,
-                   ExcInternalError());
-    }
+    AssertThrow (get_real_assert_zero_imag(vec(vec.local_range().first+10)) == vec.local_range().first-25+1,
+                 ExcInternalError());
 
   if (myid != n_processes-1)
-    {
-      AssertThrow (PetscRealPart(vec(vec.local_range().first+90)) == vec.local_range().first+105-1,
-                   ExcInternalError());
-      AssertThrow (PetscImaginaryPart(vec(vec.local_range().first+90)) == 0.,
-                   ExcInternalError());
-    }
+    AssertThrow (get_real_assert_zero_imag(vec(vec.local_range().first+90)) == vec.local_range().first+105-1,
+                 ExcInternalError());
 
   for (unsigned int i=vec.local_range().first; i<vec.local_range().second; ++i)
     {
@@ -115,8 +107,7 @@ void test()
           (i != vec.local_range().first+90))
         {
           PetscScalar val = vec(i);
-          AssertThrow (std::fabs(PetscRealPart(val) - i) <= 1e-6, ExcInternalError());
-          AssertThrow (std::fabs(PetscImaginaryPart(val)) <= 1e-6, ExcInternalError());
+          AssertThrow (std::fabs(get_real_assert_zero_imag(val) - i) <= 1e-6, 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.