From f53b62f995af1ad0e7cbc8aa3a7522d041eb9363 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Sun, 28 Sep 2025 00:09:23 +0200 Subject: Found error ._. --- examples/poiseulle_particles_channel_2d.cpp | 38 +++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 10 deletions(-) (limited to 'examples/poiseulle_particles_channel_2d.cpp') diff --git a/examples/poiseulle_particles_channel_2d.cpp b/examples/poiseulle_particles_channel_2d.cpp index 842e48b..20919b0 100644 --- a/examples/poiseulle_particles_channel_2d.cpp +++ b/examples/poiseulle_particles_channel_2d.cpp @@ -277,7 +277,7 @@ void couple_particles_to_lattice( kel::lbm::particle_system& part_sys, saw::data& latt, saw::data,kel::lbm::sch::D2Q9::D>>& macros, - saw::data time_step + saw::data time_step ){ using namespace kel::lbm; (void) time_step; @@ -346,7 +346,7 @@ void couple_particles_to_lattice( saw::data> index_shift; { index_shift.at({{0u}}) = index.at({0u}).template cast_to() - p_mask_grid_shift.at({{0u}}); - index_shift.at({{1u}}) = index.at({0u}).template cast_to() - p_mask_grid_shift.at({{1u}}); + index_shift.at({{1u}}) = index.at({1u}).template cast_to() - p_mask_grid_shift.at({{1u}}); } saw::data> mask_shift; @@ -396,11 +396,14 @@ void couple_particles_to_lattice( }, {{0u,0u}}, p_mask_grid.dims()); saw::data> solid_normal; - { - solid_normal.at({{0u}}).set(1e-3); - } //////////// + bool coll = false; + saw::data> first_index; + saw::data> first_pos; + saw::data>> first_indices; + saw::data>> first_poses; + iterate_over([&](const saw::data>& index){ @@ -411,13 +414,13 @@ void couple_particles_to_lattice( saw::data> index_shift; { index_shift.at({{0u}}) = index.at({0u}).template cast_to() - p_mask_grid_shift.at({{0u}}); - index_shift.at({{1u}}) = index.at({0u}).template cast_to() - p_mask_grid_shift.at({{1u}}); + index_shift.at({{1u}}) = index.at({1u}).template cast_to() - p_mask_grid_shift.at({{1u}}); } saw::data> mask_shift; { mask_shift.at({{0u}}) = index_shift.at({{0u}}) * x_dir.at({0u}) + index_shift.at({{1u}}) * y_dir.at({0u}); - mask_shift.at({{1u}}) = index_shift.at({{0u}}) * x_dir.at({1u}) + index_shift.at({{1u}}) * y_dir.at({1u}); + mask_shift.at({{1u}}) = index_shift.at({{1u}}) * x_dir.at({1u}) + index_shift.at({{1u}}) * y_dir.at({1u}); } auto p_pos_lie = p_pos + mask_shift; @@ -433,6 +436,8 @@ void couple_particles_to_lattice( p_cell_pos.at({{0u}}).set(std::max(1ul, std::min(p_cell_pos.at({{0u}}).get(), meta.at({0u}).get()-2ul))); p_cell_pos.at({{1u}}).set(std::max(1ul, std::min(p_cell_pos.at({{1u}}).get(), meta.at({1u}).get()-2ul))); } + first_indices.add(index); + first_poses.add(p_cell_pos); saw::data> p_vec_cell_pos; { @@ -446,6 +451,12 @@ void couple_particles_to_lattice( auto& cell = latt(p_cell_pos); auto& p_info = cell.template get<"info">()({0u}); if((p_info.get() <= 1u)){ + if(not coll){ + first_index = index; + first_pos = p_cell_pos; + } + coll = true; + // Fake solid normal auto p_pos_rel_vec = p_pos - p_vec_cell_pos.template cast_to(); @@ -457,7 +468,7 @@ void couple_particles_to_lattice( { saw::data> one; - one.at({}) = {10.0f}; + one.at({}) = {1.0f}; p_pos_rel_vec.at({{0u}}) = p_pos_rel_vec.at({{0u}}) * one.at({}); p_pos_rel_vec.at({{1u}}) = p_pos_rel_vec.at({{1u}}) * one.at({}); @@ -518,6 +529,13 @@ void couple_particles_to_lattice( std::cout<<"POS: "< i{0u}; i < first_indices.size(); ++i){ + std::cout<<"Index: "<,sch::D2Q9::D>> macros{dim}; - uint64_t lbm_steps = 8000u; + uint64_t lbm_steps = 10000u; for(uint64_t i = 0u; i < lbm_steps; ++i){ print_progress_bar(i,lbm_steps-1u); bool even_step = ((i % 2u) == 0u); @@ -769,7 +787,7 @@ int main(int argc, char** argv){ } } - couple_particles_to_lattice(particle_sys, lattice, macros, {1u}); + couple_particles_to_lattice(particle_sys, lattice, macros, {i}); particle_sys.step({1u}); lbm_step(lattice, macros, i); } -- cgit v1.2.3