From: Daniel Arndt Date: Wed, 3 May 2017 15:46:12 +0000 (+0200) Subject: Fix petsc_complex tests X-Git-Tag: v9.0.0-rc1~1628^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F4340%2Fhead;p=dealii.git Fix petsc_complex tests --- diff --git a/source/lac/petsc_vector_base.cc b/source/lac/petsc_vector_base.cc index 353846f2ec..83c5fd2732 100644 --- a/source/lac/petsc_vector_base.cc +++ b/source/lac/petsc_vector_base.cc @@ -49,7 +49,7 @@ namespace PETScWrappers } // else see if we are dealing // with a parallel vector - else if (dynamic_cast(&vector) != nullptr) + else if (dynamic_cast(&vector) != nullptr) { // there is the possibility // that the vector has diff --git a/tests/petsc/vector_wrap_01.cc b/tests/petsc/vector_wrap_01.cc index 0bd8749689..e8a320859c 100644 --- a/tests/petsc/vector_wrap_01.cc +++ b/tests/petsc/vector_wrap_01.cc @@ -15,7 +15,7 @@ -// Test the constructor PETScWrappers::MPI::Vector(const Vec &) that takes an +// Test the constructor PETScWrappers::VectorBase(const Vec &) that takes an // existing PETSc vector. #include "../tests.h" @@ -25,7 +25,7 @@ #include -void test (PETScWrappers::MPI::Vector &v, +void test (PETScWrappers::VectorBase &v, PETScWrappers::MPI::Vector &w) { // set the first vector @@ -39,20 +39,13 @@ void test (PETScWrappers::MPI::Vector &v, // check that they're equal Assert (v==w, ExcInternalError()); - v.compress(VectorOperation::insert); - w.compress(VectorOperation::insert); - v=w; - deallog << "OK" << std::endl; } - int main (int argc, char **argv) { - std::ofstream logfile("output"); - deallog.attach(logfile); - deallog.threshold_double(1.e-10); + initlog(); try { @@ -61,10 +54,8 @@ int main (int argc, char **argv) int ierr = VecCreateSeq (PETSC_COMM_SELF, 100, &vpetsc); AssertThrow (ierr == 0, ExcPETScError(ierr)); { - IndexSet indices(100); - indices.add_range(0, 100); - PETScWrappers::MPI::Vector v (indices, MPI_COMM_WORLD); - PETScWrappers::MPI::Vector w (indices, MPI_COMM_WORLD); + PETScWrappers::VectorBase v (vpetsc); + PETScWrappers::MPI::Vector w (PETSC_COMM_SELF, 100, 100); test (v,w); } @@ -75,8 +66,6 @@ int main (int argc, char **argv) #endif AssertThrow (ierr == 0, ExcPETScError(ierr)); - - } catch (std::exception &exc) { diff --git a/tests/petsc_complex/element_access_00.output b/tests/petsc_complex/element_access_00.output index 60ff416e00..c38e99036f 100644 --- a/tests/petsc_complex/element_access_00.output +++ b/tests/petsc_complex/element_access_00.output @@ -2,5 +2,5 @@ DEAL::Check vector access DEAL::OK DEAL::vector: -(0.000e+00,5.000e+00) (1.000e+00,4.000e+00) (2.000e+00,3.000e+00) (3.000e+00,2.000e+00) (4.000e+00,1.000e+00) +[Proc0 0-4] (0.000e+00,5.000e+00) (1.000e+00,4.000e+00) (2.000e+00,3.000e+00) (3.000e+00,2.000e+00) (4.000e+00,1.000e+00) diff --git a/tests/petsc_complex/vector_assign_02.output b/tests/petsc_complex/vector_assign_02.output index f432760cf7..0c62f40c8e 100644 --- a/tests/petsc_complex/vector_assign_02.output +++ b/tests/petsc_complex/vector_assign_02.output @@ -1,6 +1,6 @@ DEAL::OK DEAL::Complex vectors: -DEAL::v: (0.,0.) (1.,1.) (2.,4.) (3.,9.) (4.,16.) (5.,25.) (6.,36.) (7.,49.) (8.,64.) (9.,81.) (10.,100.) (11.,121.) (12.,144.) (13.,169.) (14.,196.) (15.,225.) (16.,256.) (17.,289.) (18.,324.) (19.,361.) -w: (0.,0.) (1.,1.) (2.,4.) (3.,9.) (4.,16.) (5.,25.) (6.,36.) (7.,49.) (8.,64.) (9.,81.) (10.,100.) (11.,121.) (12.,144.) (13.,169.) (14.,196.) (15.,225.) (16.,256.) (17.,289.) (18.,324.) (19.,361.) +DEAL::v: [Proc0 0-19] (0.,0.) (1.,1.) (2.,4.) (3.,9.) (4.,16.) (5.,25.) (6.,36.) (7.,49.) (8.,64.) (9.,81.) (10.,100.) (11.,121.) (12.,144.) (13.,169.) (14.,196.) (15.,225.) (16.,256.) (17.,289.) (18.,324.) (19.,361.) +w: [Proc0 0-19] (0.,0.) (1.,1.) (2.,4.) (3.,9.) (4.,16.) (5.,25.) (6.,36.) (7.,49.) (8.,64.) (9.,81.) (10.,100.) (11.,121.) (12.,144.) (13.,169.) (14.,196.) (15.,225.) (16.,256.) (17.,289.) (18.,324.) (19.,361.) OK diff --git a/tests/petsc_complex/vector_equality_1.output b/tests/petsc_complex/vector_equality_1.output index 450c4b40d9..b07ef46ee2 100644 --- a/tests/petsc_complex/vector_equality_1.output +++ b/tests/petsc_complex/vector_equality_1.output @@ -1,6 +1,6 @@ DEAL::OK DEAL::Complex vectors: -(0.,0.) (1.,1.) (2.,2.) (3.,3.) (4.,4.) (5.,5.) (6.,6.) (7.,7.) (8.,8.) (9.,9.) (10.,10.) (11.,11.) (12.,12.) (13.,13.) (14.,14.) (15.,15.) (16.,16.) (17.,17.) (18.,18.) (19.,19.) -(1.,1.) (0.,0.) (0.,0.) (4.,4.) (0.,0.) (0.,0.) (7.,7.) (0.,0.) (0.,0.) (10.,10.) (0.,0.) (0.,0.) (13.,13.) (0.,0.) (0.,0.) (16.,16.) (0.,0.) (0.,0.) (19.,19.) (0.,0.) +[Proc0 0-19] (0.,0.) (1.,1.) (2.,2.) (3.,3.) (4.,4.) (5.,5.) (6.,6.) (7.,7.) (8.,8.) (9.,9.) (10.,10.) (11.,11.) (12.,12.) (13.,13.) (14.,14.) (15.,15.) (16.,16.) (17.,17.) (18.,18.) (19.,19.) +[Proc0 0-19] (1.,1.) (0.,0.) (0.,0.) (4.,4.) (0.,0.) (0.,0.) (7.,7.) (0.,0.) (0.,0.) (10.,10.) (0.,0.) (0.,0.) (13.,13.) (0.,0.) (0.,0.) (16.,16.) (0.,0.) (0.,0.) (19.,19.) (0.,0.) DEAL::OK diff --git a/tests/petsc_complex/vector_equality_2.cc b/tests/petsc_complex/vector_equality_2.cc index 73c0764224..cecb0d1214 100644 --- a/tests/petsc_complex/vector_equality_2.cc +++ b/tests/petsc_complex/vector_equality_2.cc @@ -35,6 +35,8 @@ void test (PETScWrappers::MPI::Vector &v, if (k%3 == 0) w(k) = std::complex (k+1.,k+1); } + v.compress(VectorOperation::insert); + w.compress(VectorOperation::insert); // then copy elements and make sure the vectors are actually equal v = w; diff --git a/tests/petsc_complex/vector_equality_2.output b/tests/petsc_complex/vector_equality_2.output index b49f220c60..7c0c076c2d 100644 --- a/tests/petsc_complex/vector_equality_2.output +++ b/tests/petsc_complex/vector_equality_2.output @@ -1,6 +1,6 @@ DEAL::OK DEAL::Complex vectors: -(1.,1.) (0.,0.) (0.,0.) (4.,4.) (0.,0.) (0.,0.) (7.,7.) (0.,0.) (0.,0.) (10.,10.) (0.,0.) (0.,0.) (13.,13.) (0.,0.) (0.,0.) (16.,16.) (0.,0.) (0.,0.) (19.,19.) (0.,0.) -(1.,1.) (0.,0.) (0.,0.) (4.,4.) (0.,0.) (0.,0.) (7.,7.) (0.,0.) (0.,0.) (10.,10.) (0.,0.) (0.,0.) (13.,13.) (0.,0.) (0.,0.) (16.,16.) (0.,0.) (0.,0.) (19.,19.) (0.,0.) +[Proc0 0-19] (1.,1.) (0.,0.) (0.,0.) (4.,4.) (0.,0.) (0.,0.) (7.,7.) (0.,0.) (0.,0.) (10.,10.) (0.,0.) (0.,0.) (13.,13.) (0.,0.) (0.,0.) (16.,16.) (0.,0.) (0.,0.) (19.,19.) (0.,0.) +[Proc0 0-19] (1.,1.) (0.,0.) (0.,0.) (4.,4.) (0.,0.) (0.,0.) (7.,7.) (0.,0.) (0.,0.) (10.,10.) (0.,0.) (0.,0.) (13.,13.) (0.,0.) (0.,0.) (16.,16.) (0.,0.) (0.,0.) (19.,19.) (0.,0.) DEAL::OK diff --git a/tests/petsc_complex/vector_print.output b/tests/petsc_complex/vector_print.output index a2b6107901..29734db430 100644 --- a/tests/petsc_complex/vector_print.output +++ b/tests/petsc_complex/vector_print.output @@ -1,5 +1,6 @@ DEAL::unreadable=true,across=false +[Proc 0 0-4] (0.0000000000e+00,0.0000000000e+00) (1.2345678901e+00,2.4691357802e+00) (2.4691357802e+00,4.9382715605e+00) @@ -7,4 +8,4 @@ DEAL::unreadable=true,across=false (4.9382715605e+00,9.8765431210e+00) DEAL::unreadable=false,across=true -(0.000,0.000) (1.235,2.469) (2.469,4.938) (3.704,7.407) (4.938,9.877) +[Proc0 0-4] (0.000,0.000) (1.235,2.469) (2.469,4.938) (3.704,7.407) (4.938,9.877) diff --git a/tests/petsc_complex/vector_wrap_01.cc b/tests/petsc_complex/vector_wrap_01.cc index d74a0a51ec..a9735b34a7 100644 --- a/tests/petsc_complex/vector_wrap_01.cc +++ b/tests/petsc_complex/vector_wrap_01.cc @@ -15,7 +15,8 @@ -// See comments in tests/petsc/vector_wrap_01.cc +// Test the constructor PETScWrappers::VectorBase(const Vec &) that takes an +// existing PETSc vector for complex values. #include "../tests.h" #include @@ -24,7 +25,7 @@ #include -void test (PETScWrappers::MPI::Vector &v, +void test (PETScWrappers::VectorBase &v, PETScWrappers::MPI::Vector &w) { // set the first vector @@ -38,21 +39,13 @@ void test (PETScWrappers::MPI::Vector &v, // check that they're equal AssertThrow (v==w, ExcInternalError()); - v=w; - - // check that they're still equal - AssertThrow (v==w, ExcInternalError()); - deallog << "OK" << std::endl; } int main (int argc, char **argv) { - std::ofstream logfile("output"); - deallog.attach(logfile); - deallog.depth_console(0); - deallog.threshold_double(1.e-10); + initlog(); try { @@ -61,7 +54,7 @@ int main (int argc, char **argv) int ierr = VecCreateSeq (PETSC_COMM_SELF, 100, &vpetsc); AssertThrow (ierr == 0, ExcPETScError(ierr)); { - PETScWrappers::MPI::Vector v (vpetsc); + PETScWrappers::VectorBase v (vpetsc); PETScWrappers::MPI::Vector w (PETSC_COMM_SELF, 100, 100); test (v,w); }