use crate::py::element_field::PyElementField;
use crate::py::matrix::PyMatrix;
use crate::py::model::PyModel;
use pyo3::prelude::*;
use pyrucast_macros::py_op;
#[py_op(method_on = PyModel, name = "stiffness_matrix")]
#[cfg_attr(feature = "stub-gen", pyo3_stub_gen::derive::gen_stub_pyfunction)]
#[pyfunction]
pub fn stiffness(model: PyRef<PyModel>, materials: PyRef<PyElementField>) -> PyResult<PyMatrix> {
let k = crate::ops::matrix::stiffness(&model.inner, &materials.inner)?;
Ok(PyMatrix { inner: k })
}
#[py_op(method_on = PyModel, name = "mass_matrix")]
#[cfg_attr(feature = "stub-gen", pyo3_stub_gen::derive::gen_stub_pyfunction)]
#[pyfunction]
pub fn mass(model: PyRef<PyModel>, materials: PyRef<PyElementField>) -> PyResult<PyMatrix> {
let m = crate::ops::matrix::mass(&model.inner, &materials.inner)?;
Ok(PyMatrix { inner: m })
}
#[py_op(method_on = PyMatrix)]
#[cfg_attr(feature = "stub-gen", pyo3_stub_gen::derive::gen_stub_pyfunction)]
#[pyfunction]
pub fn lump(matrix: PyRef<PyMatrix>) -> PyResult<PyMatrix> {
let m = crate::ops::matrix::lump(&matrix.inner)?;
Ok(PyMatrix { inner: m })
}
#[py_op(method_on = PyModel, name = "geometric_matrix")]
#[cfg_attr(feature = "stub-gen", pyo3_stub_gen::derive::gen_stub_pyfunction)]
#[pyfunction]
pub fn geometric(
model: PyRef<PyModel>,
materials: PyRef<PyElementField>,
stress: PyRef<PyElementField>,
) -> PyResult<PyMatrix> {
let m = crate::ops::matrix::geometric(&model.inner, &materials.inner, &stress.inner)?;
Ok(PyMatrix { inner: m })
}
#[py_op(method_on = PyModel, name = "tangent_matrix")]
#[cfg_attr(feature = "stub-gen", pyo3_stub_gen::derive::gen_stub_pyfunction)]
#[pyfunction]
#[pyo3(signature = (model, materials, deformation, prev, dt=None))]
pub fn tangent(
model: PyRef<PyModel>,
materials: PyRef<PyElementField>,
deformation: PyRef<PyElementField>,
prev: PyRef<PyElementField>,
dt: Option<f64>,
) -> PyResult<PyMatrix> {
let m = crate::ops::matrix::tangent(
&model.inner,
&materials.inner,
&deformation.inner,
&prev.inner,
dt,
)?;
Ok(PyMatrix { inner: m })
}