Peano
Loading...
Searching...
No Matches
FixedTimeSteppingCodeSnippets.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
9 Code snippet generator for fixed time stepping in the Runge-Kutta schemes
10
11 """
12 def __init__(self, normalised_time_step_size, use_enclave_tasking):
13 self._normalised_time_step_size = normalised_time_step_size
14 self._use_enclave_tasking = use_enclave_tasking
15
16
18 """
19
20 The outcome is used before we actually roll over the accumulation variables
21 and other stuff. So we assume that the state is already updated, but the
22 other data is not yet rolled-over.
23
24 I don't want to plot the very first time stamp, where I don't know the
25 cell size yet, so I check _maxCellHThisTimeStep. If we don't know the cell
26 size yet, we haven't done a single grid sweep. In this case, I don't plot
27 anything. The other check isFirstGridSweepOfTimeStep() ensures that I only
28 plot once prior to the first Runge-Kutta step.
29
30 """
31 predicate = """
32 tarch::mpi::Rank::getInstance().isGlobalMaster()
33 and
34 _maxCellHThisTimeStep>0.0
35 and
36 isFirstGridSweepOfTimeStep()
37 """
38
40 predicate += """and (_solverState == SolverState::Primary or _solverState == SolverState::PrimaryAfterGridInitialisation) """
41
42 return """
43 if (""" + predicate + """) {
44 logInfo( "startTimeStep()", "Solver {{SOLVER_NAME}}:" );
45 logInfo( "startTimeStep()", "t = " << _minTimeStampThisTimeStep );
46 logInfo( "startTimeStep()", "dt = " << getTimeStepSize() );
47 logInfo( "startTimeStep()", "h_{min} = " << _minCellHThisTimeStep );
48 logInfo( "startTimeStep()", "h_{max} = " << _maxCellHThisTimeStep );
49 }
50"""
51
52
54 return """
55 if ( isLastGridSweepOfTimeStep() ) {
56 assertion( _minCellH >= 0.0 );
57 assertion( MaxAdmissibleCellH > 0.0 );
58 if (_minCellHThisTimeStep <= MaxAdmissibleCellH) {
59 _timeStepSize = """ + str(self._normalised_time_step_size) + """ * _minCellHThisTimeStep / {{RK_ORDER}} / {{RK_ORDER}};
60 }
61 else {
62 _timeStepSize = 0.0;
63 }
64 }
65"""
66
67