Skip to main content

PoissonSolver

Trait PoissonSolver 

Source
pub trait PoissonSolver {
    // Required methods
    fn solve(&self, density: &DensityField, g: f64) -> PotentialField;
    fn compute_acceleration(
        &self,
        potential: &PotentialField,
    ) -> AccelerationField;

    // Provided method
    fn set_progress(&mut self, _progress: Arc<StepProgress>) { ... }
}
Expand description

Trait for all gravitational Poisson solver implementations.

§Examples

use caustic::{FftPoisson, PoissonSolver, Domain, DomainBuilder, SpatialBoundType, VelocityBoundType};

let domain = Domain::builder()
    .spatial_extent(10.0)
    .velocity_extent(5.0)
    .spatial_resolution(16)
    .velocity_resolution(16)
    .spatial_bc(SpatialBoundType::Periodic)
    .velocity_bc(VelocityBoundType::Open)
    .build()
    .unwrap();

let poisson = FftPoisson::new(&domain);
let potential = poisson.solve(&density, 1.0);
let acceleration = poisson.compute_acceleration(&potential);

Required Methods§

Source

fn solve(&self, density: &DensityField, g: f64) -> PotentialField

Solve ∇²Φ = 4πGρ and return the potential field.

Source

fn compute_acceleration(&self, potential: &PotentialField) -> AccelerationField

Compute the gravitational acceleration g = −∇Φ via spectral differentiation or finite differences.

Provided Methods§

Source

fn set_progress(&mut self, _progress: Arc<StepProgress>)

Attach shared progress state for intra-phase cell-level reporting.

Implementors§