walberla::field::StabilityChecker< Field_T, Filter_T, CheckFunction_T > Class Template Reference

Detailed Description

template<typename Field_T, typename Filter_T = DefaultEvaluationFilter, typename CheckFunction_T = std::function<bool ( const typename Field_T::value_type & value )>>
class walberla::field::StabilityChecker< Field_T, Filter_T, CheckFunction_T >

Class/functor for checking a running simulation for non-finite values in a specific field.

Stability Checker

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:

  • Field_T: the field storing the simulation values (also works if the field stores data of type Vector3)
  • Filter_T: the type of the evaluation filter (see Evaluation Filter in 'EvaluationFilter.h')

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:

{
checkFrequency [unsigned integer]; // check frequency [default:0]
streamOutput [boolean]; // output to stream? [default: true]
vtkOutput [boolean]; // output to VTK? [default:true]
vtkBaseFolder [string]; // VTK base folder [default: vtk_out]
vtkExecutionFolder [string]; // VTK execution folder [default:output]
vtkIdentifier [string]; // VTK identifier [default: error_field]
vtkBinary [boolean]; // write VTK data in binary? [default: true]
vtkLittleEndian [boolean]; // VTK binary file format [default: true (= little endian)]
vtkMPIIO [boolean]; // use MPI IO for creating VTK output? [default: true]
vtkForcePVTU [boolean]; // force VTK to generate a PVTU file? [default: false]
}

Example:

{
checkFrequency 100;
streamOutput false;
vtkOutput true;
vtkBaseFolder /home/anonymous/vtk;
}

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< StructuredBlockStorageblocks_
 
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_
 

Member Typedef Documentation

◆ BlockCellsMap

template<typename Field_T , typename Filter_T = DefaultEvaluationFilter, typename CheckFunction_T = std::function<bool ( const typename Field_T::value_type & value )>>
using walberla::field::StabilityChecker< Field_T, Filter_T, CheckFunction_T >::BlockCellsMap = std::map<const IBlock *, std::map<Cell, std::set<cell_idx_t> >>
private

Constructor & Destructor Documentation

◆ StabilityChecker() [1/4]

template<typename Field_T , typename Filter_T = DefaultEvaluationFilter, typename CheckFunction_T = std::function<bool ( const typename Field_T::value_type & value )>>
walberla::field::StabilityChecker< Field_T, Filter_T, CheckFunction_T >::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() 
)
inline

Constructor for class 'StabilityChecker'.

Parameters
blocksShared pointer to a structured block storage
fieldIdBlock data ID of the field that will be checked
filterThe evaluation filter that indicates which cells are processed
checkFrequencyIf 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.
checkFunctionIf 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.
outputToStreamIf true, in case a non-finite value is detected in the field, information about the corresponding cells is logged via WALBERLA_LOG_WARNING.
outputVTKIf true, in case a non-finite value is detected in the field, VTK output is generated and information about the corresponding cells is saved.
requiredSelectorsRequired selectors
incompatibleSelectorsIncompatible selectors

◆ StabilityChecker() [2/4]

template<typename Field_T , typename Filter_T = DefaultEvaluationFilter, typename CheckFunction_T = std::function<bool ( const typename Field_T::value_type & value )>>
walberla::field::StabilityChecker< Field_T, Filter_T, CheckFunction_T >::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() 
)
inline

◆ StabilityChecker() [3/4]

template<typename Field_T , typename Filter_T = DefaultEvaluationFilter, typename CheckFunction_T = std::function<bool ( const typename Field_T::value_type & value )>>
walberla::field::StabilityChecker< Field_T, Filter_T, CheckFunction_T >::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() 
)
inline

◆ StabilityChecker() [4/4]

template<typename Field_T , typename Filter_T = DefaultEvaluationFilter, typename CheckFunction_T = std::function<bool ( const typename Field_T::value_type & value )>>
walberla::field::StabilityChecker< Field_T, Filter_T, CheckFunction_T >::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() 
)
inline

Member Function Documentation

◆ checkBlock()

template<typename Field_T , typename Filter_T , typename CheckFunction_T >
void walberla::field::StabilityChecker< Field_T, Filter_T, CheckFunction_T >::checkBlock ( const IBlock *const  block)
private

◆ operator()()

template<typename Field_T , typename Filter_T , typename CheckFunction_T >
void walberla::field::StabilityChecker< Field_T, Filter_T, CheckFunction_T >::operator()

