Peano
Loading...
Searching...
No Matches
AdaptiveSubcyclingTimeSteppingCodeSnippets.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, time_step_relaxation, use_enclave_tasking):
13 self._time_step_relaxation = time_step_relaxation
14 self._use_enclave_tasking = use_enclave_tasking
15
16
18 predicate = """
19 tarch::mpi::Rank::getInstance().isGlobalMaster()
20 and
21 _maxVolumeH>0.0
22 """
23
24 if use_enclave_tasking:
25 predicate += """and (_solverState == SolverState::Primary or _solverState == SolverState::PrimaryAfterGridInitialisation) """
26
27 statistics = """
28 if (""" + predicate + """) {
29 logInfo( "startTimeStep()", "Solver {{SOLVER_NAME}}:" );
30 logInfo( "startTimeStep()", "t_{min,global} = " << _minTimeStamp );
31 logInfo( "startTimeStep()", "t_{max,global} = " << _maxTimeStamp );
32 logInfo( "startTimeStep()", "t_{min,this-step} = " << _minTimeStampThisTimeStep );
33 logInfo( "startTimeStep()", "t_{max,this-step} = " << _maxTimeStampThisTimeStep );
34 if (_minTimeStepSize > _maxTimeStepSize ) {
35 logInfo( "startTimeStep()", "dt_{min} = <not yet known>" );
36 logInfo( "startTimeStep()", "dt_{max} = <not yet known>" );
37 }
38 else {
39 logInfo( "startTimeStep()", "dt_{min,this-step} = " << _minTimeStepSize );
40 logInfo( "startTimeStep()", "dt_{max,this-step} = " << _maxTimeStepSize );
41 }
42 logInfo( "startTimeStep()", "h_{min} = " << _minVolumeH << " (volume size)");
43 logInfo( "startTimeStep()", "h_{max} = " << _maxVolumeH << " (volume size)" );
44 logInfo( "startTimeStep()", "lambda_{max} = " << _maxEigenvalue );
45 logInfo( "startTimeStep()", "#updates = " << _patchUpdates << " (no of patches)" );
46 }
47"""
48
49 if use_enclave_tasking:
50 clear_max_eigenvalue = """if (_solverState == SolverState::Primary or _solverState == SolverState::PrimaryAfterGridInitialisation) {
51 _maxEigenvalue = 0.0;
52}"""
53 else:
54 clear_max_eigenvalue = """if (_solverState == SolverState::TimeStep or _solverState == SolverState::TimeStepAfterGridInitialisation) {
55 _maxEigenvalue = 0.0;
56}"""
57
58 return statistics + clear_max_eigenvalue
59
60
62 """
63
64 The superclass takes the admissible cell size and divides it by the
65 maximum eigenvalue. The Finite Volume solvers however operate with
66 patches, i.e. we have to devide by the volume count per axis.
67
68 """
69 code_snippet = super( AdaptiveTimeSteppingCodeSnippets, self ).create_finish_time_step_implementation() + """
70 if ( tarch::la::greater(_maxEigenvalue, 0.0 ) ) {
71 _admissibleTimeStepSize = """ + str(self._time_step_relaxation) + """ * _minVolumeHThisTimeStep / _maxEigenvalue;
72 if ( std::isnan(_admissibleTimeStepSize) or std::isinf(_admissibleTimeStepSize) ) {
73 ::tarch::triggerNonCriticalAssertion( __FILE__, __LINE__, "_admissibleTimeStepSize>0", "invalid (NaN of inf) time step size: " + std::to_string(_admissibleTimeStepSize) );
74 }
75 if (tarch::la::smallerEquals(_admissibleTimeStepSize,0.0,1e-10) ) {
76 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" );
77 }
78 }
79"""
81 return """
82if (_solverState==SolverState::Secondary) {
83""" + code_snippet + """
84}
85"""
86 else:
87 return code_snippet
88
create_finish_time_step_implementation(self)
The superclass takes the admissible cell size and divides it by the maximum eigenvalue.