Skip to main content

PyFemBinding

Struct PyFemBinding 

Source
pub struct PyFemBinding { /* private fields */ }
Expand description

PyO3-style binding handle for a 2-D FEM solver.

Wraps PyFemSolver and PyFemMesh and exposes helpers suitable for future #[pymethods] annotation.

Implementations§

Source§

impl PyFemBinding

Source

pub fn new() -> Self

Create a new FEM binding with an empty mesh.

Source

pub fn add_node(&mut self, x: f64, y: f64) -> usize

Add a 2-D node at position (x, y). Returns the new node index.

Source

pub fn add_tri_element(&mut self, n0: usize, n1: usize, n2: usize) -> usize

Add a CST triangular element given three node indices.

Returns the new element index.

Source

pub fn add_tri_element_with_material( &mut self, n0: usize, n1: usize, n2: usize, material_id: usize, thickness: f64, ) -> usize

Add a CST triangular element with explicit material and thickness.

Source

pub fn add_material(&mut self, material: PyFemMaterial) -> usize

Add a material to the mesh library. Returns the material index.

Source

pub fn node_count(&self) -> usize

Return the number of nodes.

Source

pub fn element_count(&self) -> usize

Return the number of elements.

Source

pub fn pin_node(&mut self, node: usize)

Pin a node (fix both x and y DOFs to zero).

Source

pub fn add_dirichlet_bc(&mut self, bc: PyFemDirichletBC)

Apply a Dirichlet (fixed DOF) boundary condition.

Source

pub fn apply_nodal_force(&mut self, node: usize, fx: f64, fy: f64)

Apply a nodal force [fx, fy] at node.

Source

pub fn solve(&mut self) -> bool

Solve the linear-elastic static problem.

Returns true on success. Query results via get_displacement_flat.

Source

pub fn get_displacement_flat(&self) -> Vec<f64>

Return nodal displacements as a flat [ux0,uy0, ux1,uy1, …] array, or an empty Vec if no solve has been run.

Source

pub fn get_stress_flat(&self) -> Vec<f64>

Return element von-Mises stresses as a flat array.

Source

pub fn max_von_mises_stress(&self) -> f64

Return the maximum von-Mises stress, or 0.0 if no result exists.

Source

pub fn last_solve_converged(&self) -> bool

Return whether the last solve converged.

Trait Implementations§

Source§

impl Clone for PyFemBinding

Source§

fn clone(&self) -> PyFemBinding

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PyFemBinding

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for PyFemBinding

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.