DNDSR 0.1.0.dev1+gcd065ad
Distributed Numeric Data Structure for CFV
Loading...
Searching...
No Matches
EulerP_BC_bind.hpp
Go to the documentation of this file.
1/**
2 * @file EulerP_BC_bind.hpp
3 * @brief Pybind11 bindings for the EulerP boundary condition types and handlers.
4 *
5 * Exposes the following Python API under the EulerP module:
6 * - @c BCType: Enum with all boundary condition types (Wall, Far, Sym, etc.)
7 * - @c BCInput: JSON-serializable BC input specification with name, type, value properties
8 * and to_dict/from_dict methods
9 * - @c BC: Single boundary condition with id, type, values properties
10 * - @c BCHandler: BC manager constructed from (bc_inputs, name2id) with id2bc lookup
11 */
12#pragma once
13
14#include "DNDS/Defines_bind.hpp"
15#include "EulerP_BC.hpp"
16
17#include <pybind11_json/pybind11_json.hpp>
18#include <pybind11/stl.h>
19
20namespace DNDS::EulerP
21{
22 /**
23 * @brief Registers the BCType enum as a Python enum class.
24 *
25 * Exposes all BCType values: Wall, WallInvis, WallIsothermal, Far, Sym,
26 * In, InPsTs, Out, OutP, Special, Unknown.
27 *
28 * @param m Pybind11 module to register the enum into.
29 */
30 inline void pybind11_BCType_define(py::module_ &m)
31 {
32#define DNDS_PY_ENUM_CLASS_BCType_ADD(v) value(#v, BCType::v)
33
34 py::enum_<BCType>(m, "BCType")
35 .DNDS_PY_ENUM_CLASS_BCType_ADD(Wall)
36 .DNDS_PY_ENUM_CLASS_BCType_ADD(WallInvis)
37 .DNDS_PY_ENUM_CLASS_BCType_ADD(WallIsothermal)
38 .DNDS_PY_ENUM_CLASS_BCType_ADD(Far)
39 .DNDS_PY_ENUM_CLASS_BCType_ADD(Sym)
40 .DNDS_PY_ENUM_CLASS_BCType_ADD(In)
41 .DNDS_PY_ENUM_CLASS_BCType_ADD(InPsTs)
42 .DNDS_PY_ENUM_CLASS_BCType_ADD(Out)
43 .DNDS_PY_ENUM_CLASS_BCType_ADD(OutP)
44 .DNDS_PY_ENUM_CLASS_BCType_ADD(Special)
45 .DNDS_PY_ENUM_CLASS_BCType_ADD(Unknown);
46#undef DNDS_PY_ENUM_CLASS_BCType_ADD
47 }
48
49 /**
50 * @brief Registers pybind11 bindings for the BCInput struct.
51 *
52 * Exposes BCInput with:
53 * - Default constructor
54 * - @c to_dict() / @c from_dict() for JSON round-trip
55 * - @c name, @c type, @c value as read/write properties
56 *
57 * @param m Pybind11 module to register bindings into.
58 */
59 inline void pybind11_BCInput_define(py::module_ &m)
60 {
61 using T = BCInput;
62 auto T_ = py_class_ssp<T>(
63 m, "BCInput");
64
65 T_.def(py::init());
66
67 T_
68 .def("to_dict",
69 [](T &self)
70 {
71 return py::dict(nlohmann::json(self));
72 })
73 .def_static("from_dict",
74 [](const py::dict &d)
75 {
76 return T(nlohmann::json(d));
77 });
78
79 T_
80 .def_readwrite("name", &T::name)
81 .def_readwrite("type", &T::type)
82 .def_readwrite("value", &T::value);
83 }
84
85 /**
86 * @brief Registers pybind11 bindings for the BC class.
87 *
88 * Exposes BC with:
89 * - Default constructor
90 * - @c id (read/write property via getId/setId)
91 * - @c type (read/write property via getType/setType)
92 * - @c values (read/write property via getValues/setValues)
93 *
94 * @param m Pybind11 module to register bindings into.
95 */
96 inline void pybind11_BC_define(py::module_ &m)
97 {
98 using T = BC;
99 auto T_ = py_class_ssp<T>(
100 m, "BC");
101
102 T_
103 .def(py::init());
104 T_
105 .def_property("id", &T::getId, &T::setId)
106 .def_property("type", &T::getType, &T::setType)
107 .def_property("values", &T::getValues, &T::setValues);
108 }
109
110 /**
111 * @brief Registers pybind11 bindings for the BCHandler class.
112 *
113 * Exposes BCHandler with:
114 * - Constructor taking (bc_inputs: list[BCInput], name2id: AutoAppendName2ID)
115 * - @c id2bc(id) method for BC lookup by zone ID
116 *
117 * @param m Pybind11 module to register bindings into.
118 */
119 inline void pybind11_BCHandler_define(py::module_ &m)
120 {
121 using T = BCHandler;
122 auto T_ = py_class_ssp<T>(
123 m, "BCHandler");
124
125 T_.def(py::init([](const std::vector<BCInput> &bc_inputs, Geom::AutoAppendName2ID &name2id)
126 { return BCHandler(bc_inputs, name2id); }));
127
128 T_
129 .def("id2bc", &T::id2bc);
130 }
131
132 /**
133 * @brief Top-level binding function for all EulerP boundary condition Python API.
134 *
135 * Calls pybind11_BCType_define, pybind11_BCInput_define, pybind11_BC_define,
136 * and pybind11_BCHandler_define to register the complete BC Python interface.
137 *
138 * @param m Pybind11 module to register bindings into.
139 */
140 inline void pybind11_BC_bind(py::module_ &m)
141 {
146 }
147}
Shared pybind11 plumbing used by every *_bind.hpp in DNDS (buffer-protocol type check,...
Boundary condition types, implementations, and handler for the EulerP module.
Host-side boundary condition handler managing all BC objects for a simulation.
Host-side boundary condition object managing parameter values and device transfer.
Namespace for the EulerP alternative evaluator module with GPU support.
Definition EulerP.hpp:29
void pybind11_BCInput_define(py::module_ &m)
Registers pybind11 bindings for the BCInput struct.
void pybind11_BCType_define(py::module_ &m)
Registers the BCType enum as a Python enum class.
@ InPsTs
Inflow with specified stagnation pressure and temperature.
@ Sym
Symmetry plane BC.
@ WallInvis
Inviscid (slip) wall BC.
@ WallIsothermal
No-slip viscous wall with fixed temperature.
@ Out
Supersonic/subsonic outflow BC.
@ Unknown
Uninitialized or unrecognized BC type.
@ Wall
No-slip viscous wall (adiabatic).
@ Special
Special-purpose BC for benchmark cases (e.g., DMR, Riemann).
@ Far
Farfield BC (characteristic-based).
@ In
Supersonic/subsonic inflow BC.
@ OutP
Outflow with specified back-pressure.
void pybind11_BC_define(py::module_ &m)
Registers pybind11 bindings for the BC class.
void pybind11_BC_bind(py::module_ &m)
Top-level binding function for all EulerP boundary condition Python API.
void pybind11_BCHandler_define(py::module_ &m)
Registers pybind11 bindings for the BCHandler class.
py::classh< T > py_class_ssp
Simple struct for JSON-deserialized boundary condition input specification.