From e821d617802ebbfff756844e4d9720342fc78a4e Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Fri, 13 Nov 2026 14:12:49 +0100 Subject: Swarm POC --- examples/particles_gpu/particles_gpu.cpp | 136 ------------------------------- 1 file changed, 136 deletions(-) delete mode 100644 examples/particles_gpu/particles_gpu.cpp (limited to 'examples/particles_gpu/particles_gpu.cpp') diff --git a/examples/particles_gpu/particles_gpu.cpp b/examples/particles_gpu/particles_gpu.cpp deleted file mode 100644 index 94ec5f1..0000000 --- a/examples/particles_gpu/particles_gpu.cpp +++ /dev/null @@ -1,136 +0,0 @@ -#include -#include - - -#include -#include - -namespace kel{ -namespace lbm { -namespace sch { -} -} - -kel::lbm::error_or lbm_main(int argc, char** argv){ - (void) argc; - (void) argv; - - using namespace lbm; - using namespace acpp; - - kel::lbm::data>> particles{1024u}; - - for(kel::lbm::data i{0u}; i < kel::lbm::data{32u}; ++i){ - for(kel::lbm::data j{0u}; j < kel::lbm::data{32u}; ++j){ - - auto& part = particles.at(i*32ul+j); - auto& body = part.template get<"rigid_body">(); - - auto& pos = body.template get<"position">(); - auto& old_pos = body.template get<"position_old">(); - auto& acceleration = body.template get<"acceleration">(); - auto& p_rad = part.template get<"collision">().template get<"radius">(); - // Scalar base, so the value goes through the element rather than a - // braced whole-unit assignment. - p_rad.at({}).set(0.4f); - - if(j.get() % 2u == 0) acceleration.at({{1u}}) = {-9.81}; - - pos.at({{0u}}) = {i.template cast_to()+0.5f}; - pos.at({{1u}}) = {j.template cast_to()+64.0f}; - - old_pos = pos; - } - } - - // A timestep is a lattice time, which makes (pos - pos_old)/time_step a - // velocity rather than an unlabelled vector. - kel::lbm::data>> time_step; - time_step.at({}).set(0.05f); - - for(kel::lbm::data dt{0u}; dt < kel::lbm::data{32ul}; ++dt){ - // Do Verlet Step - for(kel::lbm::data i{0u}; i < particles.size(); ++i){ - auto& part_i = particles.at(i); - - verlet_step_lambda(part_i,time_step); - auto& body_i = part_i.template get<"rigid_body">(); - auto& acc_i = body_i.template get<"acceleration">(); - - acc_i.at({{0u}}) = 0.0; - acc_i.at({{1u}}) = -9.81; - } - - // - for(kel::lbm::data i{0u}; i < particles.size(); ++i){ - auto& part_i = particles.at(i); - 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">(); - /** - * Test against other particles - */ - for(kel::lbm::data j{i+1ul}; j < particles.size(); ++j){ - auto& part_j = particles.at(j); - auto& body_j = part_j.template get<"rigid_body">(); - auto& pos_j = body_j.template get<"position">(); - auto& pos_old_j = body_j.template get<"position_old">(); - - auto res = broadphase_collision_distance_squared(part_i, part_j); - if(res.first){ - //std::cout<<"Collision"<= 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 ){ - 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< 0u){ - std::cerr<<" - "<