Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
pySolverGraph.cpp
Go to the documentation of this file.
1// -------------------------------------------------------//
2//
3// SHAMROCK code for hydrodynamics
4// Copyright (c) 2021-2026 Timothée David--Cléris <tim.shamrock@proton.me>
5// SPDX-License-Identifier: CeCILL Free Software License Agreement v2.1
6// Shamrock is licensed under the CeCILL 2.1 License, see LICENSE for more information
7//
8// -------------------------------------------------------//
9
21#include "shamcomm/logs.hpp"
25#include <pybind11/complex.h>
26#include <pybind11/pybind11.h>
27
28template<class T>
29void register_field(py::module &m, const char *class_name) {
30 using namespace shamrock::solvergraph;
31
32 py::class_<Field<T>, IEdge>(m, class_name)
33 .def(
34 "get_buf",
35 [](Field<T> &self, u64 id_patch) -> sham::DeviceBuffer<T> & {
36 return self.get_buf(id_patch);
37 },
38 py::return_value_policy::reference)
39 .def("__repr__", [=](Field<T> &self) {
40 return shambase::format(
41 "{}(label={}, tex_symbol={}, nvar={})",
42 class_name,
43 self.get_label(),
44 self.get_tex_symbol(),
45 self.get_nvar());
46 });
47}
48
49Register_pymod(shamsolvergraphinit) {
50
51 using namespace shamrock::solvergraph;
52
53 py::class_<IEdge>(m, "IEdge")
54 .def("get_label", &IEdge::get_label)
55 .def("get_tex_symbol", &IEdge::get_tex_symbol);
56
57 register_field<f64>(m, "Field_f64");
58 register_field<f64_3>(m, "Field_f64_3");
59}
Header file describing a Node Instance.
std::uint64_t u64
64 bit unsigned integer
A buffer allocated in USM (Unified Shared Memory)
Pybind11 include and definitions.
#define Register_pymod(placeholdername)
Register a python module init function using static initialisation.