sparkl3d_core/dynamics/solver/
solver_parameters.rs

1use crate::math::Real;
2
3bitflags::bitflags! {
4    #[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
5    #[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
6    #[repr(C)]
7    pub struct SimulationDofs: u32 {
8        const LOCK_NONE = 0;
9        const LOCK_X = 1 << 0;
10        const LOCK_Y = 1 << 1;
11        #[cfg(feature = "dim3")]
12        const LOCK_Z = 1 << 2;
13    }
14}
15
16#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
17#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
18#[derive(Copy, Clone, Debug, PartialEq)]
19#[repr(C)]
20pub enum BoundaryHandling {
21    Stick,
22    Friction,
23    FrictionZUp, // A bit of a hack until we have a more generic solution
24    None,
25}
26
27#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
28#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
29#[derive(Copy, Clone, Debug, PartialEq)]
30#[repr(C)]
31pub enum DamageModel {
32    CdMpm,
33    Eigenerosion,
34    ModifiedEigenerosion,
35    None,
36}
37
38#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
39#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
40#[derive(Copy, Clone, Debug, PartialEq)]
41#[repr(C)]
42pub struct SolverParameters {
43    pub dt: Real,
44    pub max_substep_dt: Real,
45    pub max_num_substeps: u32,
46    pub boundary_handling: BoundaryHandling,
47    pub damage_model: DamageModel,
48    pub force_fluids_volume_recomputation: bool,
49    pub enable_boundary_particle_projection: bool,
50    pub stop_after_one_substep: bool,
51    pub simulation_dofs: SimulationDofs,
52}
53
54impl Default for SolverParameters {
55    fn default() -> Self {
56        SolverParameters {
57            dt: 1.0 / 60.0,
58            max_substep_dt: Real::MAX,
59            max_num_substeps: 1000,
60            boundary_handling: BoundaryHandling::Friction,
61            damage_model: DamageModel::None,
62            force_fluids_volume_recomputation: false,
63            enable_boundary_particle_projection: false,
64            stop_after_one_substep: false,
65            simulation_dofs: SimulationDofs::LOCK_NONE,
66        }
67    }
68}