]> https://gitweb.dealii.org/ - dealii.git/commitdiff
DiscreteTime::set_next_step_size() added 10621/head
authorReza Rastak <rastak@stanford.edu>
Sat, 27 Jun 2020 22:48:31 +0000 (15:48 -0700)
committerReza Rastak <rastak@stanford.edu>
Sun, 19 Jul 2020 16:59:59 +0000 (09:59 -0700)
doc/news/changes/minor/20200627RezaRastak [new file with mode: 0644]
include/deal.II/base/discrete_time.h
source/base/discrete_time.cc
tests/base/discrete_time_1.cc

diff --git a/doc/news/changes/minor/20200627RezaRastak b/doc/news/changes/minor/20200627RezaRastak
new file mode 100644 (file)
index 0000000..c951c0b
--- /dev/null
@@ -0,0 +1,3 @@
+New: The member function DiscreteTime::set_next_step_size() is added.
+<br>
+(Reza Rastak, 2020/06/27)
index a656f7713860b5d45b05db415ca5332a6c8cf0ce..51c81f85f23bdb00afbc918b2009d26c418778b0 100644 (file)
@@ -349,6 +349,22 @@ public:
   void
   set_desired_next_step_size(const double time_step_size);
 
+  /**
+   * Set the *actual* value of the next time step size. By calling this
+   * method, we are indicating the next time advance_time() is called,
+   * @p time_step_size is to be used to advance the simulation time.
+   *
+   * @note The difference between set_next_step_size() and
+   * set_desired_next_step_size() is that the former uses the provided $dt$
+   * exactly without any adjustment, but produces an
+   * error (in debug mode) if $dt$ is not in the acceptable range.
+   * Generally, set_desired_next_step_size() is the preferred method because
+   * it can adjust the $dt$ intelligently, based on $T_{\text{end}}$.
+   * @pre $0 < dt \le T_{\text{end}} - t$.
+   */
+  void
+  set_next_step_size(const double time_step_size);
+
   /**
    * Advance the current time based on the value of the current step.
    * If you want to adjust the next time step size, call the method
index 1ce499e1a5e59d3a0eb02d82ffe1316347e12915..28636a7d54f177afbee4f91ca0d4c8f589b69136 100644 (file)
@@ -66,6 +66,20 @@ DiscreteTime::set_desired_next_step_size(const double next_step_size)
 
 
 
+void
+DiscreteTime::set_next_step_size(const double next_step_size)
+{
+  Assert(next_step_size > 0,
+         ExcMessage("Only positive time step size is allowed."));
+  next_time = current_time + next_step_size;
+  Assert(
+    next_time <= end_time,
+    ExcMessage(
+      "Time step size is too large. The next time cannot exceed the end time."));
+}
+
+
+
 void
 DiscreteTime::advance_time()
 {
index e5461cf19809a0754577673ebbcedf0d4364e935..b37ee917d49ec0d29d37fc117df160b80aea86d9 100644 (file)
@@ -69,7 +69,7 @@ test_adjust_time_step_size()
   print_time(time);
   time.advance_time();
   print_time(time);
-  time.set_desired_next_step_size(0.36);
+  time.set_next_step_size(0.36);
   time.advance_time();
   print_time(time);
   time.advance_time();

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.