[cig-commits] commit 2004 by heister to /var/svn/dealii/aspect
dealii.demon at gmail.com
dealii.demon at gmail.com
Sat Nov 2 16:23:16 PDT 2013
Revision 2004
add 'Nonlinear solver tolerance' and abort iteration if reached
U trunk/aspect/doc/modules/changes.h
U trunk/aspect/include/aspect/simulator.h
U trunk/aspect/source/simulator/core.cc
U trunk/aspect/source/simulator/parameters.cc
http://www.dealii.org/websvn/revision.php?repname=Aspect+Repository&path=%2F&rev=2004&peg=2004
Diff:
Modified: trunk/aspect/doc/modules/changes.h
===================================================================
--- trunk/aspect/doc/modules/changes.h 2013-11-02 23:20:52 UTC (rev 2003)
+++ trunk/aspect/doc/modules/changes.h 2013-11-02 23:22:19 UTC (rev 2004)
@@ -8,6 +8,11 @@
</p>
<ol>
+ <li>New: the "iterated Stokes" nonlinear solver will now stop iterating
+ if the residual is smaller than the new "Nonlinear solver tolerance".
+ <br>
+ (Timo Heister 2013/11/02)
+
<li>New: add a visual postprocessor that outputs the artificial
viscosity parameter for the temperature equation on each cell.
<br>
Modified: trunk/aspect/include/aspect/simulator.h
===================================================================
--- trunk/aspect/include/aspect/simulator.h 2013-11-02 23:20:52 UTC (rev 2003)
+++ trunk/aspect/include/aspect/simulator.h 2013-11-02 23:22:19 UTC (rev 2004)
@@ -158,6 +158,7 @@
NonlinearSolverKind nonlinear_solver;
+ double nonlinear_tolerance;
bool resume_computation;
double start_time;
double CFL_number;
Modified: trunk/aspect/source/simulator/core.cc
===================================================================
--- trunk/aspect/source/simulator/core.cc 2013-11-02 23:20:52 UTC (rev 2003)
+++ trunk/aspect/source/simulator/core.cc 2013-11-02 23:22:19 UTC (rev 2004)
@@ -1094,6 +1094,11 @@
= solution.block(introspection.block_indices.compositional_fields[c]);
}
+
+ // residual vector (only for the velocity)
+ LinearAlgebra::Vector residual (introspection.index_sets.system_partitioning[0], mpi_communicator);
+ LinearAlgebra::Vector tmp (introspection.index_sets.system_partitioning[0], mpi_communicator);
+
// ...and then iterate the solution
// of the Stokes system
for (unsigned int i=0; i< parameters.max_nonlinear_iterations; ++i)
@@ -1106,11 +1111,21 @@
assemble_stokes_system();
build_stokes_preconditioner();
solve_stokes();
+
+ // check for convergence:
+ residual = solution.block(introspection.block_indices.velocities);
+ tmp = current_linearization_point.block(introspection.block_indices.velocities);
+ residual -= tmp; // TODO: why can I not use a ghosted vector to read from?!
+ pcout << " residual: " << residual.l2_norm() << std::endl;
+ if (residual.l2_norm() < parameters.nonlinear_tolerance)
+ break;
+
current_linearization_point.block(introspection.block_indices.velocities)
= solution.block(introspection.block_indices.velocities);
current_linearization_point.block(introspection.block_indices.pressure)
= solution.block(introspection.block_indices.pressure);
+
pcout << std::endl;
}
Modified: trunk/aspect/source/simulator/parameters.cc
===================================================================
--- trunk/aspect/source/simulator/parameters.cc 2013-11-02 23:20:52 UTC (rev 2003)
+++ trunk/aspect/source/simulator/parameters.cc 2013-11-02 23:22:19 UTC (rev 2004)
@@ -135,6 +135,12 @@
"temperature equation (careful, the material model must not depend on "
"the temperature; mostly useful for Stokes benchmarks).");
+ prm.declare_entry ("Nonlinear solver tolerance", "1e-9",
+ Patterns::Double(0,1),
+ "A relative tolerance up to which the nonlinear solver "
+ "will iterate. This parameter is only relevant if "
+ "Nonlinear solver scheme is set to 'iterated Stokes'.");
+
prm.declare_entry ("Pressure normalization", "surface",
Patterns::Selection ("surface|volume|no"),
"If and how to normalize the pressure after the solution step. "
@@ -503,6 +509,8 @@
else
AssertThrow (false, ExcNotImplemented());
+ nonlinear_tolerance = prm.get_double("Nonlinear solver tolerance");
+
max_nonlinear_iterations = prm.get_integer ("Max nonlinear iterations");
start_time = prm.get_double ("Start time");
if (convert_to_years == true)
More information about the CIG-COMMITS
mailing list