diff options
| author | Claudius "keldu" Holeksa <mail@keldu.de> | 2026-01-08 15:12:34 +0100 |
|---|---|---|
| committer | Claudius "keldu" Holeksa <mail@keldu.de> | 2026-01-08 15:12:34 +0100 |
| commit | 1d797346f7b3e31b43baabdf37650658fe2f7142 (patch) | |
| tree | c1f20b3e41cc4f817e1b920087219cf0ffe521ec /examples/particles_gpu/particles_gpu.cpp | |
| parent | 6aa27007996656da995088aabecc273abd97db4b (diff) | |
| download | libs-lbm-1d797346f7b3e31b43baabdf37650658fe2f7142.tar.gz | |
Dangling things
Diffstat (limited to 'examples/particles_gpu/particles_gpu.cpp')
| -rw-r--r-- | examples/particles_gpu/particles_gpu.cpp | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/examples/particles_gpu/particles_gpu.cpp b/examples/particles_gpu/particles_gpu.cpp index 2f2d691..2fa44c1 100644 --- a/examples/particles_gpu/particles_gpu.cpp +++ b/examples/particles_gpu/particles_gpu.cpp @@ -31,25 +31,32 @@ saw::error_or<void> lbm_main(int argc, char** argv){ auto& old_pos = body.template get<"position_old">(); auto& acceleration = body.template get<"acceleration">(); auto& p_size = part.template get<"size">(); - p_size = {0.5f}; + auto& p_rad = part.template get<"collision">().template get<"radius">(); + p_size = {0.4f}; + p_rad = {0.4f}; - if(j.get() % 2u == 0) acceleration.at({{1u}}) = {9.81}; + if(j.get() % 2u == 0) acceleration.at({{1u}}) = {-9.81}; - pos.at({{0u}}) = {i.template cast_to<sch::Float32>()}; - pos.at({{1u}}) = {j.template cast_to<sch::Float32>()}; + pos.at({{0u}}) = {i.template cast_to<sch::Float32>()+0.5f}; + pos.at({{1u}}) = {j.template cast_to<sch::Float32>()+64.0f}; old_pos = pos; } } for(saw::data<sch::UInt64> dt{0u}; dt < saw::data<sch::UInt64>{32ul}; ++dt){ + // Do Verlet Step for(saw::data<sch::UInt64> i{0u}; i < particles.size(); ++i){ auto& part_i = particles.at(i); verlet_step_lambda<sch::Float32,2u>(part_i,{0.05f}); } + // for(saw::data<sch::UInt64> i{0u}; i < particles.size(); ++i){ auto& part_i = particles.at(i); + /** + * Test against other particles + */ for(saw::data<sch::UInt64> j{i+1ul}; j < particles.size(); ++j){ auto& part_j = particles.at(j); @@ -58,9 +65,24 @@ saw::error_or<void> lbm_main(int argc, char** argv){ std::cout<<"Collision"<<std::endl; } } + /** + * Test against walls + */ + auto& body_i = part_i.template get<"rigid_body">(); + auto& pos_i = body_i.template get<"position">(); + auto& pos_old_i = body_i.template get<"position_old">(); + if(pos_i.at({{0u}}).get() <= 0 or pos_i.at({{0u}}).get() >= 40 ){ + auto pos_i_0 = pos_i.at({{0u}}); + pos_i.at({{0u}}) = pos_old_i.at({{0u}}); + pos_old_i.at({{0u}}) = pos_i_0; + } + if(pos_i.at({{1u}}).get() <= 0 or pos_i.at({{1u}}).get() >= 40 ){ + auto pos_i_1 = pos_i.at({{1u}}); + pos_i.at({{1u}}) = pos_old_i.at({{1u}}); + pos_old_i.at({{1u}}) = pos_i_1; + } } auto& pos = particles.at({0u}).template get<"rigid_body">().template get<"position">(); - std::cout<<pos.at({{0u}}).get()<<" "<<pos.at({{1u}}).get()<<std::endl; saw::codec<sch::Array<sch::Particle<sch::Float32,2u>>, saw::encode::Json> j_codec; } |
