Skip to main content

SolidificationPorosity

Struct SolidificationPorosity 

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

Simple solidification as a porous blockage — upstream porosityModels::solidification.

§The model

The solid phase is represented purely as a drag on the momentum equation,

S = -α ρ D(T) U,

with D(T) a user-supplied table of drag against temperature and α an optional phase fraction of the solidifying phase. Nothing else happens: upstream states plainly that the latent heat of solidification is not included and the temperature is unchanged by the modelled change of phase.

§When to use this instead of the enthalpy-porosity model

SolidificationMelting is the physically complete model — it tracks a liquid fraction, absorbs latent heat, and carries its own Boussinesq buoyancy. This one does none of that. It exists because it is cheap and because it needs no thermophysical model at all: it only ever reads a temperature field. Use it to freeze flow out of a region whose thermal history you do not care about; use the enthalpy-porosity model when the phase change itself is the physics of interest.

A gallium melting calculation, for instance, cannot be run with this model — without latent heat the melt front advances at entirely the wrong rate.

§State

Stateless, unlike SolidificationMelting. The drag depends only on the current temperature, so there is no history to carry and no per-timestep update to guard.

Implementations§

Source§

impl SolidificationPorosity

Source

pub fn new( name: impl Into<String>, velocity_name: impl Into<String>, selection: CellSelection, drag: TemperatureTable, form: MomentumEquationForm, ) -> Self

Build the model.

  • name — identifier for diagnostics, upstream’s dictionary key.
  • velocity_name — the velocity field whose equation gains the drag.
  • selection — the cells acted on, upstream’s cellZone.
  • drag — the D(T) table.
  • form — whether the momentum equation is kinematic or density-weighted; see MomentumEquationForm.

The optional phase fraction (upstream’s alpha, default none) is not set here; use with_phase_fraction if the drag should act only on a fraction of each cell.

Source

pub fn with_phase_fraction(self, alpha_name: impl Into<String>) -> Self

Name the optional phase fraction field of the solidifying phase, upstream’s alpha keyword.

The drag is scaled by this field, so a cell only half occupied by the solidifying phase feels half the blockage. Without it upstream substitutes geometricOneField(), i.e. α = 1 everywhere.

Source

pub fn name(&self) -> &str

The model’s name.

Source

pub fn velocity_name(&self) -> &str

The velocity field this adds drag to.

Source

pub fn phase_fraction_name(&self) -> Option<&str>

The name of the optional solidifying-phase fraction field, if one was set.

Source

pub fn selection(&self) -> &CellSelection

The cells acted on.

Source

pub fn drag_table(&self) -> &TemperatureTable

The D(T) table.

Source

pub fn form(&self) -> MomentumEquationForm

Which momentum-equation form this model was built for.

Source

pub fn add_momentum_source( &self, temperature: &VolScalarField, rho: &VolScalarField, phase_fraction: Option<&VolScalarField>, eqn: &mut FvVectorMatrix, )

Add the porous drag to a velocity equation.

Upstream’s correct(fvVectorMatrix& UEqn), which does

Udiag[celli] += V[celli]*alpha[celli]*rho[celli]*D_->value(T[celli]);

rho is used only in the DensityWeighted form and ignored otherwise; pass any field in the kinematic case. phase_fraction is Some only if the model was built with with_phase_fraction — passing None when one was named silently drops the scaling, so callers should keep the two together.

§Sign convention — this one is not negated, unlike the fvModel

This is the trap when reading the two solidification models side by side. Upstream’s fvModel solidificationMelting writes into an intermediate matrix that solve(UEqn == fvModels.source(...)) then subtracts, so its Sp[celli] += Vc*S with a negative S reaches the solved system as a positive diagonal contribution. Upstream’s porosityModel, by contrast, is handed the solver’s own UEqn and mutates UEqn.diag() in place — nothing negates it afterwards, which is exactly why upstream writes += here with a positive D.

The two upstream files therefore look like they disagree about the sign of a Darcy drag, and they do not. This port writes diag += V·α·ρ·D(T) — upstream’s expression unchanged — because eqn here, like upstream’s UEqn, is the system being solved. Increasing the diagonal damps the velocity, which is the intended sink.

Source

pub fn force_diagonal( &self, temperature: &VolScalarField, rho: &VolScalarField, phase_fraction: Option<&VolScalarField>, cell_volumes: &[f64], ) -> Vec<f64>

The diagonal drag coefficient per cell, upstream’s Udiag inside calcForce.

This is V·α·ρ·D(T) — the same quantity add_momentum_source adds to the diagonal, exposed on its own so a caller can form upstream’s diagnostic force = Udiag·U (units [N] in the density-weighted form, [m⁴/s²] in the kinematic one) without re-deriving it. The cell volume is included, because upstream’s calcForce passes mesh_.V() into the same apply the momentum correction uses.

It is a diagnostic only: no equation gains a term from calling this.

Returns one value per selected cell, in selection order, not one per mesh cell.

Trait Implementations§

Source§

impl Clone for SolidificationPorosity

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 Debug for SolidificationPorosity

Source§

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

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

impl PartialEq for SolidificationPorosity

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 SolidificationPorosity

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.