Skip to content

Make the Vtk::Function overloads more robust and set better default values

Simon Praetorius requested to merge issue/function_overloads into master

Summary

When constructing a Vtk::Function wrapper (that is used in the VtkWriter to store PointData and CellData functions) the user can pass either a GridFunction or directly a LocalFunction. Additionally, various parameters to control the behavior of the function wrapper can be passed:

  • A name to give a (unique) identifier in the file [mandatory]
  • Number of components in the range or a vector of components
  • A data type, either Vtk::DataTypes::FLOAT32 or Vtk::DataTypes::FLOAT64 to specify the output precision
  • A range type, either Vtk::SCALAR, Vtk::VECTOR, or Vtk::TENSOR to specify the range categroy

The parameters for dataType and rangeType can be passed multiple times. The first one found in the parameter list is used. This allows to specify some defaults in writer.addPointData() and writer.addCellData()

Default values

When constructing a Vtk::Function directly, the default data-type is Vtk::DataTypes::FLOAT64 and default range-type is Vtk::RangeTypes::UNSPECIFIED.

When passing a grid-function or local-function to addPointData() or addCellData a new Vtk::Function is constructed. The default data-type then is the data-type used for the whole file (passed to the constructor of VtkWriter). The default range-type is Vtk::RangeTypes::AUTO. This means that the category is determined automatically by the number of components N, i.e.

if N > 9:
  Vtk::RangeTypes::UNSPECIFIED
else if N > 3:
  Vtk::RangeTypes::TENSOR
else if N > 1:
  Vtk::RangeTypes::VECTOR
else
  Vtk::RangeTypes::SCALAR

Where UNSPECIFIED means no specific category and the components are neither padded by 0 nor restricted. VECTOR and TENSOR categories mean padding of the components with 0.0 up to 3 components (VECTOR) or 9 components (TENSOR), where for a matrix-valued grid-function the rows and columns are padded with zeros up to 3 rows/columns.

Edited by Simon Praetorius

Merge request reports