version 3.8
python/io/vtkoutputmodule.hh
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2// vi: set et ts=4 sw=4 sts=4:
3//
4// SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
12#ifndef DUMUX_PYTHON_IO_VTK_OUTPUTMODULE_HH
13#define DUMUX_PYTHON_IO_VTK_OUTPUTMODULE_HH
14
16
17#include <dune/python/pybind11/pybind11.h>
18#include <dune/python/pybind11/stl.h>
19
22
23namespace Dumux::Python {
24
25template <class GridVariables, class SolutionVector, class... options>
26void registerVtkOutputModule(pybind11::handle scope,
27 pybind11::class_<VtkOutputModule<GridVariables, SolutionVector>, options...> cls)
28{
29 using pybind11::operator""_a;
30
32 using VolumeVariables = typename VtkOutputModule::VolumeVariables;
33 Dumux::Python::Impl::registerVolumeVariables<VolumeVariables>(scope);
34
35
36 cls.def(pybind11::init([](const GridVariables& gridVariables,
37 const SolutionVector& sol,
38 const std::string& name){
39 return new VtkOutputModule(gridVariables, sol, name);
40 }));
41
42 using Scalar = double;
43
44 cls.def("addField", [](VtkOutputModule& self, const SolutionVector& sol, const std::string& name){
45 self.addField(sol, name);
46 });
47
48 cls.def("write", [](VtkOutputModule& self, Scalar time){
49 self.write(time);
50 });
51
52 cls.def("addVolumeVariable", [](VtkOutputModule& self,
53 std::function<Scalar(const VolumeVariables&)>&& f,
54 const std::string& name){
55 self.addVolumeVariable(std::move(f), name);
56 });
57
58 using VelocityOutputType = Dumux::VelocityOutput<GridVariables>;
59 cls.def("addVelocityOutput", [](VtkOutputModule& self, std::shared_ptr<VelocityOutputType> velocityOutput){
60 self.addVelocityOutput(velocityOutput);
61 });
62};
63
64
65template<class GridVariables, class SolutionVector>
66void registerVtkOutputModule(pybind11::handle scope, const char *clsName = "VtkOutputModule")
67{
69 pybind11::class_<VtkOutputModule> cls(scope, clsName);
70 registerVtkOutputModule(scope, cls);
71}
72
73} // namespace Dumux::Python
74
75#endif
Velocity output for implicit (porous media) models.
Definition: io/velocityoutput.hh:29
void write(double time, Dune::VTK::OutputType type=Dune::VTK::ascii)
Definition: io/vtkoutputmodule.hh:165
void addField(const Vector &v, const std::string &name, Vtk::FieldType fieldType=Vtk::FieldType::automatic)
Add a scalar or vector valued vtk field.
Definition: io/vtkoutputmodule.hh:92
A VTK output module to simplify writing dumux simulation data to VTK format.
Definition: io/vtkoutputmodule.hh:300
VV VolumeVariables
export type of the volume variables for the outputfields
Definition: io/vtkoutputmodule.hh:330
void addVolumeVariable(std::function< Scalar(const VolumeVariables &)> &&f, const std::string &name)
Definition: io/vtkoutputmodule.hh:364
void addVelocityOutput(std::shared_ptr< VelocityOutputType > velocityOutput)
Add a velocity output policy.
Definition: io/vtkoutputmodule.hh:358
Default velocity output policy for porous media models.
A VTK output module to simplify writing dumux simulation data to VTK format.
Definition: python/assembly/fvassembler.hh:18
void registerVtkOutputModule(pybind11::handle scope, pybind11::class_< VtkOutputModule< GridVariables, SolutionVector >, options... > cls)
Definition: python/io/vtkoutputmodule.hh:26
Python wrapper for volume variables (finite volume schemes)