Skip to main content

RootProblem

Struct RootProblem 

Source
pub struct RootProblem {
    pub lo: f64,
    pub hi: f64,
    pub guess: f64,
}
Expand description

One bracketed root problem: an interval believed to contain a root, plus an optional starting iterate for the Newton solver.

§Fields and valid ranges

  • lo, hi — the bracket. Both must be finite. They may be given in either order; the solvers do not require lo < hi. The residual must have opposite signs at the two ends (or be exactly zero at one of them), otherwise the lane reports RootStatus::NotBracketed rather than guessing.
  • guess — the initial iterate for solve_newton_batch. Ignored by solve_bracketed_batch, which is driven entirely by the bracket. A non-finite guess, or one outside [lo, hi], is replaced by the bracket midpoint rather than rejected — a bad guess is a performance problem, not a correctness one, because the Newton solver is bracket-safeguarded.

§Units

Dimensionless f64 in whatever units the caller’s abscissa carries — kelvin for a temperature inversion, dimensionless for a compressibility factor. See the module-level “Units” section.

§Example

use outram_foam_basic_lib::math::parallel::RootProblem;

// Bracket only; the Newton guess defaults to the midpoint.
let p = RootProblem::new(300.0, 3000.0);
assert_eq!(p.guess, 1650.0);

// Or seed Newton from the previous timestep's answer.
let q = RootProblem::with_guess(300.0, 3000.0, 812.5);
assert_eq!(q.guess, 812.5);

Fields§

§lo: f64

One end of the bracket. Finite; need not be less than hi.

§hi: f64

The other end of the bracket. Finite; need not be greater than lo.

§guess: f64

Starting iterate for solve_newton_batch; ignored by solve_bracketed_batch.

Implementations§

Source§

impl RootProblem

Source

pub fn new(lo: f64, hi: f64) -> Self

A problem bracketed on [lo, hi], with the Newton guess set to the bracket midpoint.

§Arguments
  • lo, hi — the bracket ends, finite, in either order.
Source

pub fn with_guess(lo: f64, hi: f64, guess: f64) -> Self

A problem bracketed on [lo, hi] with an explicit Newton starting iterate.

Seeding from the previous timestep’s converged value is the usual reason to reach for this: it typically halves the iteration count of a per-cell thermodynamic inversion.

§Arguments
  • lo, hi — the bracket ends, finite, in either order.
  • guess — starting iterate. Silently replaced by the midpoint if it is non-finite or outside the bracket.

Trait Implementations§

Source§

impl Clone for RootProblem

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for RootProblem

Source§

impl Debug for RootProblem

Source§

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

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

impl PartialEq for RootProblem

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for RootProblem

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<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 = !

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

fn try_from(value: U) -> Result<T, !>

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.