@@ -11,7 +11,6 @@ use bevy_wgsparkl::resources::{AppState, PhysicsContext};
11
11
use nalgebra:: { Vector3 , vector} ;
12
12
use wgrapier3d:: dynamics:: body:: { BodyCoupling , BodyCouplingEntry } ;
13
13
use wgsparkl3d:: models:: DruckerPrager ;
14
- use wgsparkl3d:: solver:: ParticlePhase ;
15
14
use wgsparkl3d:: {
16
15
models:: ElasticCoefficients ,
17
16
pipeline:: MpmData ,
@@ -77,15 +76,6 @@ pub fn setup_mpm_particles(
77
76
let grid_size_z = 25 ;
78
77
let num_particles = grid_size_x * grid_size_y * grid_size_z;
79
78
80
- let particle_positions = ( 0 ..num_particles)
81
- . map ( |i| {
82
- let x = i % grid_size_x;
83
- let y = ( i / grid_size_x) % grid_size_y;
84
- let z = ( i / ( grid_size_x * grid_size_y) ) % grid_size_z;
85
- Vector3 :: new ( x as f32 , y as f32 + 1f32 , z as f32 )
86
- } )
87
- . collect :: < Vec < _ > > ( ) ;
88
-
89
79
app_state. particles_initialized = true ;
90
80
91
81
let coupling: Vec < _ > = coupling
@@ -121,46 +111,34 @@ pub fn setup_mpm_particles(
121
111
let cell_width = 1.0 ;
122
112
let mut particles = vec ! [ ] ;
123
113
124
- for x in -1 ..2 {
125
- for z in -1 ..2 {
126
- let x = x as f32 ;
127
- let z = z as f32 ;
128
- let offset = vector ! [ x * grid_size_x as f32 , 0f32 , z * grid_size_z as f32 ] * 2f32 ;
129
- for particle in & particle_positions {
130
- let position = vector ! [ particle. x, particle. y, particle. z] ;
131
-
132
- let particle_size = vector ! [ 1.0 , 1.0 , 1.0 ] ;
133
- let volume = particle_size. x * particle_size. y * particle_size. z ;
134
- let density = 1700.0 ;
135
- particles. push ( Particle {
136
- position : nalgebra:: Rotation :: from_axis_angle (
137
- & Vector3 :: z_axis ( ) ,
138
- 5f32 . to_radians ( ) ,
139
- ) * vector ! [ position. x, position. y, position. z]
140
- + offset,
141
- velocity : Vector3 :: zeros ( ) ,
142
- volume : ParticleMassProps :: new ( density * volume, volume. cbrt ( ) / 2.0 ) ,
143
- model : ElasticCoefficients :: from_young_modulus (
144
- 100_000_000.0 * 10f32 . powf ( z - 1f32 ) ,
145
- 0.2 + x * 0.05f32 ,
146
- ) ,
147
- plasticity : Some ( DruckerPrager {
148
- h0 : ( 45.0f32 + x * 20f32 ) . to_radians ( ) ,
149
- h1 : ( 70.0f32 + x * 20f32 ) . to_radians ( ) + z,
150
- h2 : 1.6 + z * 0.5f32 ,
151
- h3 : 25.0f32 . to_radians ( ) + x,
152
- ..DruckerPrager :: new (
153
- 100_000_000.0 * 10f32 . powf ( z - 1f32 ) ,
154
- 0.2 + x * 0.05f32 ,
155
- )
156
- } ) ,
157
- phase : Some ( ParticlePhase {
158
- phase : 0.5 + 0.5 * x,
159
- max_stretch : ( 0.0 + z) . clamp ( 0.0 , 1.0 ) ,
160
- } ) ,
161
- } ) ;
162
- }
163
- }
114
+ let density = 2700.0 ;
115
+ let rock_size = vector ! [ 1.0 , 1.0 , 1.0 ] ;
116
+ let volume = rock_size. x * rock_size. y * rock_size. z ;
117
+ let mass_props = ParticleMassProps :: new ( density * volume, volume. cbrt ( ) / 2.0 ) ;
118
+ let modulus = 10_000_000.0 ;
119
+ let poisson = 0.2 ;
120
+ let model = ElasticCoefficients :: from_young_modulus ( modulus, poisson) ;
121
+ let plasticity = Some ( DruckerPrager {
122
+ h0 : 45.0f32 . to_radians ( ) ,
123
+ h1 : 50.0f32 . to_radians ( ) ,
124
+ h2 : 0.4 ,
125
+ h3 : 15.0f32 . to_radians ( ) ,
126
+ ..DruckerPrager :: new ( modulus, poisson)
127
+ } ) ;
128
+
129
+ for i in 0 ..num_particles {
130
+ let x = i % grid_size_x;
131
+ let y = ( i / grid_size_x) % grid_size_y;
132
+ let z = ( i / ( grid_size_x * grid_size_y) ) % grid_size_z;
133
+ let position = vector ! [ x, y, z] ;
134
+ particles. push ( Particle {
135
+ position : vector ! [ position. x as f32 , position. y as f32 , position. z as f32 ] ,
136
+ velocity : Vector3 :: zeros ( ) ,
137
+ volume : mass_props,
138
+ model,
139
+ plasticity,
140
+ phase : None ,
141
+ } ) ;
164
142
}
165
143
166
144
println ! ( "Number of simulated particles: {}" , particles. len( ) ) ;
0 commit comments