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
8):
9 def __init__(self):
10 pass
11
13 return """
14 const double maxEigenvalue = kernels::{{SOLVER_NAME}}::maxScaledEigenvalue(
15 repositories::{{SOLVER_INSTANCE}},
16 luh,
17 marker.x(),
18 marker.h(),
19 timeStamp,
20 timeStepSize
21 );
22
23 repositories::{{SOLVER_INSTANCE}}.setMaxEigenvalue(maxEigenvalue);
24
25 // This is a value set for stats reasons. We'll ignore it later as we
26 // ask for a new valid time step size from getAdmissibleTimeStepSize().
27 //const double newTimeStepSize = 0.0;
28 const double newTimeStepSize = repositories::{{SOLVER_INSTANCE}}.getMinCellSize(false) > 0.0 ?
29 repositories::{{SOLVER_INSTANCE}}.getAdmissibleTimeStepSize() * marker.h()(0) / repositories::{{SOLVER_INSTANCE}}.getMinCellSize(false) :
30 0.0;
31"""
32
34 return """
35 if (
36 tarch::mpi::Rank::getInstance().isGlobalMaster()
37 and
38 _maxCellH > 0.0
39 and
40 isFirstGridSweepOfTimeStep()
41 ) {
42 logInfo("startTimeStep(...)", "Solver {{SOLVER_NAME}}:");
43 logInfo("startTimeStep(...)", "t = " << _minTimeStamp);
44 logInfo("startTimeStep(...)", "dt = " << getAdmissibleTimeStepSize());
45 logInfo("startTimeStep(...)", "h_{min} = " << _minCellH);
46 logInfo("startTimeStep(...)", "h_{max} = " << _maxCellH);
47 logInfo("startTimeStep(...)", "lambda_{max} = " << _maxEigenvalue);
48 }
49
50 if (isFirstGridSweepOfTimeStep()) {
51 _maxEigenvalue = 0.0;
52 }
53"""
54
56 """
57 This routine is inserted after we have reduced all global quantities. These
58 are the quantities with the postfix ThisTimeStep.
59 """
60 return (
61 super(
62 AdaptiveTimeSteppingCodeSnippets, self
64 + """
65 if (
66 isLastGridSweepOfTimeStep()
67 and
68 tarch::la::greater(_maxEigenvalue, 0.0)
69 ) {
70 const double minCellSize = _minCellHThisTimeStep;
71 // The max eigenvalue here is already the sum of the eigenvalues in each direction scaled with the volume size in that direction.
72 _admissibleTimeStepSize = std::min(MinTerminalTime - _minTimeStampThisTimeStep, CFL * PNPM / _maxEigenvalue);
73 if (std::isnan(_admissibleTimeStepSize) or std::isinf(_admissibleTimeStepSize)) {
74 ::tarch::triggerNonCriticalAssertion(__FILE__, __LINE__, "_admissibleTimeStepSize > 0", "invalid (NaN of inf) time step size: " + std::to_string(_admissibleTimeStepSize));
75 }
76 if (tarch::la::smallerEquals(_admissibleTimeStepSize, 0.0, 1e-10)) {
77 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 (h=" << minCellSize << ")");
78 }
79 }
80"""
81 )
create_finish_time_step_implementation(self)
This routine is inserted after we have reduced all global quantities.
create_compute_new_time_step_size()
Very similar to create_compute_time_step_size(), this routine should return a code snippet which crea...