◆ setVTKBaseFolder()

template<typename Field_T , typename Filter_T = DefaultEvaluationFilter, typename CheckFunction_T = std::function<bool ( const typename Field_T::value_type & value )>>
void walberla::field::StabilityChecker< Field_T, Filter_T, CheckFunction_T >::setVTKBaseFolder ( const std::string &  vtkBaseFolder)
inline

◆ setVTKBinary()

template<typename Field_T , typename Filter_T = DefaultEvaluationFilter, typename CheckFunction_T = std::function<bool ( const typename Field_T::value_type & value )>>
void walberla::field::StabilityChecker< Field_T, Filter_T, CheckFunction_T >::setVTKBinary ( const bool  vtkBinary)
inline

◆ setVTKExecutionFolder()

template<typename Field_T , typename Filter_T = DefaultEvaluationFilter, typename CheckFunction_T = std::function<bool ( const typename Field_T::value_type & value )>>
void walberla::field::StabilityChecker< Field_T, Filter_T, CheckFunction_T >::setVTKExecutionFolder ( const std::string &  vtkExecutionFolder)
inline

◆ setVTKForcePVTU()

template<typename Field_T , typename Filter_T = DefaultEvaluationFilter, typename CheckFunction_T = std::function<bool ( const typename Field_T::value_type & value )>>
void walberla::field::StabilityChecker< Field_T, Filter_T, CheckFunction_T >::setVTKForcePVTU ( const bool  vtkForcePVTU)
inline

◆ setVTKIdentifier()

template<typename Field_T , typename Filter_T = DefaultEvaluationFilter, typename CheckFunction_T = std::function<bool ( const typename Field_T::value_type & value )>>
void walberla::field::StabilityChecker< Field_T, Filter_T, CheckFunction_T >::setVTKIdentifier ( const std::string &  vtkIdentifier)
inline

◆ setVTKLittleEndian()

template<typename Field_T , typename Filter_T = DefaultEvaluationFilter, typename CheckFunction_T = std::function<bool ( const typename Field_T::value_type & value )>>
void walberla::field::StabilityChecker< Field_T, Filter_T, CheckFunction_T >::setVTKLittleEndian ( const bool  vtkLittleEndian)
inline

◆ setVTKMPIIO()

template<typename Field_T , typename Filter_T = DefaultEvaluationFilter, typename CheckFunction_T = std::function<bool ( const typename Field_T::value_type & value )>>
void walberla::field::StabilityChecker< Field_T, Filter_T, CheckFunction_T >::setVTKMPIIO ( const bool  vtkMPIIO)
inline

Member Data Documentation

◆ blocks_

template<typename Field_T , typename Filter_T = DefaultEvaluationFilter, typename CheckFunction_T = std::function<bool ( const typename Field_T::value_type & value )>>
weak_ptr< StructuredBlockStorage > walberla::field::StabilityChecker< Field_T, Filter_T, CheckFunction_T >::blocks_
private

◆ checkFrequency_

template<typename Field_T , typename Filter_T = DefaultEvaluationFilter, typename CheckFunction_T = std::function<bool ( const typename Field_T::value_type & value )>>
uint_t walberla::field::StabilityChecker< Field_T, Filter_T, CheckFunction_T >::checkFrequency_
private

◆ checkFunction_

template<typename Field_T , typename Filter_T = DefaultEvaluationFilter, typename CheckFunction_T = std::function<bool ( const typename Field_T::value_type & value )>>
CheckFunction_T walberla::field::StabilityChecker< Field_T, Filter_T, CheckFunction_T >::checkFunction_
private

◆ executionCounter_

template<typename Field_T , typename Filter_T = DefaultEvaluationFilter, typename CheckFunction_T = std::function<bool ( const typename Field_T::value_type & value )>>
uint_t walberla::field::StabilityChecker< Field_T, Filter_T, CheckFunction_T >::executionCounter_ {uint_c(0)}
private

◆ failedCells_

template<typename Field_T , typename Filter_T = DefaultEvaluationFilter, typename CheckFunction_T = std::function<bool ( const typename Field_T::value_type & value )>>
BlockCellsMap walberla::field::StabilityChecker< Field_T, Filter_T, CheckFunction_T >::failedCells_
private

◆ fieldId_

template<typename Field_T , typename Filter_T = DefaultEvaluationFilter, typename CheckFunction_T = std::function<bool ( const typename Field_T::value_type & value )>>
ConstBlockDataID walberla::field::StabilityChecker< Field_T, Filter_T, CheckFunction_T >::fieldId_
private

