From b9ac301bbbebbc38712c1c0a47c07354340a789f Mon Sep 17 00:00:00 2001 From: Henry <henry.korb@geo.uu.se> Date: Tue, 14 Nov 2023 17:12:16 +0100 Subject: [PATCH] add bindings for kernel --- .../pyfluids-stubs/gpu/__init__.pyi | 2 +- .../pyfluids-stubs/gpu/kernel/__init__.pyi | 4 + .../gpu/kernel/compressible.pyi | 17 ++++ .../gpu/kernel/incompressible.pyi | 7 ++ .../gpu/kernel/porous_media.pyi | 1 + .../pyfluids-stubs/gpu/kernel/wale.pyi | 4 + pythonbindings/src/gpu/gpu.cpp | 1 + pythonbindings/src/gpu/submodules/kernel.cpp | 83 +++++++++++++++++++ .../src/gpu/submodules/parameter.cpp | 2 +- 9 files changed, 119 insertions(+), 2 deletions(-) create mode 100644 pythonbindings/pyfluids-stubs/gpu/kernel/__init__.pyi create mode 100644 pythonbindings/pyfluids-stubs/gpu/kernel/compressible.pyi create mode 100644 pythonbindings/pyfluids-stubs/gpu/kernel/incompressible.pyi create mode 100644 pythonbindings/pyfluids-stubs/gpu/kernel/porous_media.pyi create mode 100644 pythonbindings/pyfluids-stubs/gpu/kernel/wale.pyi create mode 100644 pythonbindings/src/gpu/submodules/kernel.cpp diff --git a/pythonbindings/pyfluids-stubs/gpu/__init__.pyi b/pythonbindings/pyfluids-stubs/gpu/__init__.pyi index 15386f7b0..31fe74fb1 100644 --- a/pythonbindings/pyfluids-stubs/gpu/__init__.pyi +++ b/pythonbindings/pyfluids-stubs/gpu/__init__.pyi @@ -42,7 +42,7 @@ import basics, parallel from . import grid_generator as grid_generator from . import probes as probes -from . import Kernel as Kernel +from . import kernel as kernel class PreCollisionInteractor: def __init__(self, *args, **kwargs) -> None: ... diff --git a/pythonbindings/pyfluids-stubs/gpu/kernel/__init__.pyi b/pythonbindings/pyfluids-stubs/gpu/kernel/__init__.pyi new file mode 100644 index 000000000..1298ed96d --- /dev/null +++ b/pythonbindings/pyfluids-stubs/gpu/kernel/__init__.pyi @@ -0,0 +1,4 @@ +from . import compressible as compressible +from . import incompressible as incompressible +from . import porous_media as porous_media +from . import wale as wale \ No newline at end of file diff --git a/pythonbindings/pyfluids-stubs/gpu/kernel/compressible.pyi b/pythonbindings/pyfluids-stubs/gpu/kernel/compressible.pyi new file mode 100644 index 000000000..4b2069fab --- /dev/null +++ b/pythonbindings/pyfluids-stubs/gpu/kernel/compressible.pyi @@ -0,0 +1,17 @@ +BGK: str +BGKUnified: str +BGKPlus: str +MRT: str +Cascade: str +CumulantClassic: str +CumulantK15Unified: str +K17CompressibleNavierStokesUnified: str +K17CompressibleNavierStokes: str +K17CompressibleNavierStokesBulkViscosity: str +K17CompressibleNavierStokesChimeraLegacy: str +CumulantAll4SP27: str +CumulantK18: str +CumulantK20: str +K15CompressibleNavierStokes: str +K15CompressibleNavierStokesBulk: str +K15CompressibleNavierStokesSponge: str \ No newline at end of file diff --git a/pythonbindings/pyfluids-stubs/gpu/kernel/incompressible.pyi b/pythonbindings/pyfluids-stubs/gpu/kernel/incompressible.pyi new file mode 100644 index 000000000..6dd05ff1c --- /dev/null +++ b/pythonbindings/pyfluids-stubs/gpu/kernel/incompressible.pyi @@ -0,0 +1,7 @@ +BGK: str +BGKPlus: str +MRT: str +Cascade: str +Cumulant1h: str +CumulantIsometric: str +CumulantK15: str \ No newline at end of file diff --git a/pythonbindings/pyfluids-stubs/gpu/kernel/porous_media.pyi b/pythonbindings/pyfluids-stubs/gpu/kernel/porous_media.pyi new file mode 100644 index 000000000..8e340b2a9 --- /dev/null +++ b/pythonbindings/pyfluids-stubs/gpu/kernel/porous_media.pyi @@ -0,0 +1 @@ +CumulantOne: str \ No newline at end of file diff --git a/pythonbindings/pyfluids-stubs/gpu/kernel/wale.pyi b/pythonbindings/pyfluids-stubs/gpu/kernel/wale.pyi new file mode 100644 index 000000000..95aca0ca9 --- /dev/null +++ b/pythonbindings/pyfluids-stubs/gpu/kernel/wale.pyi @@ -0,0 +1,4 @@ +CumulantK17: str +CumulantK17Debug: str +CumulantK15: str +CumulantK15SoniMalav: str \ No newline at end of file diff --git a/pythonbindings/src/gpu/gpu.cpp b/pythonbindings/src/gpu/gpu.cpp index dcb4ded4b..012ffd06e 100644 --- a/pythonbindings/src/gpu/gpu.cpp +++ b/pythonbindings/src/gpu/gpu.cpp @@ -62,5 +62,6 @@ PYBIND11_MODULE(gpu, m) grid_provider::makeModule(m); turbulence_model::makeModule(m); grid_scaling_factory::makeModule(m); + kernel::makeModule(m); } } // namespace gpu_bindings diff --git a/pythonbindings/src/gpu/submodules/kernel.cpp b/pythonbindings/src/gpu/submodules/kernel.cpp new file mode 100644 index 000000000..baf1252b7 --- /dev/null +++ b/pythonbindings/src/gpu/submodules/kernel.cpp @@ -0,0 +1,83 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids 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. +// +// VirtualFluids 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 VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file kernel.cpp +//! \ingroup submodules +//! \author Henry Korb +//======================================================================================= +#include <pybind11/pybind11.h> +#include <pybind11/stl.h> +#include <gpu/core/Kernel/Utilities/KernelTypes.h> + +namespace kernel +{ + namespace py = pybind11; + + void makeModule(py::module_ &parentModule) + { + auto kernel_module = parentModule.def_submodule("Kernel", "Kernel types"); + auto compressible = kernel_module.def_submodule("compressible", "Compressible Kernel types"); + auto incompressible = kernel_module.def_submodule("incompressible", "Incompressible Kernel types"); + auto porous_media = kernel_module.def_submodule("porous_media", "Porous Media Kernel types"); + auto wale = kernel_module.def_submodule("wale", "WALE Kernel types"); + + compressible.attr("BGK") = vf::collisionKernel::compressible::BGK; + compressible.attr("BGKUnified") = vf::collisionKernel::compressible::BGKUnified; + compressible.attr("BGKPlus") = vf::collisionKernel::compressible::BGKPlus; + compressible.attr("MRT") = vf::collisionKernel::compressible::MRT; + compressible.attr("Cascade") = vf::collisionKernel::compressible::Cascade; + compressible.attr("CumulantClassic") = vf::collisionKernel::compressible::CumulantClassic; + compressible.attr("CumulantK15Unified") = vf::collisionKernel::compressible::CumulantK15Unified; + compressible.attr("K17CompressibleNavierStokesUnified") = vf::collisionKernel::compressible::K17CompressibleNavierStokesUnified; + compressible.attr("K17CompressibleNavierStokes") = vf::collisionKernel::compressible::K17CompressibleNavierStokes; + compressible.attr("K17CompressibleNavierStokesBulkViscosity") = vf::collisionKernel::compressible::K17CompressibleNavierStokesBulkViscosity; + compressible.attr("K17CompressibleNavierStokesChimeraLegacy") = vf::collisionKernel::compressible::K17CompressibleNavierStokesChimeraLegacy; + compressible.attr("CumulantAll4SP27") = vf::collisionKernel::compressible::CumulantAll4SP27; + compressible.attr("CumulantK18") = vf::collisionKernel::compressible::CumulantK18; + compressible.attr("CumulantK20") = vf::collisionKernel::compressible::CumulantK20; + compressible.attr("K15CompressibleNavierStokes") = vf::collisionKernel::compressible::K15CompressibleNavierStokes; + compressible.attr("K15CompressibleNavierStokesBulk") = vf::collisionKernel::compressible::K15CompressibleNavierStokesBulk; + compressible.attr("K15CompressibleNavierStokesSponge") = vf::collisionKernel::compressible::K15CompressibleNavierStokesSponge; + + incompressible.attr("BGK") = vf::collisionKernel::incompressible::BGK; + incompressible.attr("BGKPlus") = vf::collisionKernel::incompressible::BGKPlus; + incompressible.attr("MRT") = vf::collisionKernel::incompressible::MRT; + incompressible.attr("Cascade") = vf::collisionKernel::incompressible::Cascade; + incompressible.attr("Cumulant1h") = vf::collisionKernel::incompressible::Cumulant1h; + incompressible.attr("CumulantIsometric") = vf::collisionKernel::incompressible::CumulantIsometric; + incompressible.attr("CumulantK15") = vf::collisionKernel::incompressible::CumulantK15; + + porous_media.attr("CumulantOne") = vf::collisionKernel::porousMedia::CumulantOne; + + wale.attr("CumulantK17") = vf::collisionKernel::wale::CumulantK17; + wale.attr("CumulantK17Debug") = vf::collisionKernel::wale::CumulantK17Debug; + wale.attr("CumulantK15") = vf::collisionKernel::wale::CumulantK15; + wale.attr("CumulantK15SoniMalav") = vf::collisionKernel::wale::CumulantK15SoniMalav; + + } +} diff --git a/pythonbindings/src/gpu/submodules/parameter.cpp b/pythonbindings/src/gpu/submodules/parameter.cpp index 6b9d57a71..167ae0a3f 100644 --- a/pythonbindings/src/gpu/submodules/parameter.cpp +++ b/pythonbindings/src/gpu/submodules/parameter.cpp @@ -83,7 +83,7 @@ namespace parameter .def("set_max_dev", &Parameter::setMaxDev, py::arg("max_dev")) .def("set_is_body_force", &Parameter::setIsBodyForce, py::arg("is_body_force")) .def("set_use_streams", &Parameter::setUseStreams, py::arg("use_streams")) - .def("set_main_kernel", &Parameter::configureMainKernel, py::arg("kernel")) + .def("configure_main_kernel", &Parameter::configureMainKernel, py::arg("kernel")) .def("set_AD_kernel", &Parameter::setADKernel, py::arg("ad_kernel")) .def("set_has_wall_model_monitor", &Parameter::setHasWallModelMonitor, py::arg("has_wall_monitor")) .def("set_outflow_pressure_correction_factor", &Parameter::setOutflowPressureCorrectionFactor, py::arg("correction_factor")) -- GitLab