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§
Sourcefn solve(&self, density: &DensityField, g: f64) -> PotentialField
fn solve(&self, density: &DensityField, g: f64) -> PotentialField
Solve ∇²Φ = 4πGρ and return the potential field.
Sourcefn compute_acceleration(&self, potential: &PotentialField) -> AccelerationField
fn compute_acceleration(&self, potential: &PotentialField) -> AccelerationField
Compute the gravitational acceleration g = −∇Φ via spectral differentiation or finite differences.
Provided Methods§
Sourcefn set_progress(&mut self, _progress: Arc<StepProgress>)
fn set_progress(&mut self, _progress: Arc<StepProgress>)
Attach shared progress state for intra-phase cell-level reporting.