Peano
Loading...
Searching...
No Matches
exahype2.api.fv.actionsets.ComputeGlobalCFLCondition.ComputeGlobalCFLCondition Class Reference

Derive the next global time step size from the CFL condition. More...

Inheritance diagram for exahype2.api.fv.actionsets.ComputeGlobalCFLCondition.ComputeGlobalCFLCondition:
Collaboration diagram for exahype2.api.fv.actionsets.ComputeGlobalCFLCondition.ComputeGlobalCFLCondition:

Public Member Functions

 __init__ (self, solver, cfl_constant, patch_size)
 get_body_of_unprepareTraversal (self)
 Called once per rank, after the sweep - the one safe place both to read the solver's reduced maximum eigenvalue (nothing can still be writing it) and to issue an MPI reduction: tarch.mpi.Rank.allReduce()'s own documentation requires "only one thread per rank" to ever call it, which a once-per-rank static method already guarantees.
 get_includes (self)
 Return include statements that you need.
 get_action_set_name (self)
 You should replicate this function in each subclass, so you get meaningful action set names (otherwise, it will be AbstractFVActionSet0,1,2,...).
Public Member Functions inherited from exahype2.api.fv.actionsets.AbstractFVActionSet.AbstractFVActionSet
 __init__ (self, solver)
 solver: ADERDG Reference to creating class
 user_should_modify_template (self)
 Is the user allowed to modify the output.
Public Member Functions inherited from peano4.api.solversteps.ActionSet.ActionSet
 __init__ (self, descend_invocation_order=0, parallel=False)
 get_constructor_body (self)
 Define a tailored constructor body.
 get_static_initialisations (self, full_qualified_classname)
 get_destructor_body (self)
 get_body_of_createGridControlEventsForNextTraversal (self)
 Return the grid control events that this action set wants to trigger.
 get_implementation_of_createGridControlEventsForNextTraversal (self)
 Return the C++ implementation of createGridControlEventsForNextTraversal().
 get_body_of_prepareTraversal (self)
 get_implementation_of_prepareTraversal (self)
 Return the C++ implementation of prepareTraversal().
 get_implementation_of_unprepareTraversal (self)
 Return the C++ implementation of unprepareTraversal().
 get_body_of_operation (self, operation_name)
 Return actual C++ code snippets to be inserted into C++ code.
 get_guard_of_operation (self, operation_name)
 Return the guard of an operation.
 get_implementation_of_operation (self, operation_name)
 Return the C++ implementation of an operation.
bool may_run_in_background_task (self)
 May a task graph compiler move touchCellFirstTime() into a task.
 get_attributes (self)
 Return attributes as copied and pasted into the generated class.

Data Fields

 cfl_constant = cfl_constant
 patch_size = patch_size

Additional Inherited Members

Static Public Attributes inherited from peano4.api.solversteps.ActionSet.ActionSet
int descend_invocation_order = 0
bool parallel = False
str OPERATION_BEGIN_TRAVERSAL = "beginTraversal"
str OPERATION_END_TRAVERSAL = "endTraversal"
str OPERATION_CREATE_PERSISTENT_VERTEX = "createPersistentVertex"
str OPERATION_DESTROY_PERSISTENT_VERTEX = "destroyPersistentVertex"
str OPERATION_CREATE_HANGING_VERTEX = "createHangingVertex"
str OPERATION_DESTROY_HANGING_VERTEX = "destroyHangingVertex"
str OPERATION_CREATE_PERSISTENT_FACE = "createPersistentFace"
str OPERATION_DESTROY_PERSISTENT_FACE = "destroyPersistentFace"
str OPERATION_CREATE_HANGING_FACE = "createHangingFace"
str OPERATION_DESTROY_HANGING_FACE = "destroyHangingFace"
str OPERATION_CREATE_CELL = "createCell"
str OPERATION_DESTROY_CELL = "destroyCell"
str OPERATION_TOUCH_VERTEX_FIRST_TIME = "touchVertexFirstTime"
str OPERATION_TOUCH_VERTEX_LAST_TIME = "touchVertexLastTime"
str OPERATION_TOUCH_FACE_FIRST_TIME = "touchFaceFirstTime"
str OPERATION_TOUCH_FACE_LAST_TIME = "touchFaceLastTime"
str OPERATION_TOUCH_CELL_FIRST_TIME = "touchCellFirstTime"
str OPERATION_TOUCH_CELL_LAST_TIME = "touchCellLastTime"
Protected Attributes inherited from exahype2.api.fv.actionsets.AbstractFVActionSet.AbstractFVActionSet
 _solver = solver

Detailed Description

Derive the next global time step size from the CFL condition.

exahype2.api.fv.actionsets.ComputeMaxEigenvalue stores the maximum eigenvalue of every patch per cell, and exahype2.api.fv.actionsets.ReduceMaxEigenvalue reduces these values into the solver. This action set acts in unprepareTraversal() only: it reads and resets the solver's reduced maximum eigenvalue, turns it into the next time step size, and feeds it into exahype2.Solver's own time step bookkeeping (updateCell()/finishTimeStep()/startTimeStep()). There is deliberately no separate, solver-level time stamp/time step size state on top of exahype2.Solver.

The action set touches no mesh data. The task that hosts it hence is a GLOBAL_END_OF_STEP task (peano4.api.taskgraph.Task.Task.GridEntity), which the task graph compiler fuses into the last traversal of the time step instead of spending a traversal on it.

Global time stepping: all cells share one time stamp and time step size, which are taken from the solver (getMinTimeStamp() and getMinTimeStepSize()) rather than from per-cell bookkeeping.

