Class/functor for checking a running simulation for non-finite values in a specific field.
If non-finite values are detected in the field that is checked, the simulation is aborted. Optionally, information about all cells that contain non-finite vales can be logged via the Logging or saved as VTK output for further investigation.
It is important to be aware that checking for non-finite values will not work when using FASTMATH: https://stackoverflow.com/questions/22931147/stdisinf-does-not-work-with-ffast-math-how-to-check-for-infinity https://community.intel.com/t5/Intel-C-Compiler/icx-2021-3-0-bug-isinf-wrong-result/m-p/1316407#M39279
Thus a different checkFunction must be used for the StabilityChecker when FASTMATH is enabled.
Do not create objects of class StabilityChecker directly, better use one of the various 'makeStabilityChecker' functions below!
Template parameters:
For the parameters for setting up and controlling the stability checker see the documentation of the constructor of this class.
You do not have to specify an evaluation filter! If you do not specify any filter, all cells are processed and no cell is excluded.
If you want to use a flag field as evaluation filter, fitting 'makeStabilityChecker' functions already exist. These functions need an additional template parameter FlagField_T and you have to provide the block data ID of the flag field together with a set of flag UIDs that specify which cells need to be processed.
There also exist 'makeStabilityChecker' functions that take configuration file data as an additional parameter in order to parse the configuration file for setting up and controlling the stability checker. The configuration file block looks like as follows:
Example:
For documentation of the VTK parameters see VTK via Configuration File.
Note that the shared pointer returned by all 'makeStabilityChecker' functions can be captured by a SharedFunctor for immediate registration at a time loop (see field::makeSharedFunctor).
#include <StabilityChecker.h>
Classes | |
class | FValueVTKWriter |
For each value of a cell, either '0' or '1' is stored in the VTK file. More... | |
class | GlobalCoordVTKWriter |
For each cell, the corresponding global cell coordinates are stored in the VTK file. More... | |
class | LocalCoordVTKWriter |
For each cell, the corresponding block local cell coordinates are stored in the VTK file. More... | |
class | VTKCellFilter |
This cell filter selects only those cells in which at least one non-finite value (= infinite or NaN) was detected. More... | |
Public Member Functions | |
StabilityChecker (const weak_ptr< StructuredBlockStorage > &blocks, const ConstBlockDataID &fieldId, const Filter_T &filter, const uint_t checkFrequency, const bool outputToStream=true, const bool outputVTK=true, const Set< SUID > &requiredSelectors=Set< SUID >::emptySet(), const Set< SUID > &incompatibleSelectors=Set< SUID >::emptySet()) | |
Constructor for class 'StabilityChecker'. More... | |
StabilityChecker (const weak_ptr< StructuredBlockStorage > &blocks, const ConstBlockDataID &fieldId, const Filter_T &filter, const uint_t checkFrequency, CheckFunction_T checkFunction, const bool outputToStream=true, const bool outputVTK=true, const Set< SUID > &requiredSelectors=Set< SUID >::emptySet(), const Set< SUID > &incompatibleSelectors=Set< SUID >::emptySet()) | |
StabilityChecker (const weak_ptr< StructuredBlockStorage > &blocks, const ConstBlockDataID &fieldId, const uint_t checkFrequency, const bool outputToStream=true, const bool outputVTK=true, const Set< SUID > &requiredSelectors=Set< SUID >::emptySet(), const Set< SUID > &incompatibleSelectors=Set< SUID >::emptySet()) | |
StabilityChecker (const weak_ptr< StructuredBlockStorage > &blocks, const ConstBlockDataID &fieldId, const uint_t checkFrequency, CheckFunction_T checkFunction, const bool outputToStream=true, const bool outputVTK=true, const Set< SUID > &requiredSelectors=Set< SUID >::emptySet(), const Set< SUID > &incompatibleSelectors=Set< SUID >::emptySet()) | |
void | setVTKBaseFolder (const std::string &vtkBaseFolder) |
void | setVTKExecutionFolder (const std::string &vtkExecutionFolder) |
void | setVTKIdentifier (const std::string &vtkIdentifier) |
void | setVTKBinary (const bool vtkBinary) |
void | setVTKLittleEndian (const bool vtkLittleEndian) |
void | setVTKMPIIO (const bool vtkMPIIO) |
void | setVTKForcePVTU (const bool vtkForcePVTU) |
void | operator() () |
Private Types | |
using | BlockCellsMap = std::map< const IBlock *, std::map< Cell, std::set< cell_idx_t > >> |
Private Member Functions | |
void | checkBlock (const IBlock *const block) |
Private Attributes | |
weak_ptr< StructuredBlockStorage > | blocks_ |
ConstBlockDataID | fieldId_ |
Filter_T | filter_ |
uint_t | executionCounter_ {uint_c(0)} |
uint_t | checkFrequency_ |
CheckFunction_T | checkFunction_ |
bool | outputToStream_ |
bool | outputVTK_ |
BlockCellsMap | failedCells_ |
std::string | vtkBaseFolder_ {internal::stabilityCheckerVTKBase} |
std::string | vtkExecutionFolder_ {internal::stabilityCheckerVTKFolder} |
std::string | vtkIdentifier_ {internal::stabilityCheckerVTKIdentifier} |
bool | vtkBinary_ {internal::stabilityCheckerVTKBinary} |
bool | vtkLittleEndian_ {internal::stabilityCheckerVTKLittleEndian} |
bool | vtkMPIIO_ {internal::stabilityCheckerVTKMPIIO} |
bool | vtkForcePVTU_ {internal::stabilityCheckerVTKForcePVTU} |
Set< SUID > | requiredSelectors_ |
Set< SUID > | incompatibleSelectors_ |
|
private |
|
inline |
Constructor for class 'StabilityChecker'.
blocks | Shared pointer to a structured block storage |
fieldId | Block data ID of the field that will be checked |
filter | The evaluation filter that indicates which cells are processed |
checkFrequency | If operator()() is called, the stability check is only performed every 'checkFrequency'-th time. Setting 'checkFrequency' to 1 means the stability check is performed each time operator()() is called. Setting 'checkFrequency' to 0 disables the check entirely. |
checkFunction | If a checkFunction is provided it is used to check each value per cell. The checkFunction has the signature "std::function<bool ( const typename Field_T::value_type & value )>". By default the checkFunction checks in each cell math::finite. However, this will not work if the program is compiled with fast math because NaN is not defined then. |
outputToStream | If true, in case a non-finite value is detected in the field, information about the corresponding cells is logged via WALBERLA_LOG_WARNING. |
outputVTK | If true, in case a non-finite value is detected in the field, VTK output is generated and information about the corresponding cells is saved. |
requiredSelectors | Required selectors |
incompatibleSelectors | Incompatible selectors |
|
inline |
|
inline |
|
inline |
|
private |
void walberla::field::StabilityChecker< Field_T, Filter_T, CheckFunction_T >::operator() |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |