3import exahype2.solvers.AdaptiveTimeSteppingCodeSnippets
8 Code snippet generator for fixed time stepping in the Runge-Kutta schemes
10 adaptive_starting_timeStep_size: none, hard, soft
12 def __init__(self, time_step_relaxation, adaptive_starting_timeStep_size="none"):
19 tarch::mpi::Rank::getInstance().isGlobalMaster()
21 (_maxVolumeH > 0.0 or _maxVolumeHThisTimeStep > 0.0)
23 isFirstGridSweepOfTimeStep()
25 logInfo("startTimeStep(...)", "Solver {{SOLVER_NAME}}:");
26 logInfo("startTimeStep(...)", "t = " << _minTimeStampThisTimeStep);
27 logInfo("startTimeStep(...)", "dt = " << getAdmissibleTimeStepSize());
28 logInfo("startTimeStep(...)", "h_{min} = " << _minVolumeHThisTimeStep << " (volume size)");
29 logInfo("startTimeStep(...)", "h_{max} = " << _maxVolumeHThisTimeStep << " (volume size)");
30 logInfo("startTimeStep(...)", "lambda_{max} = " << _maxEigenvalue);
33 if (isFirstGridSweepOfTimeStep()) {
40 The superclass takes the admissible cell size and divides it by the
41 maximum eigenvalue. The Finite Volume solvers however operate with
42 patches, i.e. we have to divide by the volume count per axis.
47 isLastGridSweepOfTimeStep()
49 tarch::la::greater(_maxEigenvalue, 0.0)
51 _admissibleTimeStepSize = """ + str(self.
_time_step_relaxation) +
""" * _minVolumeHThisTimeStep / _maxEigenvalue;
55 temp_implementation +=
"""
56 if (tarch::la::equals(_minTimeStampThisTimeStep, 0, 1e-8)) {_admissibleTimeStepSize *= 1e-3;}
57 if (CheckpointTimeStamp != 0 and tarch::la::equals(_minTimeStampThisTimeStep, CheckpointTimeStamp, 1e-8)) {_admissibleTimeStepSize *= 1e-3;}
60 temp_implementation +=
"""
61 if (_previousTimeStepSize != 0.0 and _previousTimeStepSize<_admissibleTimeStepSize)
62 {_admissibleTimeStepSize = 0.2*_admissibleTimeStepSize + 0.8*_previousTimeStepSize;}
63 _previousTimeStepSize = _admissibleTimeStepSize;
66 temp_implementation +=
"""
67 if (std::isnan(_admissibleTimeStepSize) or std::isinf(_admissibleTimeStepSize)) {
68 ::tarch::triggerNonCriticalAssertion( __FILE__, __LINE__, "_admissibleTimeStepSize > 0", "invalid (NaN of inf) time step size: " + std::to_string(_admissibleTimeStepSize) );
70 if (::tarch::la::smallerEquals(_admissibleTimeStepSize, 0.0, 1e-10)) {
71 logWarning("finishTimeStep()", "degenerated time step size of " << std::to_string(_admissibleTimeStepSize) << ". Problem might be extremely stiff (and can't be solved) or there could be a bug in the eigenvalue computation");
76 return temp_implementation
Code snippet generator for fixed time stepping in the Runge-Kutta schemes.
_adaptive_starting_timeStep_size
create_finish_time_step_implementation(self)
The superclass takes the admissible cell size and divides it by the maximum eigenvalue.
create_start_time_step_implementation(self)
__init__(self, time_step_relaxation, adaptive_starting_timeStep_size="none")