]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add more tests. 15223/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Thu, 18 May 2023 20:40:46 +0000 (14:40 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Thu, 18 May 2023 20:41:06 +0000 (14:41 -0600)
tests/sundials/arkode_10.cc [new file with mode: 0644]
tests/sundials/arkode_10.output [new file with mode: 0644]
tests/sundials/arkode_10_in.prm [new file with mode: 0644]
tests/sundials/arkode_11.cc [new file with mode: 0644]
tests/sundials/arkode_11.output [new file with mode: 0644]
tests/sundials/arkode_11_in.prm [new file with mode: 0644]

diff --git a/tests/sundials/arkode_10.cc b/tests/sundials/arkode_10.cc
new file mode 100644 (file)
index 0000000..6f1efeb
--- /dev/null
@@ -0,0 +1,151 @@
+//-----------------------------------------------------------
+//
+//    Copyright (C) 2020 - 2022 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.
+//
+//-----------------------------------------------------------
+
+#include <deal.II/base/logstream.h>
+#include <deal.II/base/parameter_handler.h>
+
+#include <deal.II/lac/full_matrix.h>
+#include <deal.II/lac/precondition.h>
+#include <deal.II/lac/solver_cg.h>
+#include <deal.II/lac/solver_control.h>
+#include <deal.II/lac/vector.h>
+
+#include <deal.II/sundials/arkode.h>
+
+#include "../tests.h"
+
+
+// Like _08, but throw a recoverable exception when solving with the linearized
+// system.
+
+
+int
+main()
+{
+  initlog();
+
+  using VectorType = Vector<double>;
+
+  ParameterHandler                             prm;
+  SUNDIALS::ARKode<VectorType>::AdditionalData data;
+  data.add_parameters(prm);
+
+  if (false)
+    {
+      std::ofstream ofile(SOURCE_DIR "/arkode_10_in.prm");
+      prm.print_parameters(ofile, ParameterHandler::ShortText);
+      ofile.close();
+    }
+
+  std::ifstream ifile(SOURCE_DIR "/arkode_08_in.prm");
+  prm.parse_input(ifile);
+
+  SUNDIALS::ARKode<VectorType> ode(data);
+
+  // Explicit jacobian = stiffness matrix
+  FullMatrix<double> K(2, 2);
+  K(0, 0) = K(1, 1) = 0.5;
+  K(1, 0) = K(0, 1) = -0.5;
+
+  // mass matrix
+  FullMatrix<double> M(2, 2);
+  M(0, 0) = M(1, 1) = 2.0 / 3;
+  M(1, 0) = M(0, 1) = 1.0 / 3;
+
+  ode.implicit_function = [&](double, const VectorType &y, VectorType &ydot) {
+    K.vmult(ydot, y);
+  };
+
+
+  ode.explicit_function = [&](double, const VectorType &y, VectorType &ydot) {
+    ydot[0] = 1;
+    ydot[1] = 2;
+  };
+
+  ode.jacobian_times_vector = [&](const VectorType &v,
+                                  VectorType &      Jv,
+                                  double            t,
+                                  const VectorType &y,
+                                  const VectorType &fy) { K.vmult(Jv, v); };
+
+  [&](SUNDIALS::SundialsOperator<VectorType> &,
+      SUNDIALS::SundialsPreconditioner<VectorType> &,
+      VectorType &,
+      const VectorType &,
+      double) {
+    deallog << "Reporting recoverable failure." << std::endl;
+    throw RecoverableUserCallbackError();
+  };
+
+  ode.solve_linearized_system =
+    [&](SUNDIALS::SundialsOperator<VectorType> &,
+        SUNDIALS::SundialsPreconditioner<VectorType> &,
+        VectorType &,
+        const VectorType &,
+        double) {
+      deallog << "Reporting recoverable failure when solving linearized system."
+              << std::endl;
+      throw RecoverableUserCallbackError();
+    };
+
+
+  ode.solve_mass = [&](SUNDIALS::SundialsOperator<VectorType> &      op,
+                       SUNDIALS::SundialsPreconditioner<VectorType> &prec,
+                       VectorType &                                  x,
+                       const VectorType &                            b,
+                       double                                        tol) {
+    ReductionControl     control;
+    SolverCG<VectorType> solver_cg(control);
+    solver_cg.solve(op, x, b, prec);
+  };
+
+  FullMatrix<double> M_inv(2, 2);
+
+  ode.mass_preconditioner_solve =
+    [&](double t, const VectorType &r, VectorType &z, double gamma, int lr) {
+      LogStream::Prefix prefix("mass_preconditioner_solve");
+      deallog << "applied" << std::endl;
+      M_inv.vmult(z, r);
+    };
+
+  ode.mass_preconditioner_setup = [&](double t) {
+    LogStream::Prefix prefix("mass_preconditioner_setup");
+    deallog << "applied" << std::endl;
+    M_inv.invert(M);
+  };
+
+  ode.mass_times_vector = [&](const double      t,
+                              const VectorType &v,
+                              VectorType &      Mv) { M.vmult(Mv, v); };
+
+
+  ode.output_step =
+    [&](const double t, const VectorType &sol, const unsigned int step_number) {
+      deallog << t << ' ' << sol[0] << ' ' << sol[1] << std::endl;
+    };
+
+  Vector<double> y(2);
+  y[0] = 1;
+  y[1] = 0;
+
+  try
+    {
+      ode.solve_ode(y);
+    }
+  catch (const std::exception &exc)
+    {
+      deallog << "Caught exception:" << std::endl << exc.what() << std::endl;
+    }
+}
diff --git a/tests/sundials/arkode_10.output b/tests/sundials/arkode_10.output
new file mode 100644 (file)
index 0000000..377b2ea
--- /dev/null
@@ -0,0 +1,258 @@
+
+DEAL::0.00000 1.00000 0.00000
+DEAL:mass_preconditioner_setup::applied
+DEAL:mass_preconditioner_setup::applied
+DEAL:cg::Starting value 2.12132
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL:mass_preconditioner_setup::applied
+DEAL:cg::Starting value 0.707107
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL:cg::Starting value 2.23607
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL:mass_preconditioner_setup::applied
+DEAL::Reporting recoverable failure when solving linearized system.
+DEAL:cg::Starting value 0.707107
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL:cg::Starting value 2.23607
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL:mass_preconditioner_setup::applied
+DEAL::Reporting recoverable failure when solving linearized system.
+DEAL:cg::Starting value 0.707107
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL:cg::Starting value 2.23607
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL:mass_preconditioner_setup::applied
+DEAL::Reporting recoverable failure when solving linearized system.
+DEAL:cg::Starting value 0.707107
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL:cg::Starting value 2.23607
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL:mass_preconditioner_setup::applied
+DEAL::Reporting recoverable failure when solving linearized system.
+DEAL:cg::Starting value 0.707107
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL:cg::Starting value 2.23607
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL:mass_preconditioner_setup::applied
+DEAL::Reporting recoverable failure when solving linearized system.
+DEAL:cg::Starting value 0.707107
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL:cg::Starting value 2.23607
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL:mass_preconditioner_setup::applied
+DEAL::Reporting recoverable failure when solving linearized system.
+DEAL:cg::Starting value 0.707107
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL:cg::Starting value 2.23607
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL:mass_preconditioner_setup::applied
+DEAL::Reporting recoverable failure when solving linearized system.
+DEAL:cg::Starting value 0.707107
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL:cg::Starting value 2.23607
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL:mass_preconditioner_setup::applied
+DEAL:cg::Starting value 2.12132
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL:mass_preconditioner_setup::applied
+DEAL:cg::Starting value 0.707107
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL:cg::Starting value 2.23607
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL:mass_preconditioner_setup::applied
+DEAL::Reporting recoverable failure when solving linearized system.
+DEAL:cg::Starting value 0.707107
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL:cg::Starting value 2.23607
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL:mass_preconditioner_setup::applied
+DEAL::Reporting recoverable failure when solving linearized system.
+DEAL:cg::Starting value 0.707107
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL:cg::Starting value 2.23607
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL:mass_preconditioner_setup::applied
+DEAL::Reporting recoverable failure when solving linearized system.
+DEAL:cg::Starting value 0.707107
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL:cg::Starting value 2.23607
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL:mass_preconditioner_setup::applied
+DEAL::Reporting recoverable failure when solving linearized system.
+DEAL:cg::Starting value 0.707107
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL:cg::Starting value 2.23607
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL:mass_preconditioner_setup::applied
+DEAL::Reporting recoverable failure when solving linearized system.
+DEAL:cg::Starting value 0.707107
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL:cg::Starting value 2.23607
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL:mass_preconditioner_setup::applied
+DEAL::Reporting recoverable failure when solving linearized system.
+DEAL:cg::Starting value 0.707107
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL:cg::Starting value 2.23607
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL:mass_preconditioner_setup::applied
+DEAL::Reporting recoverable failure when solving linearized system.
+DEAL:cg::Starting value 0.707107
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL:cg::Starting value 2.23607
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL:mass_preconditioner_setup::applied
+DEAL:cg::Starting value 2.12132
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL:mass_preconditioner_setup::applied
+DEAL:cg::Starting value 2.12132
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL::0.100000 1.15000 0.150000
+DEAL:mass_preconditioner_setup::applied
+DEAL:cg::Starting value 2.12132
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL::0.200000 1.30000 0.300000
+DEAL:mass_preconditioner_setup::applied
+DEAL:cg::Starting value 0.707107
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 7.85046e-17
+DEAL:cg::Starting value 2.23607
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL:mass_preconditioner_setup::applied
+DEAL::Reporting recoverable failure when solving linearized system.
+DEAL:cg::Starting value 0.707107
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 7.85046e-17
+DEAL:cg::Starting value 2.23607
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL:mass_preconditioner_setup::applied
+DEAL::Reporting recoverable failure when solving linearized system.
+DEAL:cg::Starting value 0.707107
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 7.85046e-17
+DEAL:cg::Starting value 2.23607
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL:mass_preconditioner_setup::applied
+DEAL::Reporting recoverable failure when solving linearized system.
+DEAL:cg::Starting value 0.707107
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 7.85046e-17
+DEAL:cg::Starting value 2.23607
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL:mass_preconditioner_setup::applied
+DEAL::Reporting recoverable failure when solving linearized system.
+DEAL:cg::Starting value 0.707107
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 7.85046e-17
+DEAL:cg::Starting value 2.23607
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL:mass_preconditioner_setup::applied
+DEAL::Reporting recoverable failure when solving linearized system.
+DEAL:cg::Starting value 0.707107
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 7.85046e-17
+DEAL:cg::Starting value 2.23607
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL:mass_preconditioner_setup::applied
+DEAL::Reporting recoverable failure when solving linearized system.
+DEAL:cg::Starting value 0.707107
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 7.85046e-17
+DEAL:cg::Starting value 2.23607
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL:mass_preconditioner_setup::applied
+DEAL::Reporting recoverable failure when solving linearized system.
+DEAL:cg::Starting value 0.707107
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 7.85046e-17
+DEAL:cg::Starting value 2.23607
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL:mass_preconditioner_setup::applied
+DEAL:cg::Starting value 2.12132
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL:mass_preconditioner_setup::applied
+DEAL:cg::Starting value 2.12132
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL::0.300000 1.45000 0.450000
+DEAL:mass_preconditioner_setup::applied
+DEAL:cg::Starting value 2.12132
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL::0.400000 1.60000 0.600000
+DEAL:mass_preconditioner_setup::applied
+DEAL:cg::Starting value 2.12132
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL::0.500000 1.75000 0.750000
+DEAL:mass_preconditioner_setup::applied
+DEAL:cg::Starting value 2.12132
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL::0.600000 1.90000 0.900000
+DEAL:mass_preconditioner_setup::applied
+DEAL:cg::Starting value 2.12132
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL::0.700000 2.05000 1.05000
+DEAL:mass_preconditioner_setup::applied
+DEAL:cg::Starting value 2.12132
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL::0.800000 2.20000 1.20000
+DEAL:mass_preconditioner_setup::applied
+DEAL:cg::Starting value 2.12132
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL::0.900000 2.35000 1.35000
+DEAL:mass_preconditioner_setup::applied
+DEAL:cg::Starting value 2.12132
+DEAL:cg:mass_preconditioner_solve::applied
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL::1.00000 2.50000 1.50000
diff --git a/tests/sundials/arkode_10_in.prm b/tests/sundials/arkode_10_in.prm
new file mode 100644 (file)
index 0000000..f7d62b1
--- /dev/null
@@ -0,0 +1,15 @@
+set Final time                        = 1.
+set Initial time                      = 0.
+set Time interval between each output = 0.1
+subsection Error control
+  set Absolute error tolerance = 0.000001
+  set Relative error tolerance = 0.000010
+end
+subsection Running parameters
+  set Implicit function is linear            = true
+  set Implicit function is time independent  = true
+  set Initial step size                      = 0.010000
+  set Maximum number of nonlinear iterations = 10
+  set Maximum order of ARK                   = 5
+  set Minimum step size                      = 0.000001
+end
diff --git a/tests/sundials/arkode_11.cc b/tests/sundials/arkode_11.cc
new file mode 100644 (file)
index 0000000..75e6de2
--- /dev/null
@@ -0,0 +1,152 @@
+//-----------------------------------------------------------
+//
+//    Copyright (C) 2020 - 2022 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.
+//
+//-----------------------------------------------------------
+
+#include <deal.II/base/logstream.h>
+#include <deal.II/base/parameter_handler.h>
+
+#include <deal.II/lac/full_matrix.h>
+#include <deal.II/lac/precondition.h>
+#include <deal.II/lac/solver_cg.h>
+#include <deal.II/lac/solver_control.h>
+#include <deal.II/lac/vector.h>
+
+#include <deal.II/sundials/arkode.h>
+
+#include "../tests.h"
+
+
+// Like _08, but throw a recoverable exception when solving with the mass
+// matrix.
+
+
+int
+main()
+{
+  initlog();
+
+  using VectorType = Vector<double>;
+
+  ParameterHandler                             prm;
+  SUNDIALS::ARKode<VectorType>::AdditionalData data;
+  data.add_parameters(prm);
+
+  if (false)
+    {
+      std::ofstream ofile(SOURCE_DIR "/arkode_11_in.prm");
+      prm.print_parameters(ofile, ParameterHandler::ShortText);
+      ofile.close();
+    }
+
+  std::ifstream ifile(SOURCE_DIR "/arkode_08_in.prm");
+  prm.parse_input(ifile);
+
+  SUNDIALS::ARKode<VectorType> ode(data);
+
+  // Explicit jacobian = stiffness matrix
+  FullMatrix<double> K(2, 2);
+  K(0, 0) = K(1, 1) = 0.5;
+  K(1, 0) = K(0, 1) = -0.5;
+
+  // mass matrix
+  FullMatrix<double> M(2, 2);
+  M(0, 0) = M(1, 1) = 2.0 / 3;
+  M(1, 0) = M(0, 1) = 1.0 / 3;
+
+  ode.implicit_function = [&](double, const VectorType &y, VectorType &ydot) {
+    K.vmult(ydot, y);
+  };
+
+
+  ode.explicit_function = [&](double, const VectorType &y, VectorType &ydot) {
+    ydot[0] = 1;
+    ydot[1] = 2;
+  };
+
+  ode.jacobian_times_vector = [&](const VectorType &v,
+                                  VectorType &      Jv,
+                                  double            t,
+                                  const VectorType &y,
+                                  const VectorType &fy) { K.vmult(Jv, v); };
+
+  [&](SUNDIALS::SundialsOperator<VectorType> &,
+      SUNDIALS::SundialsPreconditioner<VectorType> &,
+      VectorType &,
+      const VectorType &,
+      double) {
+    deallog << "Reporting recoverable failure." << std::endl;
+    throw RecoverableUserCallbackError();
+  };
+
+  ode.solve_mass = [&](SUNDIALS::SundialsOperator<VectorType> &,
+                       SUNDIALS::SundialsPreconditioner<VectorType> &,
+                       VectorType &,
+                       const VectorType &,
+                       double) {
+    deallog
+      << "Reporting recoverable failure when solving with the mass matrix."
+      << std::endl;
+    throw RecoverableUserCallbackError();
+  };
+
+
+  ode.solve_linearized_system =
+    [&](SUNDIALS::SundialsOperator<VectorType> &      op,
+        SUNDIALS::SundialsPreconditioner<VectorType> &prec,
+        VectorType &                                  x,
+        const VectorType &                            b,
+        double                                        tol) {
+      ReductionControl     control;
+      SolverCG<VectorType> solver_cg(control);
+      solver_cg.solve(op, x, b, prec);
+    };
+
+  FullMatrix<double> M_inv(2, 2);
+
+  ode.mass_preconditioner_solve =
+    [&](double t, const VectorType &r, VectorType &z, double gamma, int lr) {
+      LogStream::Prefix prefix("mass_preconditioner_solve");
+      deallog << "applied" << std::endl;
+      M_inv.vmult(z, r);
+    };
+
+  ode.mass_preconditioner_setup = [&](double t) {
+    LogStream::Prefix prefix("mass_preconditioner_setup");
+    deallog << "applied" << std::endl;
+    M_inv.invert(M);
+  };
+
+  ode.mass_times_vector = [&](const double      t,
+                              const VectorType &v,
+                              VectorType &      Mv) { M.vmult(Mv, v); };
+
+
+  ode.output_step =
+    [&](const double t, const VectorType &sol, const unsigned int step_number) {
+      deallog << t << ' ' << sol[0] << ' ' << sol[1] << std::endl;
+    };
+
+  Vector<double> y(2);
+  y[0] = 1;
+  y[1] = 0;
+
+  try
+    {
+      ode.solve_ode(y);
+    }
+  catch (const std::exception &exc)
+    {
+      deallog << "Caught exception:" << std::endl << exc.what() << std::endl;
+    }
+}
diff --git a/tests/sundials/arkode_11.output b/tests/sundials/arkode_11.output
new file mode 100644 (file)
index 0000000..197f24a
--- /dev/null
@@ -0,0 +1,170 @@
+
+DEAL::0.00000 1.00000 0.00000
+DEAL:mass_preconditioner_setup::applied
+DEAL:mass_preconditioner_setup::applied
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL:mass_preconditioner_setup::applied
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL:mass_preconditioner_setup::applied
+DEAL:cg::Starting value 0.00144957
+DEAL:cg::Convergence step 1 value 3.06659e-19
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL:mass_preconditioner_setup::applied
+DEAL:cg::Starting value 0.00144957
+DEAL:cg::Convergence step 1 value 3.06659e-19
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL:mass_preconditioner_setup::applied
+DEAL:cg::Starting value 0.00144957
+DEAL:cg::Convergence step 1 value 3.06659e-19
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL:mass_preconditioner_setup::applied
+DEAL:cg::Starting value 0.00144957
+DEAL:cg::Convergence step 1 value 3.06659e-19
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL:mass_preconditioner_setup::applied
+DEAL:cg::Starting value 0.00144957
+DEAL:cg::Convergence step 1 value 3.06659e-19
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL:mass_preconditioner_setup::applied
+DEAL:cg::Starting value 0.00144957
+DEAL:cg::Convergence step 1 value 3.06659e-19
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL:mass_preconditioner_setup::applied
+DEAL:cg::Starting value 0.00144957
+DEAL:cg::Convergence step 1 value 3.06659e-19
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL:mass_preconditioner_setup::applied
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL:mass_preconditioner_setup::applied
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL:mass_preconditioner_setup::applied
+DEAL:cg::Starting value 0.0392202
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL:mass_preconditioner_setup::applied
+DEAL:cg::Starting value 0.0392202
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL:mass_preconditioner_setup::applied
+DEAL:cg::Starting value 0.0392202
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL:mass_preconditioner_setup::applied
+DEAL:cg::Starting value 0.0392202
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL:mass_preconditioner_setup::applied
+DEAL:cg::Starting value 0.0392202
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL:mass_preconditioner_setup::applied
+DEAL:cg::Starting value 0.0392202
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL:mass_preconditioner_setup::applied
+DEAL:cg::Starting value 0.0392202
+DEAL:cg::Convergence step 1 value 0.00000
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL:mass_preconditioner_setup::applied
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL:mass_preconditioner_setup::applied
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL::0.100000 1.00000 0.00000
+DEAL:mass_preconditioner_setup::applied
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL::0.200000 1.00000 0.00000
+DEAL:mass_preconditioner_setup::applied
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL:mass_preconditioner_setup::applied
+DEAL:cg::Starting value 0.104287
+DEAL:cg::Convergence step 1 value 1.96262e-17
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL:mass_preconditioner_setup::applied
+DEAL:cg::Starting value 0.104287
+DEAL:cg::Convergence step 1 value 1.96262e-17
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL:mass_preconditioner_setup::applied
+DEAL:cg::Starting value 0.104287
+DEAL:cg::Convergence step 1 value 1.96262e-17
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL:mass_preconditioner_setup::applied
+DEAL:cg::Starting value 0.104287
+DEAL:cg::Convergence step 1 value 1.96262e-17
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL:mass_preconditioner_setup::applied
+DEAL:cg::Starting value 0.104287
+DEAL:cg::Convergence step 1 value 1.96262e-17
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL:mass_preconditioner_setup::applied
+DEAL:cg::Starting value 0.104287
+DEAL:cg::Convergence step 1 value 1.96262e-17
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL:mass_preconditioner_setup::applied
+DEAL:cg::Starting value 0.104287
+DEAL:cg::Convergence step 1 value 1.96262e-17
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL:mass_preconditioner_setup::applied
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL:mass_preconditioner_setup::applied
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL::0.300000 1.00000 0.00000
+DEAL:mass_preconditioner_setup::applied
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL::0.400000 1.00000 0.00000
+DEAL:mass_preconditioner_setup::applied
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL::0.500000 1.00000 0.00000
+DEAL:mass_preconditioner_setup::applied
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL::0.600000 1.00000 0.00000
+DEAL:mass_preconditioner_setup::applied
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL::0.700000 1.00000 0.00000
+DEAL:mass_preconditioner_setup::applied
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL::0.800000 1.00000 0.00000
+DEAL:mass_preconditioner_setup::applied
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL::0.900000 1.00000 0.00000
+DEAL:mass_preconditioner_setup::applied
+DEAL::Reporting recoverable failure when solving with the mass matrix.
+DEAL::Caught exception:
+DEAL::
+--------------------------------------------------------
+An error occurred in line <0> of file <> in function
+    
+The violated condition was: 
+    
+Additional information: 
+    A user call-back function encountered a recoverable error, but the
+    underlying library that called the call-back did not manage to recover
+    from the error and aborted its operation.
+    
+    See the glossary entry on user call-back functions for more
+    information.
+--------------------------------------------------------
+
diff --git a/tests/sundials/arkode_11_in.prm b/tests/sundials/arkode_11_in.prm
new file mode 100644 (file)
index 0000000..f7d62b1
--- /dev/null
@@ -0,0 +1,15 @@
+set Final time                        = 1.
+set Initial time                      = 0.
+set Time interval between each output = 0.1
+subsection Error control
+  set Absolute error tolerance = 0.000001
+  set Relative error tolerance = 0.000010
+end
+subsection Running parameters
+  set Implicit function is linear            = true
+  set Implicit function is time independent  = true
+  set Initial step size                      = 0.010000
+  set Maximum number of nonlinear iterations = 10
+  set Maximum order of ARK                   = 5
+  set Minimum step size                      = 0.000001
+end

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.