]> https://gitweb.dealii.org/ - dealii.git/commitdiff
update patches to -c format, improve step-40 stability
authorMatthias Maier <tamiko@43-1.org>
Sun, 2 Jul 2023 15:31:10 +0000 (10:31 -0500)
committerMatthias Maier <tamiko@43-1.org>
Mon, 3 Jul 2023 04:03:19 +0000 (23:03 -0500)
tests/examples/CMakeLists.txt
tests/examples/example_test.h [new file with mode: 0644]
tests/examples/step-40.diff
tests/examples/step-40.mpirun=2.with_p4est=true.with_petsc=true.output
tests/examples/step-56.diff
tests/examples/update_diffs.sh

index 3f5ef8ad90cdffda07f12897bd980d8511496970..3440d0841698fa745568d25b309a5849162a0e11 100644 (file)
@@ -17,7 +17,7 @@ if (EXISTS "${DEAL_II_SOURCE_DIR}/examples")
   message(STATUS "Temporary binary directory: ${_binary_directory}")
   file(MAKE_DIRECTORY "${_source_directory}")
   file(WRITE "${_source_directory}/CMakeLists.txt" "deal_ii_pickup_tests(examples)")
-  file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/../tests.h" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
+  file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/example_test.h" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
 
   enable_testing()
   file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/CTestFile.cmake" "subdirs(binary)")
