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
6 """
7 Code snippet generator for fixed time stepping in the Runge-Kutta schemes
8 """
9 def __init__(self, time_step_relaxation):
10 self._time_step_relaxation = time_step_relaxation
11
13 return """
14 if (
15 tarch::mpi::Rank::getInstance().isGlobalMaster()
16 and
17 _maxCellHThisTimeStep>0.0
18 and
19 isFirstGridSweepOfTimeStep()
20 ) {
21 logInfo( "startTimeStep()", "Solver {{SOLVER_NAME}}:" );
22 logInfo( "startTimeStep()", "t = " << _minTimeStampThisTimeStep );
23 logInfo( "startTimeStep()", "dt = " << getAdmissibleTimeStepSize() );
24 logInfo( "startTimeStep()", "h_{min} = " << _minCellHThisTimeStep );
25 logInfo( "startTimeStep()", "h_{max} = " << _maxCellHThisTimeStep );
26 logInfo( "startTimeStep()", "lambda_{max} = " << _maxEigenvalue );
27 }
28
29 if (isFirstGridSweepOfTimeStep()) {
30 _maxEigenvalue = 0.0;
31 }
32"""
33
35 """
36 The superclass takes the admissible cell size and divides it by the
37 maximum eigenvalue. The Finite Volume solvers however operate with
38 patches, i.e. we have to devide by the volume count per axis.
39 """
40 return super( AdaptiveTimeSteppingCodeSnippets, self ).create_finish_time_step_implementation() + """
41 if (
42 isLastGridSweepOfTimeStep()
43 and
44 tarch::la::greater(_maxEigenvalue, 0.0 )
45 ) {
46 const double waveSpeedDamping = 1.0 / _maxEigenvalue;
47 constexpr double CockburnShuDamping = 1.0 / (2.0*{{RK_ORDER}}-1.0);
48 constexpr double meshDamping = {{DG_ORDER}}==0 ? 1.0 : 1.0 / ({{DG_ORDER}} * {{DG_ORDER}});
49 _admissibleTimeStepSize = """ + str(self._time_step_relaxation) + """ * _minCellHThisTimeStep * waveSpeedDamping * CockburnShuDamping * meshDamping;
50 if ( std::isnan(_admissibleTimeStepSize) or std::isinf(_admissibleTimeStepSize) ) {
51 ::tarch::triggerNonCriticalAssertion( __FILE__, __LINE__, "_admissibleTimeStepSize>0", "invalid (NaN of inf) time step size: " + std::to_string(_admissibleTimeStepSize) );
52 }
53 if (tarch::la::smallerEquals(_admissibleTimeStepSize,0.0,1e-10) ) {
54 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" );
55 }
56 }
57"""
create_finish_time_step_implementation(self)
This routine is inserted after we have reduced all global quantities.