9#include "pybind11/eigen.h"
14 template <
int n_m,
int n_n>
17 return "ArrayDOF" + fmt::format(
"_{}_{}",
22 template <
int n_m,
int n_n>
28 template <
int n_m,
int n_n>
29 tPy_ArrayDOF<n_m, n_n>
33 auto ArrayEigenMatrixPair_ = pybind11_ArrayEigenMatrixPair_get_class<n_m, n_n>(m);
34 return {m, pybind11_ArrayDOF_name<n_m, n_n>().c_str(), ArrayEigenMatrixPair_};
37 template <
int n_m,
int n_n>
38 tPy_ArrayDOF<n_m, n_n>
41 return {m.attr(pybind11_ArrayDOF_name<n_m, n_n>().c_str())};
44 template <
int n_m,
int n_n>
48 using t_element_mat =
typename TArr::t_element_mat;
49 auto Arr_ = pybind11_ArrayDOF_declare<n_m, n_n>(m);
53 {
return std::make_shared<TArr>(); }));
56 .def(
"clone", [](TArr &self)
58 auto new_pair = std::make_shared<TArr>();
59 new_pair->clone(self);
62 .def(
"setConstant", [](TArr &self,
real R)
63 { self.setConstant(R); }, py::arg(
"R"))
64 .def(
"setConstant", [](TArr &self,
const Eigen::Ref<const t_element_mat> &R)
65 { self.setConstant(R); }, py::arg(
"R"));
67 .def(
"__iadd__", [](TArr &self,
const TArr &R)
68 { self += R;
return self; }, py::arg(
"R"))
69 .def(
"__iadd__", [](TArr &self,
real R)
70 { self += R;
return self; }, py::arg(
"R"))
71 .def(
"__iadd__", [](TArr &self,
const Eigen::Ref<const t_element_mat> &R)
72 { self += R;
return self; }, py::arg(
"R"));
73 Arr_.def(
"__isub__", [](TArr &self,
const TArr &R)
74 { self -= R;
return self; }, py::arg(
"R"));
76 .def(
"__imul__", [](TArr &self,
real R)
77 { self *= R;
return self; }, py::arg(
"R"))
78 .def(
"__imul__", [](TArr &self,
const Eigen::Ref<const t_element_mat> &R)
79 { self *= R;
return self; }, py::arg(
"R"))
80 .def(
"__imul__", [](TArr &self,
const TArr &R)
81 { self *= R;
return self; }, py::arg(
"R"));
83 if constexpr (!(n_m == 1 && n_n == 1))
87 { self *= R;
return self; }, py::arg(
"R"));
90 .def(
"__idiv__", [](TArr &self,
const TArr &R)
91 { self /= R;
return self; }, py::arg(
"R"));
94 .def(
"assign_value", [](TArr &self,
const TArr &R)
95 { self = R; }, py::arg(
"R"))
96 .def(
"addTo", [](TArr &self,
const TArr &R,
real alpha)
97 { self.addTo(R,
alpha); }, py::arg(
"R"), py::arg(
"alpha"))
98 .def(
"norm2", [](TArr &self)
99 {
return self.norm2(); })
100 .def(
"norm2", [](TArr &self, TArr &R)
101 {
return self.norm2(R); })
102 .def(
"min", [](TArr &self)
103 {
return self.min(); })
104 .def(
"max", [](TArr &self)
105 {
return self.max(); })
106 .def(
"sum", [](TArr &self)
107 {
return self.sum(); })
108 .def(
"componentWiseNorm1", [](TArr &self)
109 {
return self.componentWiseNorm1(); })
110 .def(
"componentWiseNorm1", [](TArr &self, TArr &R)
111 {
return self.componentWiseNorm1(R); })
112 .def(
"dot", [](TArr &self,
const TArr &R)
113 {
return self.dot(R); }, py::arg(
"R"));
116 template <
int n_m,
int n_n>
123 return pybind11_ArrayDOF_define<n_m, n_n>(m);
129 template <rowsize mat_n,
size_t N, std::array<
int, N> const &Arr,
size_t... Is>
132 (_pybind11_ArrayDOF_define_dispatch<Arr[Is], mat_n>(m), ...);
133 pybind11_ArrayDOF_define<DynamicSize, mat_n>(m);
134 pybind11_ArrayDOF_define<NonUniformSize, mat_n>(m);
137 template <rowsize mat_n>
140 static constexpr auto seq = pybind11_arrayRowsizeInstantiationList;
144 seq>(m, std::make_index_sequence<seq.size()>{});
Degree-of-freedom array with vector-space operations (MPI-collective).
pybind11 bindings for Array / ParArray / ArrayPair.
Primary solver state container: an ArrayEigenMatrix pair with MPI-collective vector-space operations.
the host side operators are provided as implemented
template void pybind11_callBindArrayDOF_rowsizes< 5 >(py::module_ &m)
template void pybind11_callBindArrayDOF_rowsizes< 6 >(py::module_ &m)
void pybind11_callBindArrayDOF_rowsizes(py::module_ &m)
tPy_ArrayDOF< n_m, n_n > pybind11_ArrayDOF_declare(py::module_ &m)
std::string pybind11_ArrayDOF_name()
template void pybind11_callBindArrayDOF_rowsizes< 8 >(py::module_ &m)
py::classh< T > py_class_ssp
void pybind11_bind_ArrayDOF_All(py::module_ &m)
py_class_ssp< ArrayDof< n_m, n_n > > tPy_ArrayDOF
template void pybind11_callBindArrayDOF_rowsizes< 4 >(py::module_ &m)
std::string RowSize_To_PySnippet(rowsize rs)
Encode a rowsize constant as a short Python-binding snippet: "<number>" for fixed,...
void _pybind11_ArrayDOF_define_dispatch(py::module_ &m)
template void pybind11_callBindArrayDOF_rowsizes< 2 >(py::module_ &m)
template void pybind11_callBindArrayDOF_rowsizes< NonUniformSize >(py::module_ &m)
template void pybind11_callBindArrayDOF_rowsizes< 7 >(py::module_ &m)
template void pybind11_callBindArrayDOF_rowsizes< 1 >(py::module_ &m)
double real
Canonical floating-point scalar used throughout DNDSR (double precision).
template void pybind11_callBindArrayDOF_rowsizes< 3 >(py::module_ &m)
tPy_ArrayDOF< n_m, n_n > pybind11_ArrayDOF_get_class(py::module_ &m)
void __pybind11_callBindArrayDOFs_rowsizes_sequence(py::module_ &m, std::index_sequence< Is... >)
void pybind11_ArrayDOF_define(py::module_ &m)
DNDS_CONSTANT const rowsize UnInitRowsize
Sentinel "not initialised" rowsize value (= INT32_MIN).
template void pybind11_callBindArrayDOF_rowsizes< DynamicSize >(py::module_ &m)