Struct Settings

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

A settings struct, used to define boundary conditions, loads, and elements.

Implementations§

Source§

impl Settings

Source

pub fn new(nelx: usize, nely: usize, volume_fraction: f64) -> Self

Specify the number of elements and volume fraction

use topopt::Settings;
Settings::new(60, 20, 0.5);
Source

pub fn with_filter_radius(&mut self, filter_radius: f64) -> Self

Specify the filter radius. If not specified, the default value is 1.5.

Source

pub fn with_penalty_weight(&mut self, penalty_weight: f64) -> Self

Specify the penalty weight. If not specified, the default value is 1.5.

Source

pub fn with_active_elements(&mut self, mask: DMatrix<bool>) -> Self

Specify elements that must remain active (i.e., filled). The active element boolean mask must have shape nely × nelx.

Source

pub fn with_passive_elements(&mut self, mask: DMatrix<bool>) -> Self

Specify elements that must remain passive (i.e., filled). The passive element boolean mask must have shape nely × nelx.

Source

pub fn with_size(&mut self, nelx: usize, nely: usize) -> Self

Specify the dimensions of the domain.

Source

pub fn with_random_initialization(&mut self) -> Self

Specify the dimensions of the domain.

Source§

impl Settings

§Modifying the Boundary Conditions

This group of methods provides utilities for changing the boundary conditions. These methods are applied like so:

 let settings = Settings::new(120, 30, 0.5)
     .with_bottom_right_bc(false, true)
     .with_bottom_left_bc(false, true);
Source

pub fn with_left_bc(&mut self, x: bool, y: bool) -> Self

Apply a boundary condition to the left side of the domain. The arguments define whether or not the nodes are fixed in the x and y directions.

Source

pub fn with_right_bc(&mut self, x: bool, y: bool) -> Self

Apply a boundary condition to the right side of the domain. The arguments define whether or not the nodes are fixed in the x and y directions.

Source

pub fn with_top_bc(&mut self, x: bool, y: bool) -> Self

Apply a boundary condition to the top side of the domain. The arguments define whether or not the nodes are fixed in the x and y directions.

Source

pub fn with_bottom_bc(&mut self, x: bool, y: bool) -> Self

Apply a boundary condition to the bottom side of the domain. The arguments define whether or not the nodes are fixed in the x and y directions.

Source

pub fn with_vertical_midline_bc(&mut self, x: bool, y: bool) -> Self

Apply a boundary condition to the vertical midline of the domain. The arguments define whether or not the nodes are fixed in the x and y directions.

Source

pub fn with_horizontal_midline_bc(&mut self, x: bool, y: bool) -> Self

Apply a boundary condition to the horizontal midline of the domain. The arguments define whether or not the nodes are fixed in the x and y directions.

Source

pub fn with_bottom_right_bc(&mut self, x: bool, y: bool) -> Self

Apply a boundary condition to the bottom right corner of the domain. The arguments define whether or not the node is fixed in the x and y directions.

Source

pub fn with_bottom_left_bc(&mut self, x: bool, y: bool) -> Self

Apply a boundary condition to the bottom left corner of the domain. The arguments define whether or not the node is fixed in the x and y directions.

Source

pub fn with_top_right_bc(&mut self, x: bool, y: bool) -> Self

Apply a boundary condition to the top right corner of the domain. The arguments define whether or not the node is fixed in the x and y directions.

Source

pub fn with_top_left_bc(&mut self, x: bool, y: bool) -> Self

Apply a boundary condition to the top left corner of the domain. The arguments define whether or not the node is fixed in the x and y directions.

Source

pub fn with_bc(&mut self, boundary: DMatrix<(bool, bool)>) -> Self

Specify loading at every node. This matrix must shape nely+1 × nelx+1, where each element is a tuple defining whether or not the node is fixed in x and y directions.

Source

pub fn set_bc(&mut self, idx: usize, jdx: usize, x: bool, y: bool) -> Self

Set the boundary condition at a specific node. The arguments define the indices of the node to be loaded, and whether or not the node is fixed in the x and y directions.

Source§

impl Settings

§Modifying the Load Case

This group of methods provides utilities for changing the load case. These methods are applied like so:

 let settings = Settings::new(120, 30, 0.5)
     .with_bottom_right_bc(false, true)
     .with_bottom_left_bc(false, true)
     .with_top_middle_load(0.0, -1.0);
Source

pub fn with_bottom_right_load(&mut self, x: f64, y: f64) -> Self

Set a load at the bottom right corner of the domain. The argument define loads in the x and y directions.

Source

pub fn with_bottom_left_load(&mut self, x: f64, y: f64) -> Self

Set a load at the bottom left corner of the domain. The argument define loads in the x and y directions.

Source

pub fn with_top_right_load(&mut self, x: f64, y: f64) -> Self

Set a load at the top right corner of the domain. The argument define loads in the x and y directions.

Source

pub fn with_top_left_load(&mut self, x: f64, y: f64) -> Self

Set a load at the top left corner of the domain. The argument define loads in the x and y directions.

Source

pub fn with_top_middle_load(&mut self, x: f64, y: f64) -> Self

Set a load at the middle of the top side of the domain. The argument define loads in the x and y directions.

Source

pub fn with_bottom_middle_load(&mut self, x: f64, y: f64) -> Self

Set a load at the middle of the bottom side of the domain. The argument define loads in the x and y directions.

Source

pub fn with_right_middle_load(&mut self, x: f64, y: f64) -> Self

Set a load at the middle of the right side of the domain. The argument define loads in the x and y directions.

Source

pub fn with_left_middle_load(&mut self, x: f64, y: f64) -> Self

Set a load at the middle of the left side of the domain. The argument define loads in the x and y directions.

Source

pub fn with_centered_load(&mut self, x: f64, y: f64) -> Self

Set a load at the center of the domain. The argument define loads in the x and y directions.

Source

pub fn with_loads(&mut self, loads: DMatrix<(f64, f64)>) -> Self

Specify loading at every node. This matrix must shape nely+1 × nelx+1, where each element is a tuple defining the loading in x and y directions.

Source

pub fn set_load(&mut self, idx: usize, jdx: usize, x: bool, y: bool) -> Self

Set a load at a specific node. The arguments define the indices of the node to be loaded, and the loads in the x and y directions.

Trait Implementations§

Source§

impl Clone for Settings

Source§

fn clone(&self) -> Settings

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 Default for Settings

Source§

fn default() -> Self

use topopt::Settings;
Settings::default();

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V