KASKADE 7 development version
Classes | Public Types | Public Member Functions | List of all members
Kaskade::VTKReader Class Reference

A class to create a grid and load coefficients from a VTK file. More...

#include <vtkreader.hh>

Detailed Description

A class to create a grid and load coefficients from a VTK file.

A low-level interface to load VTK files. VTKReader will create a grid for you. From this grid you need to construct an appropriate space and variables yourself. Then you can copy the data from the VTK file into your variables. Example:

VTKReader vtk("myfile.vtu");
GridManager<Grid> gm(vtk.createGrid<Grid>());
// create varSet
vtk.getCoefficients(varSet);
A class to create a grid and load coefficients from a VTK file.
Definition: vtkreader.hh:94

Currently supported: 2D and 3D simplical grids, Orders 0, 1, 2, continuous and discontinuous data. DataArrays must be in ascii or binary format.

Definition at line 93 of file vtkreader.hh.

Classes

struct  FunctionInfo
 Information about a data set loaded from a file. More...
 

Public Types

enum  Flags {
  noInterpolation = 0 , allowOrderMismatch = 0x1 , allowContinuityMismatch = 0x2 , allowCoefficientDimensionMismatch = 0x4 ,
  allowEverything = allowOrderMismatch | allowContinuityMismatch | allowCoefficientDimensionMismatch
}
 Options for getCoefficients(). More...
 

Public Member Functions

 VTKReader ()=default
 Default constructor. More...
 
 VTKReader (std::string const &filename)
 Constructor that loads a VTK file. More...
 
void load (std::string const &filename)
 Loads a VTK file. More...
 
void loadOnlyData (std::string const &filename)
 Loads only coefficient data, omitting the grid. This can be used for time series. More...
 
template<class Grid >
std::unique_ptr< Grid > createGrid ()
 Create a grid from a previously loaded VTK file. More...
 
template<class Grid , class Deformation >
std::unique_ptr< Grid > createGrid (Deformation const &deformation)
 
template<class VariableSet >
void getCoefficients (VariableSet &varSet, int interpolationFlags=noInterpolation) const
 Copy the data from the current VTK file into the coefficients of your FEFunctions. More...
 
template<class FSE >
void getCoefficients (std::string const &functionName, FSE &fse, int interpolationFlags=noInterpolation) const
 Copy to the coefficients of a single FSE. More...
 
File contents information
std::vector< std::string > functionNames () const
 Lists the functions stored in the file by their name. More...
 
FunctionInfo getFunctionInfo (std::string const &functionName) const
 Information about the expected type of function. Meet these criteria to copy values into your variable without interpolation. More...
 

Member Enumeration Documentation

◆ Flags

Options for getCoefficients().

Enumerator
noInterpolation 
allowOrderMismatch 
allowContinuityMismatch 
allowCoefficientDimensionMismatch 
allowEverything 

Definition at line 99 of file vtkreader.hh.

Constructor & Destructor Documentation

◆ VTKReader() [1/2]

Kaskade::VTKReader::VTKReader ( )
default

Default constructor.

◆ VTKReader() [2/2]

Kaskade::VTKReader::VTKReader ( std::string const &  filename)

Constructor that loads a VTK file.

Parameters
filenameThe filename including the ending.

Member Function Documentation

◆ createGrid() [1/2]

template<class Grid >
std::unique_ptr< Grid > Kaskade::VTKReader::createGrid

Create a grid from a previously loaded VTK file.

Template Parameters
GridThe type of grid to be created. The grid's dimension must match the dimension of shapes in the file. Note that the right dimension is not necessarily the dimension of points in the VTK file. Only cell types matter: triangles mean 2D, tetrahedrons mean 3D.
Returns
A unique_ptr that can be used to construct a GridManager.

Definition at line 659 of file vtkreader.hh.

◆ createGrid() [2/2]

template<class Grid , class Deformation >
std::unique_ptr< Grid > Kaskade::VTKReader::createGrid ( Deformation const &  deformation)

Definition at line 667 of file vtkreader.hh.

◆ functionNames()

std::vector< std::string > Kaskade::VTKReader::functionNames ( ) const

Lists the functions stored in the file by their name.

◆ getCoefficients() [1/2]

template<class FSE >
void Kaskade::VTKReader::getCoefficients ( std::string const &  functionName,
FSE &  fse,
int  interpolationFlags = noInterpolation 
) const

Copy to the coefficients of a single FSE.

Parameters
functionNameThe name of the data set to be copied (as in the VTK file).

Definition at line 785 of file vtkreader.hh.

◆ getCoefficients() [2/2]

template<class VariableSet >
void Kaskade::VTKReader::getCoefficients ( VariableSet varSet,
int  interpolationFlags = noInterpolation 
) const

Copy the data from the current VTK file into the coefficients of your FEFunctions.

The following heuristics are used to determine if coefficients can be copied:

  • If the data is given as CellData, the function must be discontinuous, order 0.
  • If the data is given as PointData, the type of function depends on the grid:
    • If there are multiple points with the same coordinates, the function must be discontinuous (otherwise continuous).
    • If Cell types are quadratic triangles or quadratic tetrahedrons, order must be 2 (otherwise order 1).

You can circumvent these restrictions by passing

Parameters
interpolationFlags.If you are trying to load a file written by writeVTK(), specify order and set data mode to inferred when saving the file.
varSetA VariableSet to receive the data. Variables are assumed to live on the grid created by createGrid(). This is not checked.

Definition at line 770 of file vtkreader.hh.

◆ getFunctionInfo()

FunctionInfo Kaskade::VTKReader::getFunctionInfo ( std::string const &  functionName) const

Information about the expected type of function. Meet these criteria to copy values into your variable without interpolation.

Parameters
functionNameThe name of the data set as in the VTK file.
Returns
A FunctionInfo object that can be printed by cout.

◆ load()

void Kaskade::VTKReader::load ( std::string const &  filename)

Loads a VTK file.

Parameters
filenameThe filename including the ending.

◆ loadOnlyData()

void Kaskade::VTKReader::loadOnlyData ( std::string const &  filename)

Loads only coefficient data, omitting the grid. This can be used for time series.

Parameters
filenameThe filename including the ending.

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