pub struct PyFemAssembly {
pub n_dofs: usize,
/* private fields */
}Expand description
FEM assembly for a truss structure.
Assembles a global stiffness matrix from bar elements, applies boundary conditions, and solves with a direct (dense) solver suitable for demonstration/testing with small meshes.
Fields§
§n_dofs: usizeNumber of degrees of freedom (nodes × 3 for 3-D).
Implementations§
Source§impl PyFemAssembly
impl PyFemAssembly
Sourcepub fn add_bar_element(
&mut self,
node_a: usize,
node_b: usize,
ea: f64,
length: f64,
)
pub fn add_bar_element( &mut self, node_a: usize, node_b: usize, ea: f64, length: f64, )
Add a bar element between two nodes with given EA and undeformed length.
Sourcepub fn apply_force(&mut self, dof: usize, force: f64)
pub fn apply_force(&mut self, dof: usize, force: f64)
Apply an external force to a DOF (node_index * 3 + direction).
Sourcepub fn assemble(&mut self)
pub fn assemble(&mut self)
Assemble the global stiffness matrix from all bar elements.
For each bar element the 2×2 (1-D axial) stiffness matrix contribution
k_e = EA/L * [[1, -1\], [-1, 1]] is added to the corresponding DOF
rows/columns along the element’s axis direction.
Sourcepub fn solve(&mut self) -> bool
pub fn solve(&mut self) -> bool
Solve the linear system K·u = f using Gaussian elimination.
The system is solved in-place. Returns true on success,
false if the matrix is singular or not yet assembled.
Sourcepub fn displacement(&self, dof: usize) -> f64
pub fn displacement(&self, dof: usize) -> f64
Get the displacement at DOF dof, or 0.0 if out of bounds.
Sourcepub fn displacements(&self) -> &[f64]
pub fn displacements(&self) -> &[f64]
Get all displacements as a slice.
Sourcepub fn element_force(&self, elem_idx: usize) -> Option<f64>
pub fn element_force(&self, elem_idx: usize) -> Option<f64>
Compute the axial force in element elem_idx.
Returns None if the index is out of bounds or the system is unsolved.
Trait Implementations§
Source§impl Clone for PyFemAssembly
impl Clone for PyFemAssembly
Source§fn clone(&self) -> PyFemAssembly
fn clone(&self) -> PyFemAssembly
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for PyFemAssembly
impl RefUnwindSafe for PyFemAssembly
impl Send for PyFemAssembly
impl Sync for PyFemAssembly
impl Unpin for PyFemAssembly
impl UnsafeUnpin for PyFemAssembly
impl UnwindSafe for PyFemAssembly
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.