The kernel updates all dimensions in one explicit Euler step, so the CFL condition reads dt * sum_d lambda_d/h_d <= 1, i.e. the admissible time step size is cfl_constant * h / (Dimensions * lambda_max), with h the minimal volume size and lambda_max the maximum eigenvalue.

As this is global time stepping, getMinTimeStamp()==getMaxTimeStamp() and getMinTimeStepSize()==getMaxTimeStepSize() always hold. Hence a single updateCell() call per time step, not one per cell, is enough to keep both the min and the max in sync.

Definition at line 8 of file ComputeGlobalCFLCondition.py.

Constructor & Destructor Documentation

◆ __init__()

exahype2.api.fv.actionsets.ComputeGlobalCFLCondition.ComputeGlobalCFLCondition.__init__ ( self,
solver,
cfl_constant,
patch_size )
Parameters
solverexahype2.api.Solver Has to host the reduction of the maximum eigenvalue (exahype2.api.fv.MaxEigenvalueReduction).
cfl_constantfloat Safety factor the admissible time step size is scaled down by, relative to the theoretical CFL=1 stability limit (which already accounts for the number of dimensions, see class docstring) -
See also
exahype2.api.fv.RusanovWithExplicitEuler's own cfl_constant parameter, which this is meant to be passed straight through from.
Parameters
patch_sizeint Number of Finite Volumes per patch and dimension. The CFL condition is evaluated over the volume size, i.e. the cell size divided by patch_size.

Definition at line 44 of file ComputeGlobalCFLCondition.py.

Member Function Documentation

◆ get_action_set_name()

exahype2.api.fv.actionsets.ComputeGlobalCFLCondition.ComputeGlobalCFLCondition.get_action_set_name ( self)

You should replicate this function in each subclass, so you get meaningful action set names (otherwise, it will be AbstractFVActionSet0,1,2,...).

Reimplemented from exahype2.api.fv.actionsets.AbstractFVActionSet.AbstractFVActionSet.

Definition at line 164 of file ComputeGlobalCFLCondition.py.

◆ get_body_of_unprepareTraversal()

exahype2.api.fv.actionsets.ComputeGlobalCFLCondition.ComputeGlobalCFLCondition.get_body_of_unprepareTraversal ( self)

Called once per rank, after the sweep - the one safe place both to read the solver's reduced maximum eigenvalue (nothing can still be writing it) and to issue an MPI reduction: tarch.mpi.Rank.allReduce()'s own documentation requires "only one thread per rank" to ever call it, which a once-per-rank static method already guarantees.

This combines two different kinds of "global", reduced two different ways:

  • The mesh size comes out of peano4.grid.GridStatistics, which peano4.parallel.SpacetreeSet reduces over all ranks at the end of every traversal (Grid statistics and other global mesh information). Every rank hence reads the same, global value. GridStatistics holds the cell size; the CFL condition needs the volume size, i.e. the cell size divided by the patch size.
  • The solver's maximum eigenvalue is only a local, per-rank accumulation - that one is reduced directly via tarch.mpi.Rank.allReduce(..., MPI_MAX, ...).

Once newTimeStepSize is known, it folds it into the solver's own time step bookkeeping (see this class' docstring for why a single updateCell() call, not one per cell, is correct for this solver). newTimeStepSize is not truncated by MaxTerminalTime: the last time step may overshoot the end time, and the simulation stops afterwards, i.e. MaxTerminalTime is a lower bound on the final time. The time stamp is advanced by the time step size the update used (getMaxTimeStepSize() before updateCell()), not by newTimeStepSize, which only the next update uses. The very first time step therefore runs with time step size 0 and leaves the time stamp at 0: it only yields the first admissible time step size.

  • updateCell(newTimeStepSize, newTimeStamp) folds the new values into exahype2.Solver's ...UpdatedThisTimeStep accumulators.
  • finishTimeStep() then MPI-all-reduces that accumulator across ranks - a no-op given newTimeStepSize/newTimeStamp are already identical on every rank, but calling it anyway keeps the full exahype2.Solver lifecycle honest for any future override that relies on it actually running.
  • startTimeStep(...) immediately promotes that same accumulator into the stable _minTimeStamp/_maxTimeStamp/_minTimeStepSize/ _maxTimeStepSize fields getMinTimeStamp()/.../getMaxTimeStepSize() expose, so there is no one-phase lag: the very first TimeStep phase must already leave a genuinely positive getMaxTimeStepSize() behind for the generated main loop's tarch.la.greater(maxTimeStepSize,0.0) guard to see, or the simulation could never advance past its first iteration.

Reimplemented from peano4.api.solversteps.ActionSet.ActionSet.

Definition at line 69 of file ComputeGlobalCFLCondition.py.

Referenced by peano4.api.solversteps.ActionSet.ActionSet.get_implementation_of_unprepareTraversal().

Here is the caller graph for this function:

◆ get_includes()

exahype2.api.fv.actionsets.ComputeGlobalCFLCondition.ComputeGlobalCFLCondition.get_includes ( self)

Return include statements that you need.

All of these includes will eventually end up in the header of the generated C++ code.

Reimplemented from exahype2.api.fv.actionsets.AbstractFVActionSet.AbstractFVActionSet.

Definition at line 152 of file ComputeGlobalCFLCondition.py.

Field Documentation

◆ cfl_constant

exahype2.api.fv.actionsets.ComputeGlobalCFLCondition.ComputeGlobalCFLCondition.cfl_constant = cfl_constant

◆ patch_size


The documentation for this class was generated from the following file: