From: David Wells Date: Sat, 9 Dec 2017 23:09:23 +0000 (-0500) Subject: Convert some more tests to use initlog. X-Git-Tag: v9.0.0-rc1~670^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F5608%2Fhead;p=dealii.git Convert some more tests to use initlog. --- diff --git a/tests/full_matrix/full_matrix.cc b/tests/full_matrix/full_matrix.cc index be0acfd868..484484c629 100644 --- a/tests/full_matrix/full_matrix.cc +++ b/tests/full_matrix/full_matrix.cc @@ -39,12 +39,13 @@ void random_matrix(FullMatrix &A) int main () { - std::ofstream logfile("output"); + initlog(); deallog << std::fixed; deallog << std::setprecision(3); - deallog.attach(logfile); Testing::srand(3391466); + std::ostream &logfile = deallog.get_file_stream(); + FullMatrix T(3,3,entries); T.print_formatted(logfile, 0, false); @@ -176,5 +177,3 @@ main () } } } - - diff --git a/tests/full_matrix/full_matrix_02.cc b/tests/full_matrix/full_matrix_02.cc index d865c132c0..300fd4b125 100644 --- a/tests/full_matrix/full_matrix_02.cc +++ b/tests/full_matrix/full_matrix_02.cc @@ -31,10 +31,9 @@ const double entries_Z[9] = { 0,0,0,0,0,0,0,0,0 }; int main () { - std::ofstream logfile("output"); + initlog(); deallog << std::fixed; deallog << std::setprecision(3); - deallog.attach(logfile); Testing::srand(3391466); FullMatrix A(3,3,entries_A); diff --git a/tests/full_matrix/full_matrix_03.cc b/tests/full_matrix/full_matrix_03.cc index dc284bdfb0..174860fec6 100644 --- a/tests/full_matrix/full_matrix_03.cc +++ b/tests/full_matrix/full_matrix_03.cc @@ -31,10 +31,9 @@ const double entries_Z[9] = { 0,0,0,0,0,0,0,0,0 }; int main () { - std::ofstream logfile("output"); + initlog(); deallog << std::fixed; deallog << std::setprecision(3); - deallog.attach(logfile); Testing::srand(3391466); FullMatrix A(3,3,entries_A); diff --git a/tests/full_matrix/full_matrix_04.cc b/tests/full_matrix/full_matrix_04.cc index e5cded4b15..4c816230b8 100644 --- a/tests/full_matrix/full_matrix_04.cc +++ b/tests/full_matrix/full_matrix_04.cc @@ -112,9 +112,7 @@ void test (const unsigned int n, const unsigned int m) int main () { - const std::string logname = "output"; - std::ofstream logfile(logname.c_str()); - deallog.attach(logfile); + initlog(); test(3,4); test(4,7); diff --git a/tests/full_matrix/full_matrix_05.cc b/tests/full_matrix/full_matrix_05.cc index 46e37b9a40..f5225adea3 100644 --- a/tests/full_matrix/full_matrix_05.cc +++ b/tests/full_matrix/full_matrix_05.cc @@ -56,9 +56,7 @@ void test () int main () { - const std::string logname = "output"; - std::ofstream logfile(logname.c_str()); - deallog.attach(logfile); + initlog(); test(); } diff --git a/tests/full_matrix/full_matrix_06.cc b/tests/full_matrix/full_matrix_06.cc index 854256ffad..19149a2650 100644 --- a/tests/full_matrix/full_matrix_06.cc +++ b/tests/full_matrix/full_matrix_06.cc @@ -66,9 +66,7 @@ void test () int main () { - const std::string logname = "output"; - std::ofstream logfile(logname.c_str()); - deallog.attach(logfile); + initlog(); test(); } diff --git a/tests/full_matrix/full_matrix_07.cc b/tests/full_matrix/full_matrix_07.cc index 982c9affdf..343dc41597 100644 --- a/tests/full_matrix/full_matrix_07.cc +++ b/tests/full_matrix/full_matrix_07.cc @@ -26,10 +26,9 @@ const double compare[9] = { 14,32,50,32,77,122,50,122,194 }; int main () { - std::ofstream logfile("output"); + initlog(); deallog << std::fixed; deallog << std::setprecision(3); - deallog.attach(logfile); FullMatrix A(3,3,entries_A); FullMatrix C(3,3); diff --git a/tests/full_matrix/full_matrix_08.cc b/tests/full_matrix/full_matrix_08.cc index d90193e407..fc9216d022 100644 --- a/tests/full_matrix/full_matrix_08.cc +++ b/tests/full_matrix/full_matrix_08.cc @@ -26,10 +26,9 @@ const double compare[9] = { 66,78,90,78,93,108,90,108,126 }; int main () { - std::ofstream logfile("output"); + initlog(); deallog << std::fixed; deallog << std::setprecision(3); - deallog.attach(logfile); FullMatrix A(3,3,entries_A); FullMatrix C(3,3); diff --git a/tests/full_matrix/full_matrix_common.h b/tests/full_matrix/full_matrix_common.h index c4b71a4fb5..394e360193 100644 --- a/tests/full_matrix/full_matrix_common.h +++ b/tests/full_matrix/full_matrix_common.h @@ -156,9 +156,8 @@ main() { try { - std::ofstream logfile("output"); deallog << std::setprecision (2); - deallog.attach(logfile); + initlog(); deallog.depth_console(0); check (); diff --git a/tests/full_matrix/full_matrix_print.cc b/tests/full_matrix/full_matrix_print.cc index 53ede2b030..e2f496b570 100644 --- a/tests/full_matrix/full_matrix_print.cc +++ b/tests/full_matrix/full_matrix_print.cc @@ -26,11 +26,10 @@ const double entries[9] = { 11.1,12.2,13.3,21.456,22.12345678901,23,31,32,33 }; int main () { - std::ofstream logfile("output"); + initlog(); + std::ostream &logfile = deallog.get_file_stream(); deallog << std::fixed; deallog << std::setprecision(3); - deallog.attach(logfile); - logfile << numbers::PI << std::endl; FullMatrix T(3,3,entries); @@ -47,5 +46,3 @@ main () logfile << numbers::PI << std::endl; } - - diff --git a/tests/grid/distort_random.cc b/tests/grid/distort_random.cc index 8e45d1daaa..a78bb7343a 100644 --- a/tests/grid/distort_random.cc +++ b/tests/grid/distort_random.cc @@ -24,10 +24,6 @@ #include -std::ofstream logfile("output"); - - - template void test1 (const bool keep_boundary) { @@ -37,6 +33,7 @@ void test1 (const bool keep_boundary) GridTools::distort_random (0.1, tria, keep_boundary); + std::ostream &logfile = deallog.get_file_stream(); deallog << "dim=" << dim << ", keep_boundary=" << keep_boundary << std::endl; GridOut().write_gnuplot (tria, logfile); } @@ -45,9 +42,8 @@ void test1 (const bool keep_boundary) int main () { - deallog << std::setprecision(4); - logfile << std::setprecision(4); - deallog.attach(logfile); + initlog(); + deallog.get_file_stream() << std::setprecision(4); test1<1> (true); test1<1> (false); @@ -58,4 +54,3 @@ int main () return 0; } - diff --git a/tests/grid/extent_in_direction.cc b/tests/grid/extent_in_direction.cc index a0a6d26ada..2b3fcc1d84 100644 --- a/tests/grid/extent_in_direction.cc +++ b/tests/grid/extent_in_direction.cc @@ -105,12 +105,10 @@ void test() int main() { - std::ofstream logfile ("output"); + initlog(); deallog << std::setprecision (PRECISION); - deallog.attach(logfile); test<1>(); test<2>(); test<3>(); } - diff --git a/tests/grid/extrude_orientation_01.cc b/tests/grid/extrude_orientation_01.cc index 7cb078c219..192eda9c7d 100644 --- a/tests/grid/extrude_orientation_01.cc +++ b/tests/grid/extrude_orientation_01.cc @@ -69,8 +69,7 @@ void test(std::ostream &out) int main() { - std::ofstream logfile("output"); - deallog.attach(logfile); + initlog(); - test(logfile); + test(deallog.get_file_stream()); } diff --git a/tests/grid/extrude_orientation_02.cc b/tests/grid/extrude_orientation_02.cc index 2224743320..99e884db35 100644 --- a/tests/grid/extrude_orientation_02.cc +++ b/tests/grid/extrude_orientation_02.cc @@ -69,8 +69,7 @@ void test(std::ostream &out) int main() { - std::ofstream logfile("output"); - deallog.attach(logfile); + initlog(); - test(logfile); + test(deallog.get_file_stream()); } diff --git a/tests/grid/face_orientations_3d.cc b/tests/grid/face_orientations_3d.cc index 5ee3374c6d..085f1a78ef 100644 --- a/tests/grid/face_orientations_3d.cc +++ b/tests/grid/face_orientations_3d.cc @@ -31,9 +31,6 @@ -std::ofstream logfile("output"); - - void test (const char *filename) { Triangulation<3> tria; @@ -72,7 +69,7 @@ void test (const char *filename) int main () { deallog << std::setprecision (2); - deallog.attach(logfile); + initlog(); test (SOURCE_DIR "/grid_in_3d/1.in"); test (SOURCE_DIR "/grid_in_3d/2.in"); @@ -82,4 +79,3 @@ int main () test (SOURCE_DIR "/grid_in_3d/evil_0.in"); test (SOURCE_DIR "/grid_in_3d/evil_4.in"); } - diff --git a/tests/grid/filtered_iterator.cc b/tests/grid/filtered_iterator.cc index 9a7ba08842..54c53bec0a 100644 --- a/tests/grid/filtered_iterator.cc +++ b/tests/grid/filtered_iterator.cc @@ -28,9 +28,6 @@ #include -std::ofstream logfile("output"); - - DeclException2 (ExcNumberMismatch, int, int, << "The numbers " << arg1 << " and " << arg2 @@ -83,6 +80,7 @@ void test () cell->set_subdomain_id (subdomain); }; + std::ostream &logfile = deallog.get_file_stream(); // check 1: count number of cells // on some level @@ -218,11 +216,9 @@ void test () int main () { - deallog << std::setprecision(4); - deallog.attach(logfile); - + initlog (); + deallog.get_file_stream() << std::setprecision(4); test (); return 0; } - diff --git a/tests/grid/filtered_iterator_02.cc b/tests/grid/filtered_iterator_02.cc index 7cae4a080a..a639de6d81 100644 --- a/tests/grid/filtered_iterator_02.cc +++ b/tests/grid/filtered_iterator_02.cc @@ -28,9 +28,6 @@ #include -std::ofstream logfile("output"); - - DeclException2 (ExcNumberMismatch, int, int, << "The numbers " << arg1 << " and " << arg2 @@ -83,6 +80,7 @@ void test () cell->set_subdomain_id (subdomain); }; + std::ostream &logfile = deallog.get_file_stream(); // check 1: count number of cells // on some level @@ -217,11 +215,10 @@ void test () int main () { - deallog << std::setprecision(4); - deallog.attach(logfile); + initlog(); + deallog.get_file_stream() << std::setprecision(4); test (); return 0; } - diff --git a/tests/grid/filtered_iterator_03.cc b/tests/grid/filtered_iterator_03.cc index 742cca4d30..b2d7fede1c 100644 --- a/tests/grid/filtered_iterator_03.cc +++ b/tests/grid/filtered_iterator_03.cc @@ -28,9 +28,6 @@ #include -std::ofstream logfile("output"); - - DeclException2 (ExcNumberMismatch, int, int, << "The numbers " << arg1 << " and " << arg2 @@ -77,6 +74,7 @@ void test () cell->set_subdomain_id (subdomain); }; + std::ostream &logfile = deallog.get_file_stream(); // check 1: count number of cells // on some level @@ -103,11 +101,10 @@ void test () int main () { - deallog << std::setprecision(4); - deallog.attach(logfile); + initlog(); + deallog.get_file_stream() << std::setprecision(4); test (); return 0; } - diff --git a/tests/grid/get_finest_common_cells_01.cc b/tests/grid/get_finest_common_cells_01.cc index 2c2c7e3a0c..11fae2b0bc 100644 --- a/tests/grid/get_finest_common_cells_01.cc +++ b/tests/grid/get_finest_common_cells_01.cc @@ -64,11 +64,9 @@ void test() int main() { - std::ofstream logfile ("output"); - deallog.attach(logfile); + initlog(); test<1>(); test<2>(); test<3>(); } - diff --git a/tests/grid/get_finest_common_cells_02.cc b/tests/grid/get_finest_common_cells_02.cc index cc0d4644eb..6ef44f39d3 100644 --- a/tests/grid/get_finest_common_cells_02.cc +++ b/tests/grid/get_finest_common_cells_02.cc @@ -67,11 +67,9 @@ void test() int main() { - std::ofstream logfile ("output"); - deallog.attach(logfile); + initlog(); test<1>(); test<2>(); test<3>(); } - diff --git a/tests/grid/get_finest_common_cells_03.cc b/tests/grid/get_finest_common_cells_03.cc index 2e06d3d6e2..ef1ded774b 100644 --- a/tests/grid/get_finest_common_cells_03.cc +++ b/tests/grid/get_finest_common_cells_03.cc @@ -67,11 +67,9 @@ void test() int main() { - std::ofstream logfile ("output"); - deallog.attach(logfile); + initlog(); test<1>(); test<2>(); test<3>(); } - diff --git a/tests/grid/grid_generator_01.cc b/tests/grid/grid_generator_01.cc index c6726570a7..08c3f3e247 100644 --- a/tests/grid/grid_generator_01.cc +++ b/tests/grid/grid_generator_01.cc @@ -184,16 +184,15 @@ void test(std::ostream &out) int main() { - std::ofstream logfile("output"); - deallog.attach(logfile); + initlog(); deallog.push("1d"); - test<1>(logfile); + test<1>(deallog.get_file_stream()); deallog.pop(); deallog.push("2d"); - test<2>(logfile); + test<2>(deallog.get_file_stream()); deallog.pop(); deallog.push("3d"); - test<3>(logfile); + test<3>(deallog.get_file_stream()); deallog.pop(); } diff --git a/tests/grid/grid_generator_01a.cc b/tests/grid/grid_generator_01a.cc index 88537ddcf0..561c1d355d 100644 --- a/tests/grid/grid_generator_01a.cc +++ b/tests/grid/grid_generator_01a.cc @@ -61,10 +61,9 @@ void test(std::ostream &out) int main() { - std::ofstream logfile("output"); - deallog.attach(logfile); + initlog(); deallog.push("3d"); - test<3>(logfile); + test<3>(deallog.get_file_stream()); deallog.pop(); } diff --git a/tests/grid/grid_generator_01b.cc b/tests/grid/grid_generator_01b.cc index 168c80dfe9..3acbd24ba2 100644 --- a/tests/grid/grid_generator_01b.cc +++ b/tests/grid/grid_generator_01b.cc @@ -51,14 +51,13 @@ void test(std::ostream &out) int main() { - std::ofstream logfile("output"); - deallog.attach(logfile); + initlog(); deallog.push("2d"); - test<2>(logfile); + test<2>(deallog.get_file_stream()); deallog.pop(); deallog.push("3d"); - test<3>(logfile); + test<3>(deallog.get_file_stream()); deallog.pop(); } diff --git a/tests/grid/grid_generator_02.cc b/tests/grid/grid_generator_02.cc index 7f72a5d405..e11de4b216 100644 --- a/tests/grid/grid_generator_02.cc +++ b/tests/grid/grid_generator_02.cc @@ -81,16 +81,15 @@ void test(std::ostream &out) int main() { - std::ofstream logfile("output"); - deallog.attach(logfile); + initlog(); deallog.push("1d"); - test<1>(logfile); + test<1>(deallog.get_file_stream()); deallog.pop(); deallog.push("2d"); - test<2>(logfile); + test<2>(deallog.get_file_stream()); deallog.pop(); deallog.push("3d"); - test<3>(logfile); + test<3>(deallog.get_file_stream()); deallog.pop(); } diff --git a/tests/grid/grid_generator_03.cc b/tests/grid/grid_generator_03.cc index dad51d0745..693859742d 100644 --- a/tests/grid/grid_generator_03.cc +++ b/tests/grid/grid_generator_03.cc @@ -124,16 +124,15 @@ void test(std::ostream &out) int main() { - std::ofstream logfile("output"); - deallog.attach(logfile); + initlog(); deallog.push("1d"); - test<1>(logfile); + test<1>(deallog.get_file_stream()); deallog.pop(); deallog.push("2d"); - test<2>(logfile); + test<2>(deallog.get_file_stream()); deallog.pop(); deallog.push("3d"); - test<3>(logfile); + test<3>(deallog.get_file_stream()); deallog.pop(); } diff --git a/tests/grid/grid_generator_04.cc b/tests/grid/grid_generator_04.cc index 9cb1d15f18..f4a6afad3a 100644 --- a/tests/grid/grid_generator_04.cc +++ b/tests/grid/grid_generator_04.cc @@ -98,13 +98,12 @@ void test(std::ostream &out) int main() { - std::ofstream logfile("output"); - deallog.attach(logfile); + initlog(); deallog.push("2d"); - test<2>(logfile); + test<2>(deallog.get_file_stream()); deallog.pop(); deallog.push("3d"); - test<3>(logfile); + test<3>(deallog.get_file_stream()); deallog.pop(); } diff --git a/tests/grid/grid_generator_05.cc b/tests/grid/grid_generator_05.cc index 2abeea2551..895cd52be7 100644 --- a/tests/grid/grid_generator_05.cc +++ b/tests/grid/grid_generator_05.cc @@ -106,8 +106,7 @@ void test(std::ostream &out) int main() { - std::ofstream logfile("output"); - deallog.attach(logfile); + initlog(); - test<3>(logfile); + test<3>(deallog.get_file_stream()); } diff --git a/tests/grid/grid_generator_06.cc b/tests/grid/grid_generator_06.cc index 930330d36e..37c4469519 100644 --- a/tests/grid/grid_generator_06.cc +++ b/tests/grid/grid_generator_06.cc @@ -42,8 +42,7 @@ void test(std::ostream &out) int main() { - std::ofstream logfile("output"); - deallog.attach(logfile); + initlog(); - test<3>(logfile); + test<3>(deallog.get_file_stream()); } diff --git a/tests/grid/grid_generator_07.cc b/tests/grid/grid_generator_07.cc index 679e2a33c0..a8ec4d960a 100644 --- a/tests/grid/grid_generator_07.cc +++ b/tests/grid/grid_generator_07.cc @@ -52,9 +52,8 @@ void test(std::ostream &out) int main() { - std::ofstream logfile("output"); - deallog.attach(logfile); + initlog(); - test<2>(logfile); - test<3>(logfile); + test<2>(deallog.get_file_stream()); + test<3>(deallog.get_file_stream()); } diff --git a/tests/grid/grid_generator_08.cc b/tests/grid/grid_generator_08.cc index c61edff986..56cce3381c 100644 --- a/tests/grid/grid_generator_08.cc +++ b/tests/grid/grid_generator_08.cc @@ -81,16 +81,15 @@ void test(std::ostream &out) int main() { - std::ofstream logfile("output"); - deallog.attach(logfile); + initlog(); deallog.push("1-2"); - test<1,2>(logfile); + test<1,2>(deallog.get_file_stream()); deallog.pop(); deallog.push("1-3"); - test<1,3>(logfile); + test<1,3>(deallog.get_file_stream()); deallog.pop(); deallog.push("2-3"); - test<2,3>(logfile); + test<2,3>(deallog.get_file_stream()); deallog.pop(); } diff --git a/tests/grid/grid_generator_09.cc b/tests/grid/grid_generator_09.cc index 9b8b0f1918..f106dbb0b0 100644 --- a/tests/grid/grid_generator_09.cc +++ b/tests/grid/grid_generator_09.cc @@ -24,9 +24,6 @@ #include -std::ofstream logfile("output"); - - template void check_rect1 (unsigned int n, bool color, bool log) { @@ -47,14 +44,14 @@ void check_rect1 (unsigned int n, bool color, bool log) if (dim == 2) { if (log) - grid_out.write_xfig (tria, logfile); + grid_out.write_xfig (tria, deallog.get_file_stream()); else grid_out.write_xfig (tria, std::cout); } else { if (log) - grid_out.write_dx (tria, logfile); + grid_out.write_dx (tria, deallog.get_file_stream()); else grid_out.write_dx (tria, std::cout); } @@ -63,6 +60,8 @@ void check_rect1 (unsigned int n, bool color, bool log) int main() { + initlog(); + check_rect1<2> (1, true, true); check_rect1<2> (3, true, true); check_rect1<3> (1, true, true); diff --git a/tests/grid/grid_generator_09.output b/tests/grid/grid_generator_09.output index a78d08b289..99b71546cd 100644 --- a/tests/grid/grid_generator_09.output +++ b/tests/grid/grid_generator_09.output @@ -1,3 +1,4 @@ + #FIG 3.2 Landscape Center diff --git a/tests/grid/grid_generator_hyper_sphere.cc b/tests/grid/grid_generator_hyper_sphere.cc index 7a402ed0ff..7dfd5b3c70 100644 --- a/tests/grid/grid_generator_hyper_sphere.cc +++ b/tests/grid/grid_generator_hyper_sphere.cc @@ -59,9 +59,8 @@ void test(std::ostream &out) int main() { - std::ofstream logfile("output"); - deallog.attach(logfile); + initlog(); - test<1,2>(logfile); - test<2,3>(logfile); + test<1,2>(deallog.get_file_stream()); + test<2,3>(deallog.get_file_stream()); } diff --git a/tests/grid/twisted_parallelepiped_01.cc b/tests/grid/twisted_parallelepiped_01.cc index b1d1a3a480..b9850a37aa 100644 --- a/tests/grid/twisted_parallelepiped_01.cc +++ b/tests/grid/twisted_parallelepiped_01.cc @@ -31,7 +31,7 @@ */ template -void check_parallelepiped (std::ofstream &logfile) +void check_parallelepiped (std::ostream &logfile) { // Data structure defining dim coordinates that make up a // parallelepiped. @@ -77,7 +77,8 @@ void check_parallelepiped (std::ofstream &logfile) int main () { deal_II_exceptions::disable_abort_on_exception(); - std::ofstream logfile ("output"); + initlog(); + std::ostream &logfile = deallog.get_file_stream(); check_parallelepiped<1>(logfile); check_parallelepiped<2>(logfile); diff --git a/tests/grid/twisted_parallelepiped_01.debug.output b/tests/grid/twisted_parallelepiped_01.debug.output index 3a8ca65a9d..164bd359a1 100644 --- a/tests/grid/twisted_parallelepiped_01.debug.output +++ b/tests/grid/twisted_parallelepiped_01.debug.output @@ -1,3 +1,4 @@ + ExcInvalidInputOrientation ("The triangulation you are trying to create will consist of cells" " with negative measures. This is usually the result of input data" " that does not define a right-handed coordinate system. The usual" " fix for this is to ensure that in 1D the given point is to the" " right of the origin (or the given edge tensor is positive), in 2D" " that the two edges (and their cross product) obey the right-hand" " rule (which may usually be done by switching the order of the" " points or edge tensors), or in 3D that the edges form a" " right-handed coordinate system (which may also be accomplished by" " switching the order of the first two points or edge tensors).") ExcInvalidInputOrientation ("The triangulation you are trying to create will consist of cells" " with negative measures. This is usually the result of input data" " that does not define a right-handed coordinate system. The usual" " fix for this is to ensure that in 1D the given point is to the" " right of the origin (or the given edge tensor is positive), in 2D" " that the two edges (and their cross product) obey the right-hand" " rule (which may usually be done by switching the order of the" " points or edge tensors), or in 3D that the edges form a" " right-handed coordinate system (which may also be accomplished by" " switching the order of the first two points or edge tensors).") ExcInvalidInputOrientation ("The triangulation you are trying to create will consist of cells" " with negative measures. This is usually the result of input data" " that does not define a right-handed coordinate system. The usual" " fix for this is to ensure that in 1D the given point is to the" " right of the origin (or the given edge tensor is positive), in 2D" " that the two edges (and their cross product) obey the right-hand" " rule (which may usually be done by switching the order of the" " points or edge tensors), or in 3D that the edges form a" " right-handed coordinate system (which may also be accomplished by" " switching the order of the first two points or edge tensors).")