◆ filter_

template<typename Field_T , typename Filter_T = DefaultEvaluationFilter, typename CheckFunction_T = std::function<bool ( const typename Field_T::value_type & value )>>
Filter_T walberla::field::StabilityChecker< Field_T, Filter_T, CheckFunction_T >::filter_
private

◆ incompatibleSelectors_

template<typename Field_T , typename Filter_T = DefaultEvaluationFilter, typename CheckFunction_T = std::function<bool ( const typename Field_T::value_type & value )>>
Set<SUID> walberla::field::StabilityChecker< Field_T, Filter_T, CheckFunction_T >::incompatibleSelectors_
private

◆ outputToStream_

template<typename Field_T , typename Filter_T = DefaultEvaluationFilter, typename CheckFunction_T = std::function<bool ( const typename Field_T::value_type & value )>>
bool walberla::field::StabilityChecker< Field_T, Filter_T, CheckFunction_T >::outputToStream_
private

◆ outputVTK_

template<typename Field_T , typename Filter_T = DefaultEvaluationFilter, typename CheckFunction_T = std::function<bool ( const typename Field_T::value_type & value )>>
bool walberla::field::StabilityChecker< Field_T, Filter_T, CheckFunction_T >::outputVTK_
private

◆ requiredSelectors_

template<typename Field_T , typename Filter_T = DefaultEvaluationFilter, typename CheckFunction_T = std::function<bool ( const typename Field_T::value_type & value )>>
Set<SUID> walberla::field::StabilityChecker< Field_T, Filter_T, CheckFunction_T >::requiredSelectors_
private

◆ vtkBaseFolder_

template<typename Field_T , typename Filter_T = DefaultEvaluationFilter, typename CheckFunction_T = std::function<bool ( const typename Field_T::value_type & value )>>
std::string walberla::field::StabilityChecker< Field_T, Filter_T, CheckFunction_T >::vtkBaseFolder_ {internal::stabilityCheckerVTKBase}
private

◆ vtkBinary_

template<typename Field_T , typename Filter_T = DefaultEvaluationFilter, typename CheckFunction_T = std::function<bool ( const typename Field_T::value_type & value )>>
bool walberla::field::StabilityChecker< Field_T, Filter_T, CheckFunction_T >::vtkBinary_ {internal::stabilityCheckerVTKBinary}
private

◆ vtkExecutionFolder_

template<typename Field_T , typename Filter_T = DefaultEvaluationFilter, typename CheckFunction_T = std::function<bool ( const typename Field_T::value_type & value )>>
std::string walberla::field::StabilityChecker< Field_T, Filter_T, CheckFunction_T >::vtkExecutionFolder_ {internal::stabilityCheckerVTKFolder}
private

◆ vtkForcePVTU_

template<typename Field_T , typename Filter_T = DefaultEvaluationFilter, typename CheckFunction_T = std::function<bool ( const typename Field_T::value_type & value )>>
bool walberla::field::StabilityChecker< Field_T, Filter_T, CheckFunction_T >::vtkForcePVTU_ {internal::stabilityCheckerVTKForcePVTU}
private

◆ vtkIdentifier_

template<typename Field_T , typename Filter_T = DefaultEvaluationFilter, typename CheckFunction_T = std::function<bool ( const typename Field_T::value_type & value )>>
std::string walberla::field::StabilityChecker< Field_T, Filter_T, CheckFunction_T >::vtkIdentifier_ {internal::stabilityCheckerVTKIdentifier}
private

◆ vtkLittleEndian_

template<typename Field_T , typename Filter_T = DefaultEvaluationFilter, typename CheckFunction_T = std::function<bool ( const typename Field_T::value_type & value )>>
bool walberla::field::StabilityChecker< Field_T, Filter_T, CheckFunction_T >::vtkLittleEndian_ {internal::stabilityCheckerVTKLittleEndian}
private

◆ vtkMPIIO_

template<typename Field_T , typename Filter_T = DefaultEvaluationFilter, typename CheckFunction_T = std::function<bool ( const typename Field_T::value_type & value )>>
bool walberla::field::StabilityChecker< Field_T, Filter_T, CheckFunction_T >::vtkMPIIO_ {internal::stabilityCheckerVTKMPIIO}
private

The documentation for this class was generated from the following file:
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'.
Definition: StabilityChecker.h:262