Skip to content
Snippets Groups Projects
Unverified Commit 6384b8b9 authored by Simip's avatar Simip Committed by GitHub
Browse files

Update README.md

parent 8de840dc
No related branches found
No related tags found
No related merge requests found
...@@ -9,23 +9,30 @@ a file reader is provided to import VTK files into Dune grid and data objects. ...@@ -9,23 +9,30 @@ a file reader is provided to import VTK files into Dune grid and data objects.
## Usage ## Usage
The VTK writer works similar to the dune-grid `VTKWriter`. It needs to be bound The VTK writer works similar to the dune-grid `VTKWriter`. It needs to be bound
to a GridView and then data can be added to the points or cells in the grid. to a GridView and then data can be added to the points or cells in the grid.
Points are not necessarily grid vertices, but any coordinates places inside the Points are not necessarily grid vertices, but any coordinates placed inside the
grid cells, so the data must be provided as GridViewFunction to allow the local grid cells, so the data must be provided as GridViewFunction to allow the local
evaluation in arbitrary local coordinates. evaluation in arbitrary local coordinates.
General interface of a VtkWriter
```c++ ```c++
Grid grid = ...; template <class GridView>
VtkWriter<typename Grid::LeafGridView> vtkWriter(grid.leafGridView(), Vtk::ASCII); class Vtk[Type]Writer
{
auto fct = makeAnalyticGridViewFunction([](auto const& x) { public:
return std::sin(x[0]); // Constructor
}); Vtk[Type]Writer(GridView, Vtk::FormatTypes = Vtk::BINARY, Vtk::DataTypes = Vtk::FLOAT32);
vtkWriter.addPointData(fct, "u_points"); // Bind data to the writer
vtkWriter.addCellData(fct, "u_cells"); Vtk[Type]Writer& addPointData(Function [, std::string name, int numComponents, Vtk::FormatTypes]);
Vtk[Type]Writer& addCellData(Function [, std::string name, int numComponents, Vtk::FormatTypes]);
vtkWriter.write("filename.vtu");
// Write file with filename
void write(std::string filename);
};
``` ```
where `Function` is either a `GridViewFunction`, i.e. supports `bind()`, `unbind()`, and `localFunction(Function)`, or is a legacy `VTKFunction` from Dune-Grid. The optional parameters `name`, `numComponents` and `format` may be given for a `GridViewFunction`.
The parameter `Vtk::FormatTypes` is one of `Vtk::ASCII`, `Vtk::BINARY`, or `Vtk::COMPRESSED` and `Vtk::DataTypes` is one of `Vtk::FLOAT32`, or `Vtk::FLOAT64`.
See also the `src/` directory for more examples. See also the `src/` directory for more examples.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment