pub struct Mesh2D {
pub nodes: HashMap<u32, MeshNode2D>,
pub elements: HashMap<u32, MeshElement>,
pub next_node_id: u32,
pub next_elem_id: u32,
}Expand description
2D triangular mesh supporting adaptive refinement
Fields§
§nodes: HashMap<u32, MeshNode2D>All nodes indexed by their ID
elements: HashMap<u32, MeshElement>All elements indexed by their ID
next_node_id: u32Next available node ID
next_elem_id: u32Next available element ID
Implementations§
Source§impl Mesh2D
impl Mesh2D
Sourcepub fn add_node(&mut self, x: f64, y: f64) -> u32
pub fn add_node(&mut self, x: f64, y: f64) -> u32
Add a node at (x, y) and return its assigned ID
Sourcepub fn add_element(&mut self, n0: u32, n1: u32, n2: u32) -> u32
pub fn add_element(&mut self, n0: u32, n1: u32, n2: u32) -> u32
Add a triangular element referencing three existing node IDs Returns the new element ID
Sourcepub fn element_area(&self, elem: &MeshElement) -> f64
pub fn element_area(&self, elem: &MeshElement) -> f64
Compute the signed area of a triangle element Returns 0.0 if any referenced node is missing
Sourcepub fn element_edge_lengths(&self, elem: &MeshElement) -> [f64; 3]
pub fn element_edge_lengths(&self, elem: &MeshElement) -> [f64; 3]
Compute the three edge lengths [|e01|, |e12|, |e20|]
Returns [0,0,0] if any node is missing
Sourcepub fn element_aspect_ratio(&self, elem: &MeshElement) -> f64
pub fn element_aspect_ratio(&self, elem: &MeshElement) -> f64
Compute the aspect ratio as longest_edge / shortest_edge Returns f64::INFINITY for degenerate elements
Sourcepub fn element_min_angle_deg(&self, elem: &MeshElement) -> f64
pub fn element_min_angle_deg(&self, elem: &MeshElement) -> f64
Compute the minimum interior angle in degrees Uses the law of cosines; returns 0.0 for degenerate elements
Sourcepub fn midpoint(&self, n1: u32, n2: u32) -> (f64, f64)
pub fn midpoint(&self, n1: u32, n2: u32) -> (f64, f64)
Compute the midpoint coordinates between two nodes Returns (0,0) if either node is missing
Sourcepub fn refine_element(&mut self, elem_id: u32) -> [u32; 4]
pub fn refine_element(&mut self, elem_id: u32) -> [u32; 4]
Refine a single element by bisecting all three edges.
Inserts midpoint nodes on each edge and creates 4 congruent sub-triangles:
n2
/ \
m20--m12
/ \ / \
n0--m01--n1Returns the IDs of the 4 new child elements. Returns an empty array if the element is not found or already at MAX_REFINEMENT_LEVEL.
Sourcepub fn should_refine(
&self,
elem: &MeshElement,
criteria: &RefinementCriteria,
error_map: &HashMap<u32, f64>,
) -> bool
pub fn should_refine( &self, elem: &MeshElement, criteria: &RefinementCriteria, error_map: &HashMap<u32, f64>, ) -> bool
Determine whether an element should be refined given criteria and an error map
Sourcepub fn refine_mesh(
&mut self,
criteria: &RefinementCriteria,
error_map: &HashMap<u32, f64>,
) -> RefinementStats
pub fn refine_mesh( &mut self, criteria: &RefinementCriteria, error_map: &HashMap<u32, f64>, ) -> RefinementStats
Perform one global refinement pass: refine all elements meeting the criteria.
Returns statistics about this refinement pass.
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Return the current number of nodes
Sourcepub fn element_count(&self) -> usize
pub fn element_count(&self) -> usize
Return the current number of elements
Sourcepub fn total_area(&self) -> f64
pub fn total_area(&self) -> f64
Compute the total mesh area (sum of all element areas)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Mesh2D
impl RefUnwindSafe for Mesh2D
impl Send for Mesh2D
impl Sync for Mesh2D
impl Unpin for Mesh2D
impl UnsafeUnpin for Mesh2D
impl UnwindSafe for Mesh2D
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<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more