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.
22
23 """
24 predicate = """
25 tarch::mpi::Rank::getInstance().isGlobalMaster()
26 and
27 _maxGridCellHThisTimeStep>0.0
28 and
29 isFirstGridSweepOfTimeStep()
30 """
31
33 predicate += """and (_solverState == SolverState::Primary or _solverState == SolverState::PrimaryAfterGridInitialisation) """
34
35 return """
36 if (""" + predicate + """) {
37 logInfo( "startTimeStep()", "Solver {{SOLVER_NAME}}:" );
38 logInfo( "startTimeStep()", "t = " << _minTimeStampThisTimeStep );
39 logInfo( "startTimeStep()", "dt = " << getTimeStepSize() );
40 logInfo( "startTimeStep()", "h_{min} = " << _minGridCellHThisTimeStep << " (individual grid cell within a patch)");
41 logInfo( "startTimeStep()", "h_{max} = " << _maxGridCellHThisTimeStep << " (individual grid cell within a patch)" );
42 }
43"""
44
45
47 return """
48 if ( isLastGridSweepOfTimeStep() ) {
49 assertion( _minGridCellH >= 0.0 );
50 assertion( MaxAdmissibleGridCellH > 0.0 );
51 if (_minGridCellHThisTimeStep <= MaxAdmissibleGridCellH) {
52 _timeStepSize = """ + str(self._normalised_time_step_size) + """ * _minGridCellHThisTimeStep / MaxAdmissibleGridCellH / {{RK_ORDER}} / {{RK_ORDER}};
53 }
54 else {
55 _timeStepSize = 0.0;
56 }
57 }
58"""
59
60