From 4968da9a05df5c10fb1f10655189ae251b38f92b Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Wed, 30 Jul 2025 18:04:13 +0200 Subject: Way too many changes --- examples/poiseulle_particles_2d.cpp | 87 +++++++++++++++++++++++++++++++++---- 1 file changed, 79 insertions(+), 8 deletions(-) (limited to 'examples/poiseulle_particles_2d.cpp') diff --git a/examples/poiseulle_particles_2d.cpp b/examples/poiseulle_particles_2d.cpp index 7506318..57f77e3 100644 --- a/examples/poiseulle_particles_2d.cpp +++ b/examples/poiseulle_particles_2d.cpp @@ -2,9 +2,11 @@ #include "../c++/collision.hpp" #include "../c++/boundary.hpp" #include "../c++/iterator.hpp" +#include "../c++/particle/geometry/circle.hpp" #include + namespace kel { namespace lbm { namespace sch { @@ -29,6 +31,12 @@ using DfCell = Cell; template using CellInfo = Cell; +template +using CellParticleMask = Cell; + +template +using CellForceField = Cell; + /** * Basic type for simulation */ @@ -36,13 +44,16 @@ template using CellStruct = Struct< Member, "dfs">, Member, "dfs_old">, - Member, "info"> + Member, "info">, + Member, "particle_mask">, + Member, "forcing"> >; template using MacroStruct = Struct< Member, "velocity">, - Member + Member, + Member >; template @@ -269,6 +280,46 @@ void set_initial_conditions(saw::data& latt){ }, {{0u,0u}}, meta); } +void add_particles(kel::lbm::particle_system& part_sys){ + saw::data> part; + + + auto& p_mask = part.template get<"mask">(); + { + particle_circle_geometry geo; + p_mask = geo.template generate_mask(16u); + } + auto& rigid_body = part.template get<"rigid_body">(); + auto& p_size = part.template get<"size">(); + { + auto& pos = rigid_body.template get<"position">(); + auto& old_pos = rigid_body.template get<"position">(); + + pos = {{32u,64u}}; + old_pos = {{32u,64u}}; + + p_size = {4.0}; + } + + { + auto eov = particle_sys.add(part); + if(eov.is_error()){ + exit(-1); + } + } +} + +void couple_particles_to_lattice(kel::lbm::particle_system& part_sys, saw::data& latt){ + iterate_over([&](const saw::data>& index){ + auto& cell = latt(index); + auto& info = cell.template get<"info">(); + auto& mask = cell.template get<"particle_mask">(); + + + + }, {{0u,0u}}, meta); +} + void lbm_step( saw::data& latt, uint64_t time_step @@ -343,6 +394,13 @@ int main(int argc, char** argv){ using namespace kel::lbm; using dfi = df_info; + auto eo_lbm_dir = output_directory(); + if(eo_lbm_dir.is_error()){ + return -1; + } + auto& lbm_dir = eo_lbm_dir.get_value(); + auto out_dir = lbm_dir / "poiseulle_channel_2d"; + std::string_view cfg_file_name = "config.json"; if(argc > 1){ cfg_file_name = argv[1]; @@ -374,6 +432,13 @@ int main(int argc, char** argv){ saw::data lattice{dim}; auto meta = lattice.meta(); + /** + * Particle System + */ + particle_system particle_sys; + add_particles(particle_sys); + + /** * Setup geometry */ @@ -390,8 +455,7 @@ int main(int argc, char** argv){ geo(index).template get<"info">().set(info({0u}).get()); }, {{0u,0u}}, dim); - std::string vtk_f_name{"tmp/geometry.vtk"}; - write_vtk_file(vtk_f_name, geo); + write_vtk_file(out_dir / "geometry.vtk", geo); } /** @@ -412,15 +476,22 @@ int main(int argc, char** argv){ auto& rho = macros.at(index).template get<"pressure">(); auto& vel = macros.at(index).template get<"velocity">(); + auto& part_mask = macros.at(index).template get<"particle">(); compute_rho_u(dfs,rho,vel); rho = rho * saw::data{dfi::cs2}; - + part = cell.template get<"particle_mask">()({0u}); }, {{0u,0u}}, meta); - std::string vtk_f_name{"tmp/poiseulle_2d_"}; - vtk_f_name += std::to_string(i) + ".vtk"; - write_vtk_file(vtk_f_name, macros); + + + + { + std::string vtk_f_name{"macros_"}; + vtk_f_name += std::to_string(i) + ".vtk"; + write_vtk_file(out_dir / vtk_f_name, macros); + } } + couple_particles_to_lattice(particle_sys, lattice); lbm_step(lattice, i); } -- cgit v1.2.3