]> https://gitweb.dealii.org/ - dealii.git/commitdiff
step 21 to step 29. Adding range-based checks of solver iterations. For example,... 17100/head
authorVladimir Yushutin <vyushut@clemson.edu>
Mon, 3 Jun 2024 20:40:32 +0000 (16:40 -0400)
committerVladimir Yushutin <vyushut@clemson.edu>
Thu, 13 Jun 2024 22:59:44 +0000 (18:59 -0400)
18 files changed:
tests/examples/step-21.diff [new file with mode: 0644]
tests/examples/step-21.output [new file with mode: 0644]
tests/examples/step-22.diff [new file with mode: 0644]
tests/examples/step-22.output [new file with mode: 0644]
tests/examples/step-23.diff [new file with mode: 0644]
tests/examples/step-23.output [new file with mode: 0644]
tests/examples/step-24.diff [new file with mode: 0644]
tests/examples/step-24.output [new file with mode: 0644]
tests/examples/step-25.diff [new file with mode: 0644]
tests/examples/step-25.output [new file with mode: 0644]
tests/examples/step-26.diff [new file with mode: 0644]
tests/examples/step-26.output [new file with mode: 0644]
tests/examples/step-27.diff [new file with mode: 0644]
tests/examples/step-27.output [new file with mode: 0644]
tests/examples/step-28.diff [new file with mode: 0644]
tests/examples/step-28.output [new file with mode: 0644]
tests/examples/step-29.diff [new file with mode: 0644]
tests/examples/step-29.output [new file with mode: 0644]

