diff --git a/dumux/python/io/vtkoutputmodule.hh b/dumux/python/io/vtkoutputmodule.hh index dca4d0785367e148035ebc13ee7adce6d2fa86ab..319146c5519356306eceeeca344fdbfbb90b816f 100644 --- a/dumux/python/io/vtkoutputmodule.hh +++ b/dumux/python/io/vtkoutputmodule.hh @@ -30,6 +30,7 @@ #include <dune/python/pybind11/stl.h> #include <dumux/python/common/volumevariables.hh> +#include <dumux/io/velocityoutput.hh> namespace Dumux::Python { @@ -63,6 +64,13 @@ void registerVtkOutputModule(pybind11::handle scope, const std::string& name) { self.addVolumeVariable(std::move(f), name); }); + + using VelocityOutputType = Dumux::VelocityOutput<GridVariables>; + cls.def("addVelocityOutput", [](VtkOutputModule& self, + std::shared_ptr<VelocityOutputType> velocityOutput) + { + self.addVelocityOutput(velocityOutput); + }); }; diff --git a/dumux/python/porousmediumflow/velocityoutput.hh b/dumux/python/porousmediumflow/velocityoutput.hh new file mode 100644 index 0000000000000000000000000000000000000000..1d83ce2fd45e2ca3e4eebc2454bffa4ad139c552 --- /dev/null +++ b/dumux/python/porousmediumflow/velocityoutput.hh @@ -0,0 +1,48 @@ +// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- +// vi: set et ts=4 sw=4 sts=4: +/**************************************************************************** + * See the file COPYING for full copying permissions. * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see <http://www.gnu.org/licenses/>. * + *****************************************************************************/ +/*! + * \file + * \brief TODO: docme! + */ + +#ifndef DUMUX_PYTHON_POROUSMEDIUMFLOW_VELOCITYOUTPUT_HH +#define DUMUX_PYTHON_POROUSMEDIUMFLOW_VELOCITYOUTPUT_HH + +#include <dune/python/pybind11/pybind11.h> +#include <dumux/porousmediumflow/velocityoutput.hh> + +namespace Dumux::Python { + +// Python wrapper for the PorousMediumFlowVelocityOutput class +template<class GridVariables, class FluxVariables, class... options> +void registerPorousMediumFlowVelocityOutput(pybind11::handle scope, + pybind11::class_<Dumux::PorousMediumFlowVelocityOutput<GridVariables, FluxVariables>, options...> cls) +{ + using pybind11::operator""_a; + using namespace Dune::Python; + using VelocityOutput = Dumux::PorousMediumFlowVelocityOutput<GridVariables, FluxVariables>; + cls.def(pybind11::init([](const GridVariables& gridVariables) + { + return std::make_shared<VelocityOutput>(gridVariables); + })); +} + +} // end namespace Dumux::Python + +#endif diff --git a/python/dumux/porousmediumflow/__init__.py b/python/dumux/porousmediumflow/__init__.py index 9db28887b5d3f542b84e7310aa0dcaa33911b60c..efe82d555b2ef573153134957bcf7b00250ea23f 100644 --- a/python/dumux/porousmediumflow/__init__.py +++ b/python/dumux/porousmediumflow/__init__.py @@ -34,3 +34,24 @@ def PorousMediumFlowProblem(gridGeometry, spatialParams, enableInternalDirichlet return createPorousMediumFlowProblem return PorousMediumFlowProblemDecorator + + +def PorousMediumFlowVelocityOutput(*, gridVariables): + includes = gridVariables._includes + includes += ["dumux/python/porousmediumflow/velocityoutput.hh", "dumux/io/velocityoutput.hh"] + fluxVarsType = ( + f"Dumux::GetPropType<{gridVariables._model.getTypeTag()}, Dumux::Properties::FluxVariables>" + ) + typeName = f"Dumux::PorousMediumFlowVelocityOutput<{gridVariables._typeName}, {fluxVarsType}>" + moduleName = "porousmediumflowvelocityoutput_" + hashIt(typeName) + baseClass = [f"Dumux::VelocityOutput<{gridVariables._typeName}>"] + generator = SimpleGenerator("PorousMediumFlowVelocityOutput", "Dumux::Python") + module = generator.load( + includes, + typeName, + moduleName, + holder="std::shared_ptr", + preamble=gridVariables._model.getProperties(), + baseClasses=baseClass, + ) + return module.PorousMediumFlowVelocityOutput(gridVariables)