SERiF 0.0.1a
3+1D Stellar Structure and Evolution
Loading...
Searching...
No Matches
PyMatrix.cpp
Go to the documentation of this file.
2#include "mfem.hpp"
3
4namespace serif::pybind {
5
6 // --- Trampolines for new mfem::Matrix pure virtual methods ---
7
8 mfem::real_t& PyMatrix::Elem(int i, int j) {
9 PYBIND11_OVERRIDE_PURE(
10 mfem::real_t&, /* Return type */
11 mfem::Matrix, /* C++ base class */
12 Elem, /* C++ function name */
13 i, /* Argument 1 */
14 j /* Argument 2 */
15 );
16 }
17
18 const mfem::real_t& PyMatrix::Elem(int i, int j) const {
19 PYBIND11_OVERRIDE_PURE(
20 const mfem::real_t&,
21 mfem::Matrix,
22 Elem,
23 i,
24 j
25 );
26 }
27
28 mfem::MatrixInverse* PyMatrix::Inverse() const {
29 PYBIND11_OVERRIDE_PURE(
30 mfem::MatrixInverse*,
31 mfem::Matrix,
33 );
34 }
35
36 // --- Trampoline for new mfem::Matrix regular virtual methods ---
37
38 void PyMatrix::Finalize(int skip_zeros) {
39 PYBIND11_OVERRIDE(
40 void,
41 mfem::Matrix,
43 skip_zeros
44 );
45 }
46
47 // --- Trampolines for inherited mfem::Operator virtual methods ---
48
49 void PyMatrix::Mult(const mfem::Vector &x, mfem::Vector &y) const {
50 // This remains PURE as mfem::Matrix does not implement it.
51 PYBIND11_OVERRIDE_PURE(
52 void,
53 mfem::Matrix,
54 Mult,
55 x,
56 y
57 );
58 }
59
60 void PyMatrix::MultTranspose(const mfem::Vector &x, mfem::Vector &y) const {
61 PYBIND11_OVERRIDE(
62 void,
63 mfem::Matrix,
65 x,
66 y
67 );
68 }
69
70 void PyMatrix::AddMult(const mfem::Vector &x, mfem::Vector &y, const mfem::real_t a) const {
71 PYBIND11_OVERRIDE(
72 void,
73 mfem::Matrix,
74 AddMult,
75 x,
76 y,
77 a
78 );
79 }
80
81 void PyMatrix::AddMultTranspose(const mfem::Vector &x, mfem::Vector &y, const mfem::real_t a) const {
82 PYBIND11_OVERRIDE(
83 void,
84 mfem::Matrix,
86 x,
87 y,
88 a
89 );
90 }
91
92 mfem::Operator& PyMatrix::GetGradient(const mfem::Vector &x) const {
93 PYBIND11_OVERRIDE(
94 mfem::Operator&,
95 mfem::Matrix,
97 x
98 );
99 }
100
101 void PyMatrix::AssembleDiagonal(mfem::Vector &diag) const {
102 PYBIND11_OVERRIDE(
103 void,
104 mfem::Matrix,
106 diag
107 );
108 }
109
110 const mfem::Operator* PyMatrix::GetProlongation() const {
111 PYBIND11_OVERRIDE(
112 const mfem::Operator*,
113 mfem::Matrix,
115 );
116 }
117
118 const mfem::Operator* PyMatrix::GetRestriction() const {
119 PYBIND11_OVERRIDE(
120 const mfem::Operator*,
121 mfem::Matrix,
123 );
124 }
125
126 void PyMatrix::RecoverFEMSolution(const mfem::Vector &X, const mfem::Vector &b, mfem::Vector &x) {
127 PYBIND11_OVERRIDE(
128 void,
129 mfem::Matrix,
131 X,
132 b,
133 x
134 );
135 }
136
137} // namespace serif::pybind
Defines a pybind11 trampoline class for mfem::Matrix.
mfem::MatrixInverse * Inverse() const override
Get the inverse of the matrix. Pure virtual in mfem::Matrix. Must be overridden in Python....
Definition PyMatrix.cpp:28
void RecoverFEMSolution(const mfem::Vector &X, const mfem::Vector &b, mfem::Vector &x) override
Recover the FEM solution. Inherited from mfem::Operator. Can be overridden in Python.
Definition PyMatrix.cpp:126
void Finalize(int skip_zeros) override
Finalize matrix assembly. For sparse matrices, this typically involves finalizing the sparse structur...
Definition PyMatrix.cpp:38
void MultTranspose(const mfem::Vector &x, mfem::Vector &y) const override
Perform the transpose operator action: y = A^T*x. Inherited from mfem::Operator. Can be overridden in...
Definition PyMatrix.cpp:60
void AddMult(const mfem::Vector &x, mfem::Vector &y, const mfem::real_t a=1.0) const override
Perform the action y += a*(A*x). Inherited from mfem::Operator. Can be overridden in Python.
Definition PyMatrix.cpp:70
const mfem::Operator * GetProlongation() const override
Get the prolongation operator. Inherited from mfem::Operator. Can be overridden in Python.
Definition PyMatrix.cpp:110
const mfem::Operator * GetRestriction() const override
Get the restriction operator. Inherited from mfem::Operator. Can be overridden in Python.
Definition PyMatrix.cpp:118
void Mult(const mfem::Vector &x, mfem::Vector &y) const override
Perform the operator action: y = A*x. Inherited from mfem::Operator. Can be overridden in Python....
Definition PyMatrix.cpp:49
void AssembleDiagonal(mfem::Vector &diag) const override
Assemble the diagonal of the operator. Inherited from mfem::Operator. Can be overridden in Python.
Definition PyMatrix.cpp:101
mfem::real_t & Elem(int i, int j) override
Access element (i,j) for read/write. Pure virtual in mfem::Matrix. Must be overridden in Python.
Definition PyMatrix.cpp:8
void AddMultTranspose(const mfem::Vector &x, mfem::Vector &y, const mfem::real_t a=1.0) const override
Perform the action y += a*(A^T*x). Inherited from mfem::Operator. Can be overridden in Python.
Definition PyMatrix.cpp:81
mfem::Operator & GetGradient(const mfem::Vector &x) const override
Get the gradient operator (Jacobian) at a given point x. Inherited from mfem::Operator....
Definition PyMatrix.cpp:92
Contains pybind11 helper classes and trampoline classes for interfacing C++ with Python.