DNDSR 0.1.0.dev1+gcd065ad
Distributed Numeric Data Structure for CFV
Loading...
Searching...
No Matches
EulerP_Evaluator_bind.hpp
Go to the documentation of this file.
1/**
2 * @file EulerP_Evaluator_bind.hpp
3 * @brief Pybind11 bindings for the EulerP Evaluator class and its packed argument structs.
4 *
5 * Exposes the following Python API under the EulerP module:
6 * - @c Evaluator: Main evaluator class with constructor, config get/set, device transfer,
7 * VTK output, and all kernel methods (RecGradient, RecFace2nd, Cons2PrimMu, Cons2Prim,
8 * EstEigenDt, Flux2nd).
9 * - For each kernel, a corresponding @c *_Arg packed argument struct is exposed with
10 * all member ArrayDof pointers as read/write properties.
11 */
12#pragma once
13
14#include "DNDS/Defines_bind.hpp"
16#include "DNDS/ObjectUtils.hpp"
17#include "EulerP_Evaluator.hpp"
18#include <pybind11/pytypes.h>
19
20namespace DNDS::EulerP
21{
22 /**
23 * @brief Defines pybind11 bindings for the Evaluator class and its kernel argument structs.
24 *
25 * Registers the Evaluator class with:
26 * - Constructor taking (fv, bcHandler, physics)
27 * - @c setConfig / @c getConfig for JSON configuration round-trip
28 * - @c fv, @c bcHandler, @c physics as read/write properties
29 * - @c to_host, @c to_device, @c device for device management
30 * - @c PrintDataVTKHDF for VTK output
31 * - Kernel methods and their packed argument structs via DNDS_EULERP_EVALUATOR_BIND_STANDARD_PACKED_API
32 *
33 * @param m Pybind11 module to register bindings into.
34 */
35 inline void pybind11_Evaluator_define(py::module_ &m)
36 {
37 using T = Evaluator;
38 auto T_ = py_class_ssp<T>(
39 m, "Evaluator");
40
41 T_.def(py::init<T::t_fv, T::t_bcHandler, T::t_physics>());
42 T_.def("setConfig", [](T &self, const nlohmann::json &c)
43 { self.set_config(c); });
44 T_.def("getConfig", [](T &self) -> nlohmann::json
45 { return self.get_config(); });
46
47 T_
48 .def_readwrite("fv", &T::fv)
49 .def_readwrite("bcHandler", &T::bcHandler)
50 .def_readwrite("physics", &T::physics);
51 T_
52 .def("to_host", &T::to_host);
53 T_
54 .def("to_device", [](T &self, const std::string &B)
55 { self.to_device(device_backend_name_to_enum(B)); });
56 T_
57 .def("device", &T::device);
58
59 T_
60 .def("PrintDataVTKHDF", &T::PrintDataVTKHDF,
61 py::arg("fname"), py::arg("series_name"),
62 py::arg("arrCellCentScalar") = py::list(),
63 py::arg("arrCellCentScalar_names") = py::list(),
64 py::arg("arrCellCentVec") = py::list(),
65 py::arg("arrCellCentVec_names") = py::list(),
66 py::arg("arrNodeScalar") = py::list(),
67 py::arg("arrNodeScalar_names") = py::list(),
68 py::arg("arrNodeVec") = py::list(),
69 py::arg("arrNodeVec_names") = py::list(),
70 py::arg("uPrimCell") = py::none(),
71 py::arg("uPrimNode") = py::none(),
72 py::arg("t") = 0.0);
73
74#define DNDS_EULERP_EVALUATOR_BIND_STANDARD_PACKED_API(func, func_arg) \
75 \
76 { \
77 using TArg = T::func_arg; \
78 auto arg_ = py_class_ssp<TArg>(T_, #func_arg); \
79 arg_.def(py::init()); \
80 for_each_member_ptr_list_raw(TArg::member_list(), [&](auto &mem_ptr) \
81 { arg_.def_readwrite(mem_ptr.name, mem_ptr.ptr); }); \
82 T_.def(#func, &T::func); \
83 }
84 DNDS_EULERP_EVALUATOR_BIND_STANDARD_PACKED_API(RecGradient, RecGradient_Arg)
85 DNDS_EULERP_EVALUATOR_BIND_STANDARD_PACKED_API(RecFace2nd, RecFace2nd_Arg)
86 DNDS_EULERP_EVALUATOR_BIND_STANDARD_PACKED_API(Cons2PrimMu, Cons2PrimMu_Arg)
88 DNDS_EULERP_EVALUATOR_BIND_STANDARD_PACKED_API(EstEigenDt, EstEigenDt_Arg)
90
91 static auto const a = sizeof(T::Flux2nd_Arg);
92
93#undef DNDS_EULERP_EVALUATOR_BIND_STANDARD_PACKED_API
94 }
95
96 /**
97 * @brief Top-level binding function for the EulerP Evaluator Python API.
98 *
99 * Calls @c pybind11_Evaluator_define to register all Evaluator bindings.
100 *
101 * @param m Pybind11 module to register bindings into.
102 */
103 inline void pybind11_Evaluator_bind(py::module_ &m)
104 {
106 }
107}
Shared pybind11 plumbing used by every *_bind.hpp in DNDS (buffer-protocol type check,...
Device memory abstraction layer with backend-specific storage and factory creation.
Main evaluator class for the EulerP compressible Navier-Stokes solver module.
#define DNDS_EULERP_EVALUATOR_BIND_STANDARD_PACKED_API(func, func_arg)
Tiny reflection-style helpers (MemberRef, MemberPtr) and for_each_member_* visitors used by config / ...
Main EulerP evaluator orchestrating CFD kernel dispatch for compressible N-S solvers.
Namespace for the EulerP alternative evaluator module with GPU support.
Definition EulerP.hpp:29
void pybind11_Evaluator_bind(py::module_ &m)
Top-level binding function for the EulerP Evaluator Python API.
void pybind11_Evaluator_define(py::module_ &m)
Defines pybind11 bindings for the Evaluator class and its kernel argument structs.
py::classh< T > py_class_ssp
DeviceBackend device_backend_name_to_enum(std::string_view s)
Inverse of device_backend_name. Returns Unknown for unrecognised names.