diff --git a/tests/examples/step-21.diff b/tests/examples/step-21.diff
new file mode 100644 (file)
index 0000000..20bef91
--- /dev/null
@@ -0,0 +1,46 @@
+29c29
+< 
+---
+> #include "../example_test.h"
+512c512
+<     , time(/*start time*/ 0., /*end time*/ 1.)
+---
+>     , time(/*start time*/ 0., /*end time*/ .1)
+906c906,910
+<       cg.solve(schur_complement, solution.block(1), schur_rhs, preconditioner);
+---
+>       check_solver_within_range(std::cout,
+>         cg.solve(schur_complement, solution.block(1), schur_rhs, preconditioner),
+>         solver_control.last_step(),
+>         16, 23);
+> //    cg.solve(schur_complement, solution.block(1), schur_rhs, preconditioner);
+908,909c912,913
+<       std::cout << "   " << solver_control.last_step()
+<                 << " CG Schur complement iterations for pressure." << std::endl;
+---
+> //      std::cout << "   " << solver_control.last_step()
+> //                << " CG Schur complement iterations for pressure." << std::endl;
+950,953c954,961
+<       cg.solve(system_matrix.block(2, 2),
+<                solution.block(2),
+<                system_rhs.block(2),
+<                PreconditionIdentity());
+---
+>       check_solver_within_range(std::cout,
+>                                 cg.solve(system_matrix.block(2, 2), solution.block(2), system_rhs.block(2), PreconditionIdentity()),
+>                                 solver_control.last_step(),
+>                                 1, 2);
+> //      cg.solve(system_matrix.block(2, 2),
+> //               solution.block(2),
+> //               system_rhs.block(2),
+> //               PreconditionIdentity());
+957,958c965,966
+<       std::cout << "   " << solver_control.last_step()
+<                 << " CG iterations for saturation." << std::endl;
+---
+> //      std::cout << "   " << solver_control.last_step()
+> //                << " CG iterations for saturation." << std::endl;
+1127c1135
+<         output_results();
+---
+>       //output_results();
diff --git a/tests/examples/step-21.output b/tests/examples/step-21.output
new file mode 100644 (file)
index 0000000..288d8d9
--- /dev/null
@@ -0,0 +1,22 @@
+Number of active cells: 1024
+Number of degrees of freedom: 4160 (2112+1024+1024)
+
+Timestep 1
+Solver stopped within 16 - 23 iterations
+Solver stopped within 1 - 2 iterations
+   Now at t=0.0326742, dt=0.0326742.
+
+Timestep 2
+Solver stopped within 16 - 23 iterations
+Solver stopped within 1 - 2 iterations
+   Now at t=0.0653816, dt=0.0327074.
+
+Timestep 3
+Solver stopped within 16 - 23 iterations
+Solver stopped within 1 - 2 iterations
+   Now at t=0.0980651, dt=0.0326836.
+
+Timestep 4
+Solver stopped within 16 - 23 iterations
+Solver stopped within 1 - 2 iterations
+   Now at t=0.1, dt=0.00193487.
\ No newline at end of file
diff --git a/tests/examples/step-22.diff b/tests/examples/step-22.diff
new file mode 100644 (file)
index 0000000..da27bb9
--- /dev/null
@@ -0,0 +1,28 @@
+26c26
+< 
+---
+> #include "../example_test.h"
+854c854,858
+<       cg.solve(schur_complement, solution.block(1), schur_rhs, m_inverse);
+---
+>       check_solver_within_range(std::cout,
+>                                 cg.solve(schur_complement, solution.block(1), schur_rhs, m_inverse),
+>                                 solver_control.last_step(),
+>                                 10, 13);
+>       //cg.solve(schur_complement, solution.block(1), schur_rhs, m_inverse);
+861,863c865,867
+<       std::cout << "  " << solver_control.last_step()
+<                 << " outer CG Schur complement iterations for pressure"
+<                 << std::endl;
+---
+> //      std::cout << "  " << solver_control.last_step()
+> //                << " outer CG Schur complement iterations for pressure"
+> //                << std::endl;
+1022c1026
+<     for (unsigned int refinement_cycle = 0; refinement_cycle < 6;
+---
+>     for (unsigned int refinement_cycle = 0; refinement_cycle < 3;
+1038c1042
+<         output_results(refinement_cycle);
+---
+>       //output_results(refinement_cycle);
diff --git a/tests/examples/step-22.output b/tests/examples/step-22.output
new file mode 100644 (file)
index 0000000..62b8867
--- /dev/null
@@ -0,0 +1,20 @@
+Refinement cycle 0
+   Number of active cells: 64
+   Number of degrees of freedom: 679 (594+85)
+   Assembling...
+   Computing preconditioner...
+   Solving...Solver stopped within 10 - 13 iterations
+
+Refinement cycle 1
+   Number of active cells: 160
+   Number of degrees of freedom: 1683 (1482+201)
+   Assembling...
+   Computing preconditioner...
+   Solving...Solver stopped within 10 - 13 iterations
+
+Refinement cycle 2
+   Number of active cells: 376
+   Number of degrees of freedom: 3813 (3370+443)
+   Assembling...
+   Computing preconditioner...
+   Solving...Solver stopped within 10 - 13 iterations
\ No newline at end of file
diff --git a/tests/examples/step-23.diff b/tests/examples/step-23.diff
new file mode 100644 (file)
index 0000000..52aa2d5
--- /dev/null
@@ -0,0 +1,40 @@
+25c25
+< 
+---
+> #include "../example_test.h"
+367c367,371
+<     cg.solve(matrix_u, solution_u, system_rhs, PreconditionIdentity());
+---
+>     check_solver_within_range(std::cout,
+>                               cg.solve(matrix_u, solution_u, system_rhs, PreconditionIdentity()),
+>                               solver_control.last_step(),
+>                               7, 9);
+>     //cg.solve(matrix_u, solution_u, system_rhs, PreconditionIdentity());
+369,370c373,374
+<     std::cout << "   u-equation: " << solver_control.last_step()
+<               << " CG iterations." << std::endl;
+---
+> //    std::cout << "   u-equation: " << solver_control.last_step()
+> //              << " CG iterations." << std::endl;
+381c385,389
+<     cg.solve(matrix_v, solution_v, system_rhs, PreconditionIdentity());
+---
+>     check_solver_within_range(std::cout,
+>                               cg.solve(matrix_v, solution_v, system_rhs, PreconditionIdentity()),
+>                               solver_control.last_step(),
+>                               19, 23);
+> //    cg.solve(matrix_v, solution_v, system_rhs, PreconditionIdentity());
+383,384c391,392
+<     std::cout << "   v-equation: " << solver_control.last_step()
+<               << " CG iterations." << std::endl;
+---
+> //    std::cout << "   v-equation: " << solver_control.last_step()
+> //              << " CG iterations." << std::endl;
+473c481
+<     for (; time <= 5; time += time_step, ++timestep_number)
+---
+>     for (; time <= 0.05; time += time_step, ++timestep_number)
+583c591
+<         output_results();
+---
+>       //output_results();
diff --git a/tests/examples/step-23.output b/tests/examples/step-23.output
new file mode 100644 (file)
index 0000000..bab958a
--- /dev/null
@@ -0,0 +1,15 @@
+Number of active cells: 16384
+Number of degrees of freedom: 16641
+
+Time step 1 at t=0.015625
+Solver stopped within 7 - 9 iterations
+Solver stopped within 19 - 23 iterations
+   Total energy: 1.17887
+Time step 2 at t=0.03125
+Solver stopped within 7 - 9 iterations
+Solver stopped within 19 - 23 iterations
+   Total energy: 2.9655
+Time step 3 at t=0.046875
+Solver stopped within 7 - 9 iterations
+Solver stopped within 19 - 23 iterations
+   Total energy: 4.33761
diff --git a/tests/examples/step-24.diff b/tests/examples/step-24.diff
new file mode 100644 (file)
index 0000000..cefb8d7
--- /dev/null
@@ -0,0 +1,40 @@
+25c25
+< 
+---
+> #include "../example_test.h"
+392c392,396
+<     cg.solve(system_matrix, solution_p, system_rhs_p, PreconditionIdentity());
+---
+>     check_solver_within_range(std::cout,
+>                               cg.solve(system_matrix, solution_p, system_rhs_p, PreconditionIdentity()),
+>                               solver_control.last_step(),
+>                               8, 10);
+> //    cg.solve(system_matrix, solution_p, system_rhs_p, PreconditionIdentity());
+394,395c398,399
+<     std::cout << "   p-equation: " << solver_control.last_step()
+<               << " CG iterations." << std::endl;
+---
+> //    std::cout << "   p-equation: " << solver_control.last_step()
+> //              << " CG iterations." << std::endl;
+406,409c410,417
+<     cg.solve(mass_matrix, solution_v, system_rhs_v, PreconditionIdentity());
+< 
+<     std::cout << "   v-equation: " << solver_control.last_step()
+<               << " CG iterations." << std::endl;
+---
+>     check_solver_within_range(std::cout,
+>                               cg.solve(mass_matrix, solution_v, system_rhs_v, PreconditionIdentity()),
+>                               solver_control.last_step(),
+>                               29, 39);
+> //    cg.solve(mass_matrix, solution_v, system_rhs_v, PreconditionIdentity());
+> //
+> //    std::cout << "   v-equation: " << solver_control.last_step()
+> //              << " CG iterations." << std::endl;
+471c479
+<     const double end_time = 0.7;
+---
+>     const double end_time = 0.01;
+504c512
+<         output_results();
+---
+>       //output_results();
diff --git a/tests/examples/step-24.output b/tests/examples/step-24.output
new file mode 100644 (file)
index 0000000..93290aa
--- /dev/null
@@ -0,0 +1,15 @@
+Number of active cells: 81920
+Number of degrees of freedom: 82177
+
+
+time_step 1 @ t=0.00318473
+Solver stopped within 8 - 10 iterations
+Solver stopped within 29 - 39 iterations
+
+time_step 2 @ t=0.00636946
+Solver stopped within 8 - 10 iterations
+Solver stopped within 29 - 39 iterations
+
+time_step 3 @ t=0.00955419
+Solver stopped within 8 - 10 iterations
+Solver stopped within 29 - 39 iterations
\ No newline at end of file
diff --git a/tests/examples/step-25.diff b/tests/examples/step-25.diff
new file mode 100644 (file)
index 0000000..cb0a7db
--- /dev/null
@@ -0,0 +1,47 @@
+30c30
+< 
+---
+> #include "../example_test.h"
+265c265
+<     , final_time(2.7207)
+---
+>     , final_time(-4.5)
+540c540,544
+<     cg.solve(system_matrix, solution_update, system_rhs, preconditioner);
+---
+>     //cg.solve(system_matrix, solution_update, system_rhs, preconditioner);
+>     check_solver_within_range(std::cout,
+>                               cg.solve(system_matrix, solution_update, system_rhs, preconditioner),
+>                               solver_control.last_step(),
+>                              6, 13);
+602c606
+<     output_results(0);
+---
+>   //output_results(0);
+637,638c641,643
+<             const unsigned int n_iterations = solve();
+< 
+---
+>             //const unsigned int n_iterations = solve();
+>             solve();
+>             
+641,644c646,649
+<             if (first_iteration == true)
+<               std::cout << "    " << n_iterations;
+<             else
+<               std::cout << '+' << n_iterations;
+---
+> //            if (first_iteration == true)
+> //              std::cout << "    " << n_iterations;
+> //            else
+> //              std::cout << '+' << n_iterations;
+649c654
+<         std::cout << " CG iterations per nonlinear step." << std::endl;
+---
+>         //std::cout << " CG iterations per nonlinear step." << std::endl;
+673,674c678,679
+<         if (timestep_number % output_timestep_skip == 0)
+<           output_results(timestep_number);
+---
+>       //if (timestep_number % output_timestep_skip == 0)
+>          //output_results(timestep_number);
diff --git a/tests/examples/step-25.output b/tests/examples/step-25.output
new file mode 100644 (file)
index 0000000..7935cbf
--- /dev/null
@@ -0,0 +1,33 @@
+   Number of active cells: 64
+   Total number of cells: 127
+   Number of degrees of freedom: 65
+
+Time step #1; advancing to t = -5.28515.
+Solver stopped within 6 - 13 iterations
+Solver stopped within 6 - 13 iterations
+Solver stopped within 6 - 13 iterations
+
+Time step #2; advancing to t = -5.1289.
+Solver stopped within 6 - 13 iterations
+Solver stopped within 6 - 13 iterations
+Solver stopped within 6 - 13 iterations
+
+Time step #3; advancing to t = -4.97265.
+Solver stopped within 6 - 13 iterations
+Solver stopped within 6 - 13 iterations
+Solver stopped within 6 - 13 iterations
+
+Time step #4; advancing to t = -4.8164.
+Solver stopped within 6 - 13 iterations
+Solver stopped within 6 - 13 iterations
+Solver stopped within 6 - 13 iterations
+
+Time step #5; advancing to t = -4.66015.
+Solver stopped within 6 - 13 iterations
+Solver stopped within 6 - 13 iterations
+Solver stopped within 6 - 13 iterations
+
+Time step #6; advancing to t = -4.5039.
+Solver stopped within 6 - 13 iterations
+Solver stopped within 6 - 13 iterations
+Solver stopped within 6 - 13 iterations
\ No newline at end of file
diff --git a/tests/examples/step-26.diff b/tests/examples/step-26.diff
new file mode 100644 (file)
index 0000000..b1c1f38
--- /dev/null
@@ -0,0 +1,30 @@
+45c45
+< 
+---
+> #include "../example_test.h"
+275c275,279
+<     cg.solve(system_matrix, solution, system_rhs, preconditioner);
+---
+>     //cg.solve(system_matrix, solution, system_rhs, preconditioner);
+>     check_solver_within_range(std::cout,
+>                               cg.solve(system_matrix, solution, system_rhs, preconditioner),
+>                               solver_control.last_step(),
+>                               6, 9);
+279,280c283,284
+<     std::cout << "     " << solver_control.last_step() << " CG iterations."
+<               << std::endl;
+---
+> //    std::cout << "     " << solver_control.last_step() << " CG iterations."
+> //              << std::endl;
+465c469
+<     output_results();
+---
+>   //output_results();
+473c477
+<     const double end_time = 0.5;
+---
+>     const double end_time = 0.009;
+550c554
+<         output_results();
+---
+>       //output_results();
diff --git a/tests/examples/step-26.output b/tests/examples/step-26.output
new file mode 100644 (file)
index 0000000..3a47066
--- /dev/null
@@ -0,0 +1,51 @@
+
+===========================================
+Number of active cells: 48
+Number of degrees of freedom: 65
+
+Time step 1 at t=0.002
+Solver stopped within 6 - 9 iterations
+
+===========================================
+Number of active cells: 60
+Number of degrees of freedom: 81
+
+
+Time step 1 at t=0.002
+Solver stopped within 6 - 9 iterations
+
+===========================================
+Number of active cells: 99
+Number of degrees of freedom: 130
+
+
+Time step 1 at t=0.002
+Solver stopped within 6 - 9 iterations
+
+===========================================
+Number of active cells: 174
+Number of degrees of freedom: 223
+
+
+Time step 1 at t=0.002
+Solver stopped within 6 - 9 iterations
+
+===========================================
+Number of active cells: 306
+Number of degrees of freedom: 385
+
+
+Time step 1 at t=0.002
+Solver stopped within 6 - 9 iterations
+Time step 2 at t=0.004
+Solver stopped within 6 - 9 iterations
+Time step 3 at t=0.006
+Solver stopped within 6 - 9 iterations
+Time step 4 at t=0.008
+Solver stopped within 6 - 9 iterations
+Time step 5 at t=0.01
+Solver stopped within 6 - 9 iterations
+
+===========================================
+Number of active cells: 543
+Number of degrees of freedom: 660
\ No newline at end of file
diff --git a/tests/examples/step-27.diff b/tests/examples/step-27.diff
new file mode 100644 (file)
index 0000000..b3a9a8b
--- /dev/null
@@ -0,0 +1,8 @@
+396c396
+<       data_out.write_vtk(output);
+---
+>     //data_out.write_vtk(output);
+512c512
+<     for (unsigned int cycle = 0; cycle < 6; ++cycle)
+---
+>     for (unsigned int cycle = 0; cycle < 3; ++cycle)
diff --git a/tests/examples/step-27.output b/tests/examples/step-27.output
new file mode 100644 (file)
index 0000000..33f9b74
--- /dev/null
@@ -0,0 +1,12 @@
+Cycle 0:
+   Number of active cells      : 768
+   Number of degrees of freedom: 3264
+   Number of constraints       : 384
+Cycle 1:
+   Number of active cells      : 807
+   Number of degrees of freedom: 4764
+   Number of constraints       : 756
+Cycle 2:
+   Number of active cells      : 927
+   Number of degrees of freedom: 8226
+   Number of constraints       : 1856
diff --git a/tests/examples/step-28.diff b/tests/examples/step-28.diff
new file mode 100644 (file)
index 0000000..d4062d2
--- /dev/null
@@ -0,0 +1,28 @@
+1584c1584
+<     for (unsigned int cycle = 0; cycle < parameters.n_refinement_cycles;
+---
+>     for (unsigned int cycle = 0; cycle < 1;
+1630c1630
+<             for (unsigned int group = 0; group < parameters.n_groups; ++group)
+---
+>             for (unsigned int group = 0; group < 1; ++group)
+1671,1672c1671,1672
+<         for (unsigned int group = 0; group < parameters.n_groups; ++group)
+<           energy_groups[group]->output_results(cycle);
+---
+>       //for (unsigned int group = 0; group < parameters.n_groups; ++group)
+>       //  energy_groups[group]->output_results(cycle);
+1679,1682c1679,1682
+<         std::cout << "   Cycle=" << cycle << ", n_dofs="
+<                   << energy_groups[0]->n_dofs() + energy_groups[1]->n_dofs()
+<                   << ",  k_eff=" << k_eff << ", time=" << timer.cpu_time()
+<                   << std::endl;
+---
+>       //std::cout << "   Cycle=" << cycle << ", n_dofs="
+>       //          << energy_groups[0]->n_dofs() + energy_groups[1]->n_dofs()
+>       //          << ",  k_eff=" << k_eff << ", time=" << timer.cpu_time()
+>       //          << std::endl;
+1717c1717
+<         filename = "project.prm";
+---
+>         filename = "../../../source/step-28/project.prm";
diff --git a/tests/examples/step-28.output b/tests/examples/step-28.output
new file mode 100644 (file)
index 0000000..2944af8
--- /dev/null
@@ -0,0 +1,12 @@
+Cycle 0:
+   Numbers of active cells:       1156 1156 
+   Numbers of degrees of freedom: 4761 4761 
+
+Iter number: 1 k_eff=491.320865054334 flux_ratio=9.802486617673 max_thermal=1.000000000000
+Iter number: 2 k_eff=427.846932667383 flux_ratio=0.022773665301 max_thermal=1.000000000000
+Iter number: 3 k_eff=427.844771219007 flux_ratio=0.022481398196 max_thermal=1.000000000000
+Iter number: 4 k_eff=427.844770953844 flux_ratio=0.022481387822 max_thermal=1.000000000000
+Iter number: 5 k_eff=427.844770953798 flux_ratio=0.022481387825 max_thermal=1.000000000000
+
+
+
diff --git a/tests/examples/step-29.diff b/tests/examples/step-29.diff
new file mode 100644 (file)
index 0000000..7811883
--- /dev/null
@@ -0,0 +1,24 @@
+470c470
+<     std::cout << "done (" << timer.cpu_time() << "s)" << std::endl;
+---
+>   //std::cout << "done (" << timer.cpu_time() << "s)" << std::endl;
+500c500
+<     std::cout << "done (" << timer.cpu_time() << "s)" << std::endl;
+---
+>   //std::cout << "done (" << timer.cpu_time() << "s)" << std::endl;
+729c729
+<     std::cout << "done (" << timer.cpu_time() << "s)" << std::endl;
+---
+>   //std::cout << "done (" << timer.cpu_time() << "s)" << std::endl;
+769c769
+<     std::cout << "done (" << timer.cpu_time() << "s)" << std::endl;
+---
+>   //std::cout << "done (" << timer.cpu_time() << "s)" << std::endl;
+851c851
+<     output_results();
+---
+>   //output_results();
+874c874
+<       param.read_parameters("step-29.prm");
+---
+>       param.read_parameters("../../../source/step-29/step-29.prm");
diff --git a/tests/examples/step-29.output b/tests/examples/step-29.output
new file mode 100644 (file)
index 0000000..56e987b
--- /dev/null
@@ -0,0 +1,3 @@
+Generating grid...   Number of active cells:  25600
+Setting up system...   Number of degrees of freedom: 51842
+Assembling system matrix... Solving linear system... 

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.