SpECTRE Documentation Coverage Report
Current view: top level - Time/TimeSteppers - RungeKutta3.cpp Hit Total Coverage
Commit: b1342d46f40e2d46bbd11d0cef68fd973031a24b Lines: 0 1 0.0 %
Date: 2020-09-24 20:24:42
Legend: Lines: hit not hit

          Line data    Source code
       1           0 : // Distributed under the MIT License.
       2             : // See LICENSE.txt for details.
       3             : 
       4             : #include "Time/TimeSteppers/RungeKutta3.hpp"
       5             : 
       6             : #include <cmath>
       7             : 
       8             : #include "ErrorHandling/Assert.hpp"
       9             : #include "Time/TimeStepId.hpp"
      10             : 
      11             : namespace TimeSteppers {
      12             : 
      13             : uint64_t RungeKutta3::number_of_substeps() const noexcept {
      14             :   return 3;
      15             : }
      16             : 
      17             : size_t RungeKutta3::number_of_past_steps() const noexcept {
      18             :   return 0;
      19             : }
      20             : 
      21             : double RungeKutta3::stable_step() const noexcept {
      22             :   // This is the condition for  y' = -k y  to go to zero.
      23             :   return 0.5 * (1. + cbrt(4. + sqrt(17.)) - 1. / cbrt(4. + sqrt(17.)));
      24             : }
      25             : 
      26             : TimeStepId RungeKutta3::next_time_id(
      27             :     const TimeStepId& current_id,
      28             :     const TimeDelta& time_step) const noexcept {
      29             :   switch (current_id.substep()) {
      30             :     case 0:
      31             :       ASSERT(current_id.substep_time() == current_id.step_time(),
      32             :              "Wrong substep time");
      33             :       return {current_id.time_runs_forward(), current_id.slab_number(),
      34             :               current_id.step_time(), 1, current_id.step_time() + time_step};
      35             :     case 1:
      36             :       ASSERT(current_id.substep_time() == current_id.step_time() + time_step,
      37             :              "Wrong substep time");
      38             :       return {current_id.time_runs_forward(), current_id.slab_number(),
      39             :               current_id.step_time(), 2,
      40             :               current_id.step_time() + time_step / 2};
      41             :     case 2:
      42             :       ASSERT(
      43             :           current_id.substep_time() == current_id.step_time() + time_step / 2,
      44             :           "Wrong substep time");
      45             :       return {current_id.time_runs_forward(), current_id.slab_number(),
      46             :               current_id.step_time() + time_step};
      47             :     default:
      48             :       ERROR("Bad substep value in RK3: " << current_id.substep());
      49             :   }
      50             : }
      51             : 
      52             : }  // namespace TimeSteppers
      53             : 
      54             : /// \cond
      55             : PUP::able::PUP_ID TimeSteppers::RungeKutta3::my_PUP_ID =  // NOLINT
      56             :     0;
      57             : /// \endcond

Generated by: LCOV version 1.14