Peano
Loading...
Searching...
No Matches
AdaptiveTimeSteppingCodeSnippets.py
Go to the documentation of this file.
1# This file is part of the ExaHyPE2 project. For conditions of distribution and
2# use, please see the copyright notice at www.peano-framework.org
4
5
7 """
8 Code snippet generator for fixed time stepping in the Runge-Kutta schemes
9 """
10 def __init__(self, time_step_relaxation):
11 self._time_step_relaxation = time_step_relaxation
12
14 return """
15 if (
16 tarch::mpi::Rank::getInstance().isGlobalMaster()
17 and
18 (_maxVolumeH > 0.0 or _maxVolumeHThisTimeStep > 0.0)
19 and
20 isFirstGridSweepOfTimeStep()
21 ) {
22 logInfo("startTimeStep(...)", "Solver {{SOLVER_NAME}}:");
23 logInfo("startTimeStep(...)", "t = " << _minTimeStampThisTimeStep);
24 logInfo("startTimeStep(...)", "dt = " << getAdmissibleTimeStepSize());
25 logInfo("startTimeStep(...)", "h_{min} = " << _minVolumeHThisTimeStep << " (volume size)");
26 logInfo("startTimeStep(...)", "h_{max} = " << _maxVolumeHThisTimeStep << " (volume size)");
27 logInfo("startTimeStep(...)", "lambda_{max} = " << _maxEigenvalue);
28 }
29
30 if (isFirstGridSweepOfTimeStep()) {
31 _maxEigenvalue = 0.0;
32 }
33"""
34
36 """
37 The superclass takes the admissible cell size and divides it by the
38 maximum eigenvalue. The Finite Volume solvers however operate with
39 patches, i.e. we have to divide by the volume count per axis.
40 """
41 return super(AdaptiveTimeSteppingCodeSnippets, self).create_finish_time_step_implementation() + """
42 if (
43 isLastGridSweepOfTimeStep()
44 and
45 tarch::la::greater(_maxEigenvalue, 0.0)
46 ) {
47 _admissibleTimeStepSize = """ + str(self._time_step_relaxation) + """ * _minVolumeHThisTimeStep / _maxEigenvalue;
48 if (std::isnan(_admissibleTimeStepSize) or std::isinf(_admissibleTimeStepSize)) {
49 ::tarch::triggerNonCriticalAssertion( __FILE__, __LINE__, "_admissibleTimeStepSize > 0", "invalid (NaN of inf) time step size: " + std::to_string(_admissibleTimeStepSize) );
50 }
51 if (::tarch::la::smallerEquals(_admissibleTimeStepSize, 0.0, 1e-10)) {
52 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");
53 }
54 }
55"""
create_finish_time_step_implementation(self)
This routine is inserted after we have reduced all global quantities.