Skip to main content

PhaseChangeModifier

Struct PhaseChangeModifier 

Source
pub struct PhaseChangeModifier {
    pub config: PhaseChangeConfig,
    pub temperature: ScalarField3D,
    pub phase: ScalarField3D,
    pub latent_heat: ScalarField3D,
    pub sdf_offset: ScalarField3D,
    pub enabled: bool,
}
Expand description

Phase-change SDF modifier with solid/liquid/gas transitions

Fields§

§config: PhaseChangeConfig

Configuration

§temperature: ScalarField3D

Temperature field

§phase: ScalarField3D

Phase state per cell (stored as f32: 0=Solid, 1=Liquid, 2=Gas)

§latent_heat: ScalarField3D

Latent heat buffer (energy absorbed/released during phase transition)

§sdf_offset: ScalarField3D

Accumulated SDF offset (positive = material removed)

§enabled: bool

Whether modifier is enabled

Implementations§

Source§

impl PhaseChangeModifier

Source

pub fn new( config: PhaseChangeConfig, resolution: usize, min: (f32, f32, f32), max: (f32, f32, f32), ) -> Self

Create a new phase change modifier

Source

pub fn apply_heat_at( &mut self, x: f32, y: f32, z: f32, amount: f32, radius: f32, )

Apply heat at a position

Source

pub fn temperature_at(&self, x: f32, y: f32, z: f32) -> f32

Get temperature at a point

Source

pub fn phase_at(&self, x: f32, y: f32, z: f32) -> Phase

Get phase at a point

Source§

impl PhaseChangeModifier

Source

pub const PARTICIPANT_KIND: ParticipantKind

Snapshot tag of this type as a world participant: "PHAS", the four ASCII bytes read big endian. Never changes.

Trait Implementations§

Source§

impl CoupledScalar for PhaseChangeModifier

The temperature field is shared through a deterministic Fix128 channel.

The counterpart of the impl on crate::thermal::ThermalModifier: the two modifiers hold independent copies of the same physical quantity, and crate::coupled_field::reconcile_mean is what makes a point have one temperature instead of two.

Source§

fn coupled_name(&self) -> &'static str

Name of the quantity shared, for diagnostics ("temperature", …).
Source§

fn coupled_channel(&self) -> Result<CoupledField, CoupledFieldError>

A zero-filled channel on this subsystem’s grid. Read more
Source§

fn publish(&self, out: &mut CoupledField) -> Result<(), CoupledFieldError>

Write this subsystem’s field into out. Read more
Source§

fn adopt(&mut self, src: &CoupledField) -> Result<(), CoupledFieldError>

Replace this subsystem’s field with the channel’s contents. Read more
Source§

fn check_adopt(&self, src: &CoupledField) -> Result<(), CoupledFieldError>

Report, without changing anything, whether Self::adopt would accept src. Read more
Source§

impl Participant for PhaseChangeModifier

One update(h) per world substep (h converted with Fix128::to_f32); see the module documentation of crate::sim_modifier for the payload and what is not coupled yet.

Observations: channel 0 the highest cell temperature (absent for a grid without cells), channel 1 the number of cells that are not solid (stored phase ≥ 0.5), channel 2 the total SDF offset.

Source§

fn kind(&self) -> ParticipantKind

Snapshot tag of this participant type.
Source§

fn substep( &mut self, _ctx: &mut SubstepCtx<'_>, h: Fix128, ) -> Result<(), ParticipantFault>

Advance by one world substep of width h (ctx.h()). Read bodies from ctx, stage forces on them through ctx. Read more
Source§

fn observe(&self, out: &mut ObservationSink)

Report observable values. The world reports them as Observed::Undecided while a fault is recorded.
Source§

fn write_state(&self, out: &mut Vec<u8>)

Append the whole state to out.
Source§

fn check_state(&self, bytes: &[u8]) -> Result<(), StateError>

Check that bytes is a payload Self::read_state can apply. Must not change self. Read more
Source§

fn read_state(&mut self, bytes: &[u8])

Replace the state with bytes. Only called with a payload Self::check_state accepted.
Source§

fn step_rule(&self) -> StepRule

How this participant’s time step relates to the world substep.
Source§

fn ports(&self) -> &[Port]

The ports this participant reads and writes, empty by default. The world reads them once, at registration, to fix the execution order (execution_order); they must not change while the participant is registered.
Source§

impl PhysicsModifier for PhaseChangeModifier

Source§

fn modify_distance(&self, x: f32, y: f32, z: f32, original_dist: f32) -> f32

Modify the SDF distance at a world-space point. Read more
Source§

fn update(&mut self, dt: f32)

Advance the simulation state by dt seconds.
Source§

fn name(&self) -> &'static str

Name of this modifier (for debugging)
Source§

fn is_active(&self) -> bool

Whether this modifier has any active effect

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.