diff --git a/tests/examples/example_test.h b/tests/examples/example_test.h
new file mode 100644 (file)
index 0000000..de62b2a
--- /dev/null
@@ -0,0 +1,77 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2004 - 2023 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE.md at
+// the top level directory of deal.II.
+//
+// ---------------------------------------------------------------------
+
+#ifndef dealii_example_test_h
+#define dealii_example_test_h
+
+/*
+ * This is a stripped down version of the infamous tests.h file suitable
+ * for our example step tests. We do not include the much more intrusive
+ * full version.
+ */
+
+#include <deal.II/base/exceptions.h>
+#include <fstream>
+
+/*
+ * Given the name of a file, copy it to std::cout
+ */
+
+void
+cat_file(const char *filename)
+{
+  {
+    std::ifstream in(filename);
+    Assert(in, dealii::ExcIO());
+    std::cout << in.rdbuf() << "\n";
+  }
+}
+
+
+/*
+ * Test that a solver converged within a certain range of iteration steps.
+ *
+ * SolverType_COMMAND is the command to issue, CONTROL_COMMAND a function call
+ * that returns the number of iterations (castable to unsigned int), and
+ * MIN_ALLOWED, MAX_ALLOWED is the inclusive range of allowed iteration
+ * steps.
+ */
+
+#define check_solver_within_range(SolverType_COMMAND,                  \
+                                  CONTROL_COMMAND,                     \
+                                  MIN_ALLOWED,                         \
+                                  MAX_ALLOWED)                         \
+  {                                                                    \
+    try                                                                \
+      {                                                                \
+        SolverType_COMMAND;                                            \
+      }                                                                \
+    catch (SolverControl::NoConvergence & exc)                         \
+      {}                                                               \
+    const unsigned int steps = CONTROL_COMMAND;                        \
+    if (steps >= MIN_ALLOWED && steps <= MAX_ALLOWED)                  \
+      {                                                                \
+        std::cout << "Solver stopped within " << MIN_ALLOWED << " - "  \
+                  << MAX_ALLOWED << " iterations" << std::endl;        \
+      }                                                                \
+    else                                                               \
+      {                                                                \
+        std::cout << "Solver stopped after " << steps << " iterations" \
+                  << std::endl;                                        \
+      }                                                                \
+  }
+
+
+#endif // dealii_example_test_h
index 47d57d33371503ab19c79893e78620f592ca818b..465c92cf9447aa45e4e118824ad17283136f33f4 100644 (file)
@@ -1,8 +1,75 @@
-627c627
-<     const unsigned int n_cycles = 8;
----
->     const unsigned int n_cycles = 3;
-655c655
-<         computing_timer.print_summary();
----
->         // computing_timer.print_summary();
+*** /home/tamiko/workspace/dealii/tests/examples/../../examples/step-40/step-40.cc     2023-06-30 07:12:37.000000000 -0500
+--- step-40.cc 2023-07-02 21:45:20.777870229 -0500
+***************
+*** 18,23 ****
+--- 18,24 ----
+   *         Timo Heister, University of Goettingen, 2009, 2010
+   */
+  
++ #include "../example_test.h"
+  
+  // @sect3{Include files}
+  //
+***************
+*** 493,505 ****
+      LA::MPI::PreconditionAMG preconditioner;
+      preconditioner.initialize(system_matrix, data);
+  
+!     solver.solve(system_matrix,
+!                  completely_distributed_solution,
+!                  system_rhs,
+!                  preconditioner);
+! 
+!     pcout << "   Solved in " << solver_control.last_step() << " iterations."
+!           << std::endl;
+  
+      constraints.distribute(completely_distributed_solution);
+  
+--- 494,506 ----
+      LA::MPI::PreconditionAMG preconditioner;
+      preconditioner.initialize(system_matrix, data);
+  
+!     check_solver_within_range(solver.solve(system_matrix,
+!                                            completely_distributed_solution,
+!                                            system_rhs,
+!                                            preconditioner),
+!                               solver_control.last_step(),
+!                               8,
+!                               15);
+  
+      constraints.distribute(completely_distributed_solution);
+  
+***************
+*** 624,630 ****
+            << " on " << Utilities::MPI::n_mpi_processes(mpi_communicator)
+            << " MPI rank(s)..." << std::endl;
+  
+!     const unsigned int n_cycles = 8;
+      for (unsigned int cycle = 0; cycle < n_cycles; ++cycle)
+        {
+          pcout << "Cycle " << cycle << ':' << std::endl;
+--- 625,631 ----
+            << " on " << Utilities::MPI::n_mpi_processes(mpi_communicator)
+            << " MPI rank(s)..." << std::endl;
+  
+!     const unsigned int n_cycles = 3;
+      for (unsigned int cycle = 0; cycle < n_cycles; ++cycle)
+        {
+          pcout << "Cycle " << cycle << ':' << std::endl;
+***************
+*** 652,658 ****
+            output_results(cycle);
+          }
+  
+!         computing_timer.print_summary();
+          computing_timer.reset();
+  
+          pcout << std::endl;
+--- 653,659 ----
+            output_results(cycle);
+          }
+  
+!         // computing_timer.print_summary();
+          computing_timer.reset();
+  
+          pcout << std::endl;
index 0173dca030843df82fefd057f419b310929d08c5..6bf5cce606c141b2f3bbb26fdae0b70ef01ac292 100644 (file)
@@ -2,15 +2,18 @@ Running with PETSc on 2 MPI rank(s)...
 Cycle 0:
    Number of active cells:       1024
    Number of degrees of freedom: 4225
-   Solved in 10 iterations.
+Solver stopped within 8 - 15 iterations
+Solver stopped within 8 - 15 iterations
 
 Cycle 1:
    Number of active cells:       1960
    Number of degrees of freedom: 8421
-   Solved in 10 iterations.
+Solver stopped within 8 - 15 iterations
+Solver stopped within 8 - 15 iterations
 
 Cycle 2:
    Number of active cells:       3658
    Number of degrees of freedom: 16109
-   Solved in 11 iterations.
+Solver stopped within 8 - 15 iterations
+Solver stopped within 8 - 15 iterations
 
