diff --git a/dumux/python/assembly/fvassembler.hh b/dumux/python/assembly/fvassembler.hh index 5359b88e3ad111de06eb40df076009f2de7c0191..1ede28dc7574a7a7f20bfa754c90a5489fa86afe 100644 --- a/dumux/python/assembly/fvassembler.hh +++ b/dumux/python/assembly/fvassembler.hh @@ -59,15 +59,15 @@ void registerFVAssembler(pybind11::handle scope, pybind11::class_<FVAssembler, o cls.def_property_readonly("isStationaryProblem", &FVAssembler::isStationaryProblem); cls.def_property_readonly("gridVariables", [](FVAssembler& self) { return self.gridVariables(); }); - cls.def("updateGridVariables", [](FVAssembler& self, const SolutionVector& curSol) { + cls.def("updateGridVariables", [](FVAssembler& self, const SolutionVector& curSol){ self.updateGridVariables(curSol); }); - cls.def("assembleResidual", [](FVAssembler& self, const SolutionVector& curSol) { + cls.def("assembleResidual", [](FVAssembler& self, const SolutionVector& curSol){ self.assembleResidual(curSol); }); - cls.def("assembleJacobianAndResidual", [](FVAssembler& self, const SolutionVector& curSol) { + cls.def("assembleJacobianAndResidual", [](FVAssembler& self, const SolutionVector& curSol){ self.assembleJacobianAndResidual(curSol); }); } diff --git a/dumux/python/common/parameters.hh b/dumux/python/common/parameters.hh index d02aceaa21cc0b14613861c286bb2c0197d7802a..d743c69727fbf6f01c60f3f0d3df48c7f2db4675 100644 --- a/dumux/python/common/parameters.hh +++ b/dumux/python/common/parameters.hh @@ -35,10 +35,10 @@ template <class... options> void registerParameters(pybind11::handle scope, pybind11::class_<Parameters, options...> cls) { - auto setParams = [](const std::unordered_map<std::string, std::string>& params) - { - return [&](Dune::ParameterTree& tree) - { + using pybind11::operator""_a; + + auto setParams = [](const std::unordered_map<std::string, std::string>& params){ + return [&](Dune::ParameterTree& tree){ for (const auto& p : params) tree[p.first] = p.second; }; @@ -46,22 +46,21 @@ void registerParameters(pybind11::handle scope, cls.def(pybind11::init([setParams](const std::string& parameterFileName, const std::unordered_map<std::string, std::string>& params, - bool inputFileOverwritesParams) - { - auto p = new Parameters(); - p->init(parameterFileName, setParams(params), inputFileOverwritesParams); - return p; - }), - pybind11::arg("parameterFileName"), - pybind11::arg("params") = std::unordered_map<std::string, std::string>{}, - pybind11::arg("inputFileOverwritesParams") = false); + bool inputFileOverwritesParams){ + auto p = new Parameters(); + p->init(parameterFileName, setParams(params), inputFileOverwritesParams); + return p; + }) + , "parameterFileName"_a + , "params"_a = std::unordered_map<std::string, std::string>{} + , "inputFileOverwritesParams"_a = false + ); - cls.def(pybind11::init([setParams](const std::unordered_map<std::string, std::string>& params) - { - auto p = new Parameters(); - p->init(setParams(params)); - return p; - })); + cls.def(pybind11::init([setParams](const std::unordered_map<std::string, std::string>& params){ + auto p = new Parameters(); + p->init(setParams(params)); + return p; + })); } template<class Scalar> diff --git a/dumux/python/discretization/gridgeometry.hh b/dumux/python/discretization/gridgeometry.hh index 6b523fa6ec40d53806b46fdf9dcf5985da1a41b1..f153f9caa3a5e5c07ac8f584ece68f86ec9fb588 100644 --- a/dumux/python/discretization/gridgeometry.hh +++ b/dumux/python/discretization/gridgeometry.hh @@ -147,7 +147,9 @@ void registerGridGeometry(pybind11::handle scope, pybind11::class_<GG, Options.. return toString(GG::discMethod); }); - cls.def_property_readonly("localView", [](GG& self){ return localView(self); }); + cls.def_property_readonly("localView", [](GG& self){ + return localView(self); + }); using SubControlVolume = typename GG::SubControlVolume; Impl::registerSubControlVolume<SubControlVolume>(scope); diff --git a/dumux/python/discretization/gridvariables.hh b/dumux/python/discretization/gridvariables.hh index 29730152886f3502d7e2fb3be56fea0e58e585b1..f2edf6039a6f2406da4b8f2f9cc85f5a9a31cfa1 100644 --- a/dumux/python/discretization/gridvariables.hh +++ b/dumux/python/discretization/gridvariables.hh @@ -49,13 +49,11 @@ void registerElementSolution(pybind11::handle scope) { using pybind11::operator""_a; - cls.def("__getitem__", - [](const ElementSolution& self, std::size_t i) - { - if (i >= self.size()) - throw pybind11::index_error(); - return self[i]; - }); + cls.def("__getitem__", [](const ElementSolution& self, std::size_t i){ + if (i >= self.size()) + throw pybind11::index_error(); + return self[i]; + }); cls.def_property_readonly("size", &ElementSolution::size); } @@ -88,18 +86,17 @@ void registerGridVariables(pybind11::handle scope, pybind11::class_<GV, Options. cls.def_property_readonly("prevGridVolVars", [](GV& self) { return self.prevGridVolVars(); }); cls.def_property_readonly("gridGeometry", &GV::gridGeometry); - cls.def("updateAfterGridAdaption", [](GV& self, const SolutionVector& sol) - { return self.updateAfterGridAdaption(sol); } - ); + cls.def("updateAfterGridAdaption", [](GV& self, const SolutionVector& sol){ + return self.updateAfterGridAdaption(sol); + }); - cls.def("resetTimeStep", [](GV& self, const SolutionVector& sol) - { return self.resetTimeStep(sol); } - ); + cls.def("resetTimeStep", [](GV& self, const SolutionVector& sol){ + return self.resetTimeStep(sol); + }); - cls.def("update", [](GV& self, const SolutionVector& sol, - const bool forceFluxCacheUpdate = false) - { return self.update(sol, forceFluxCacheUpdate); } - ); + cls.def("update", [](GV& self, const SolutionVector& sol, const bool forceFluxCacheUpdate = false){ + return self.update(sol, forceFluxCacheUpdate); + }); using ElementSolution = std::decay_t<decltype(elementSolution(std::declval<Element>(), std::declval<SolutionVector>(), diff --git a/dumux/python/io/vtkoutputmodule.hh b/dumux/python/io/vtkoutputmodule.hh index 319146c5519356306eceeeca344fdbfbb90b816f..7272fc4e5ad88ce276190f83d4ab38ae1ab01f20 100644 --- a/dumux/python/io/vtkoutputmodule.hh +++ b/dumux/python/io/vtkoutputmodule.hh @@ -53,22 +53,22 @@ void registerVtkOutputModule(pybind11::handle scope, using Scalar = double; - cls.def("addField", [](VtkOutputModule& self, const SolutionVector& sol, const std::string& name) - { self.addField(sol, name); } - ); + cls.def("addField", [](VtkOutputModule& self, const SolutionVector& sol, const std::string& name){ + self.addField(sol, name); + }); - cls.def("write", [](VtkOutputModule& self, Scalar time){ self.write(time); }); + cls.def("write", [](VtkOutputModule& self, Scalar time){ + self.write(time); + }); cls.def("addVolumeVariable", [](VtkOutputModule& self, std::function<Scalar(const VolumeVariables&)>&& f, - const std::string& name) { + 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) - { + 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 index 1d83ce2fd45e2ca3e4eebc2454bffa4ad139c552..1b53c62d7c608bc7526b1561760ffb8b4285eca1 100644 --- a/dumux/python/porousmediumflow/velocityoutput.hh +++ b/dumux/python/porousmediumflow/velocityoutput.hh @@ -37,8 +37,8 @@ void registerPorousMediumFlowVelocityOutput(pybind11::handle scope, using pybind11::operator""_a; using namespace Dune::Python; using VelocityOutput = Dumux::PorousMediumFlowVelocityOutput<GridVariables, FluxVariables>; - cls.def(pybind11::init([](const GridVariables& gridVariables) - { + + cls.def(pybind11::init([](const GridVariables& gridVariables){ return std::make_shared<VelocityOutput>(gridVariables); })); }