pub enum SolverSelection {
Auto,
Named(String),
}Expand description
How a linear solver is chosen for a system.
§Canonical solver names
Named carries one of the registered backend names below. Unknown names are
rejected with a structured SolverError — they never fall back.
| name | symmetry | definiteness | intended size | registered by default |
|---|---|---|---|---|
dense | any (general) | any | small | yes |
skyline_ldlt | symmetric only | SPD (verified) | medium/large | yes |
sparse_lu | any (general) | any | medium/large | yes |
cg | symmetric only | SPD (assumed) | large | yes |
iccg | symmetric only | SPD (assumed) | large | yes |
pardiso | any (general) | any | very large | no — feature-gated stub |
§PARDISO availability
pardiso is not registered by SolverRegistry::default(), even when
the pardiso feature is compiled in: the unified PARDISO wrapper is a stub
whose factor() always returns an error. Selecting it through the default
registry therefore returns SolverError::Unsupported (“unknown solver”),
and auto-selection never claims it is available unless a PARDISO factory is
explicitly registered on the registry.
§Semantics
Auto: the registry analyses the matrix and picks a backend. It may substitute a different backend than any the caller had in mind.Named: the request is authoritative. The registry validates capabilities and returns an error if the backend cannot legally handle the matrix. It never substitutes another backend.
skyline_ldlt, cg and iccg require positive definiteness but perform
their own definiteness check during LinearSolver::factor (skyline rejects
a non-positive pivot; CG/ICCG report failure). They are therefore safe to
select on a symmetric matrix, but are never chosen by Auto for a matrix
whose SPD property is not established.
Variants§
Auto
Registry-based automatic selection (default).
Named(String)
Explicit backend request (canonical name, see type docs).
Implementations§
Source§impl SolverSelection
impl SolverSelection
Sourcepub fn named(name: impl Into<String>) -> Self
pub fn named(name: impl Into<String>) -> Self
Explicit selection by canonical name.
Examples found in repository?
13fn main() -> Result<(), Box<dyn std::error::Error>> {
14 let (e, a, i) = (200e9, 5e-3, 2e-5);
15 let (h, w) = (3.0, 4.0);
16 let lateral = 20e3; // N, +X
17 let udl = -8e3; // N/m, downward in member-local +y
18
19 // --- model -----------------------------------------------------------------
20 let mut frame = FrameModel::new();
21 let base_left = frame.add_node(0.0, 0.0)?;
22 let top_left = frame.add_node(0.0, h)?;
23 let top_right = frame.add_node(w, h)?;
24 let base_right = frame.add_node(w, 0.0)?;
25
26 let section = BeamSection::new(a, i);
27 let mat = Material::new(e, 0.3, 7850.0, "Steel");
28 let col_left = frame.add_member(base_left, top_left, mat, section)?;
29 let beam = frame.add_member(top_left, top_right, mat, section)?;
30 let col_right = frame.add_member(top_right, base_right, mat, section)?;
31
32 frame.fix(base_left)?;
33 frame.fix(base_right)?;
34 frame.nodal_load(top_left, lateral, 0.0)?; // global
35 frame.member_udl(beam, 0.0, udl)?; // local
36
37 // --- solve -----------------------------------------------------------------
38 let result = frame.solve_with(SolverSelection::named("sparse_lu"))?;
39 println!("backend : {:?}", result.solver_name());
40 println!(
41 "nodes / members : {} / {}",
42 result.n_nodes(),
43 result.n_members()
44 );
45
46 // --- results ---------------------------------------------------------------
47 println!(
48 "roof sway (ux) : {:+.6e} m",
49 result.displacement(top_left, Dof::Ux)?
50 );
51 println!(
52 "base reactions : Rx={:+.6e} Ry={:+.6e} Mz={:+.6e}",
53 result.reaction(base_left, Dof::Ux)?,
54 result.reaction(base_left, Dof::Uy)?,
55 result.reaction(base_left, Dof::Rz)?
56 );
57 println!(
58 "right base reaction : Rx={:+.6e} Ry={:+.6e}",
59 result.reaction(base_right, Dof::Ux)?,
60 result.reaction(base_right, Dof::Uy)?
61 );
62
63 // Member end forces are element-on-node forces in LOCAL axes:
64 // [N_i, V_i, M_i, N_j, V_j, M_j] = f_equiv - K_e u_e.
65 println!(
66 "beam end forces (local) : {:?}",
67 result.member_end_forces(beam)?
68 );
69 println!(
70 "left column global ends : {:?}",
71 result.member_end_forces_global(col_left)?
72 );
73 println!(
74 "right column global ends : {:?}",
75 result.member_end_forces_global(col_right)?
76 );
77
78 // --- equilibrium -----------------------------------------------------------
79 let eq = result.equilibrium();
80 println!(
81 "equilibrium residual : sumFx={:+.3e} sumFy={:+.3e} sumMz={:+.3e} (about the origin)",
82 eq.fx_residual, eq.fy_residual, eq.mz_residual
83 );
84 println!("balanced : {}", eq.is_balanced());
85
86 Ok(())
87}Sourcepub fn skyline_ldlt() -> Self
pub fn skyline_ldlt() -> Self
Select the skyline LDL^T backend (symmetric SPD).
Sourcepub fn pardiso() -> Self
pub fn pardiso() -> Self
Select the PARDISO backend.
Not available through SolverRegistry::default() — PARDISO is a
feature-gated stub that is deliberately left unregistered, so this
selection resolves only if a PARDISO factory is explicitly registered
via SolverRegistry::register. Otherwise
SolverRegistry::create_selected returns
SolverError::Unsupported rather than silently falling back.
Sourcepub fn requested_name(&self) -> Option<&str>
pub fn requested_name(&self) -> Option<&str>
The explicitly requested name, or None for SolverSelection::Auto.