index cb1bf1dbc79a81b25fa5da4d984a71af873834be..844e61e7e5d8c31818ee2a19e46927cbf577c426 100644 (file)
@@ -1,29 +1,70 @@
-1057c1057
-<     triangulation.refine_global(6 - dim);
----
->     triangulation.refine_global(2);
-1097c1097
-<         std::cout << "   VM Peak: " << mem.VmPeak << std::endl;
----
->         // std::cout << "   VM Peak: " << mem.VmPeak << std::endl;
-1099c1099
-<         computing_timer.print_summary();
----
->         // computing_timer.print_summary();
-1113c1113
-<       const int dim    = 3;
----
->       const int dim    = 2;
-1115,1117c1115,1122
-<       StokesProblem<dim> flow_problem(degree, SolverType::FGMRES_GMG);
-< 
-<       flow_problem.run();
----
->       {
->         StokesProblem<dim> flow_problem(degree, SolverType::FGMRES_GMG);
->         flow_problem.run();
->       }
->       {
->         StokesProblem<dim> flow_problem(degree, SolverType::FGMRES_ILU);
->         flow_problem.run();
->       }
+*** /home/tamiko/workspace/dealii/tests/examples/../../examples/step-56/step-56.cc     2023-06-30 07:12:37.000000000 -0500
+--- step-56.cc 2023-07-02 21:24:24.368982230 -0500
+***************
+*** 1054,1060 ****
+    void StokesProblem<dim>::run()
+    {
+      GridGenerator::hyper_cube(triangulation);
+!     triangulation.refine_global(6 - dim);
+  
+      if (solver_type == SolverType::FGMRES_ILU)
+        std::cout << "Now running with ILU" << std::endl;
+--- 1054,1060 ----
+    void StokesProblem<dim>::run()
+    {
+      GridGenerator::hyper_cube(triangulation);
+!     triangulation.refine_global(2);
+  
+      if (solver_type == SolverType::FGMRES_ILU)
+        std::cout << "Now running with ILU" << std::endl;
+***************
+*** 1094,1102 ****
+  
+          Utilities::System::MemoryStats mem;
+          Utilities::System::get_memory_stats(mem);
+!         std::cout << "   VM Peak: " << mem.VmPeak << std::endl;
+  
+!         computing_timer.print_summary();
+          computing_timer.reset();
+        }
+    }
+--- 1094,1102 ----
+  
+          Utilities::System::MemoryStats mem;
+          Utilities::System::get_memory_stats(mem);
+!         // std::cout << "   VM Peak: " << mem.VmPeak << std::endl;
+  
+!         // computing_timer.print_summary();
+          computing_timer.reset();
+        }
+    }
+***************
+*** 1110,1120 ****
+        using namespace Step56;
+  
+        const int degree = 1;
+!       const int dim    = 3;
+        // options for SolverType: UMFPACK FGMRES_ILU FGMRES_GMG
+!       StokesProblem<dim> flow_problem(degree, SolverType::FGMRES_GMG);
+! 
+!       flow_problem.run();
+      }
+    catch (std::exception &exc)
+      {
+--- 1110,1125 ----
+        using namespace Step56;
+  
+        const int degree = 1;
+!       const int dim    = 2;
+        // options for SolverType: UMFPACK FGMRES_ILU FGMRES_GMG
+!       {
+!         StokesProblem<dim> flow_problem(degree, SolverType::FGMRES_GMG);
+!         flow_problem.run();
+!       }
+!       {
+!         StokesProblem<dim> flow_problem(degree, SolverType::FGMRES_ILU);
+!         flow_problem.run();
+!       }
+      }
+    catch (std::exception &exc)
+      {
index 3359cfd59093b353c78dee0cbdd7ad4d697804ae..1399c5879ef0ee290fedb58194c7a9c04fd6aa3c 100755 (executable)
@@ -22,7 +22,7 @@ for file in ${diff_files}; do
   # Check if the corresponding .cc file exists
   if [[ -f "${source_file}" && -f "${modified_file}" ]]; then
     echo diff "${source_file}" "${modified_file}" "${file}"
-    diff -Nur "${source_file}" "${modified_file}" > "${file}"
+    diff -c "${source_file}" "${modified_file}" > "${file}"
     echo success
   else
     echo "No matching .cc files found for ${file}"

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.