]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add a test that checks that the time step can be increased when using an embedded... 3123/head
authorBruno Turcksin <bruno.turcksin@gmail.com>
Fri, 16 Sep 2016 15:26:09 +0000 (11:26 -0400)
committerBruno Turcksin <bruno.turcksin@gmail.com>
Fri, 16 Sep 2016 15:52:18 +0000 (11:52 -0400)
tests/base/time_stepping_02.cc [new file with mode: 0644]
tests/base/time_stepping_02.output [new file with mode: 0644]

diff --git a/tests/base/time_stepping_02.cc b/tests/base/time_stepping_02.cc
new file mode 100644 (file)
index 0000000..500fe0d
--- /dev/null
@@ -0,0 +1,74 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2016 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 at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+// Check that the time step can be increased when using an embedded method.
+// Bug reported by Vaibhav Palkar on the mailing list.
+
+#include "../tests.h"
+#include <deal.II/base/time_stepping.h>
+#include <deal.II/lac/vector.h>
+
+Vector<double> f(double const t, Vector<double> const &y)
+{
+  Vector<double> values(y);
+  for (unsigned int i=0; i<values.size(); ++i)
+    values[i] = 1.0;
+
+  return values;
+}
+
+double my(double const t)
+{
+  return t;
+}
+
+void test(TimeStepping::EmbeddedExplicitRungeKutta<Vector<double> > &solver,
+          std_cxx11::function<Vector<double> (double const, Vector<double> const &)> f,
+          std_cxx11::function<double (double const)> my)
+{
+  double initial_time = 0.0, final_time = 1.0;
+  double time_step = 0.1;
+  unsigned int size = 1;
+  unsigned int n_time_steps = 0;
+  double time = initial_time;
+  Vector<double> solution(size);
+  for (unsigned int i=0; i<size; ++i)
+    solution[i] = my(initial_time);
+
+
+  while (time<final_time)
+    {
+      if (time+time_step>final_time)
+        time_step = final_time - time;
+      time = solver.evolve_one_time_step(f,time,time_step,solution);
+      time_step = solver.get_status().delta_t_guess;
+      ++n_time_steps;
+    }
+
+  deallog<<n_time_steps<<std::endl;
+}
+
+int main()
+{
+  std::ofstream logfile("output");
+  deallog.attach(logfile);
+  deallog.threshold_double(1.e-10);
+
+  TimeStepping::EmbeddedExplicitRungeKutta<Vector<double> > he(TimeStepping::HEUN_EULER);
+  test(he,f,my);
+
+  return 0;
+}
diff --git a/tests/base/time_stepping_02.output b/tests/base/time_stepping_02.output
new file mode 100644 (file)
index 0000000..c05ebbb
--- /dev/null
@@ -0,0 +1,2 @@
+
+DEAL::7

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.