From 7a330f62088f391a6bee12bd703ff10bc11daea2 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Tue, 5 Aug 2025 18:55:34 +0200 Subject: Fixing boundary issues --- c++/boundary.hpp | 12 ++++++++++++ examples/poiseulle_particles_channel_2d.cpp | 25 +++++++++++++++++++++---- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/c++/boundary.hpp b/c++/boundary.hpp index 4c17e3b..3cf6f3f 100644 --- a/c++/boundary.hpp +++ b/c++/boundary.hpp @@ -7,6 +7,12 @@ namespace kel { namespace lbm { namespace cmpt { struct BounceBack {}; + +template +struct ZouHeHorizontal{}; + +template +struct ZouHeVertical{}; } /** @@ -57,5 +63,11 @@ public: } } }; + +template +class component> final { +private: +public: +}; } } diff --git a/examples/poiseulle_particles_channel_2d.cpp b/examples/poiseulle_particles_channel_2d.cpp index 725e008..3ec4f32 100644 --- a/examples/poiseulle_particles_channel_2d.cpp +++ b/examples/poiseulle_particles_channel_2d.cpp @@ -321,6 +321,8 @@ void couple_particles_to_lattice( auto meta = latt.meta(); + using dfi = df_info; + iterate_over([&](const saw::data>& index){ auto& cell = latt(index); auto& info = cell.template get<"info">(); @@ -355,6 +357,7 @@ void couple_particles_to_lattice( }, {{0u,0u}}, p_mask.template get<"grid">().dims()); // Fluid to Particle Coupling + // Prepare force sum iterate_over([&](const saw::data>& index){ saw::data> mask_shift{{ index.at({0u}).template cast_to() * x_dir.at({0u}) + index.at({0u}).template cast_to() * y_dir.at({0u}), @@ -370,9 +373,23 @@ void couple_particles_to_lattice( // Cast down to get lower corner. // Before casting shift by 0.5 for closest pick saw::data> p_cell_pos {{ - static_cast(mask_shift.at({0u}).get()+0.5), - static_cast(mask_shift.at({1u}).get()+0.5) + static_cast(p_pos_lie.at({0u}).get()+0.5), + static_cast(p_pos_lie.at({1u}).get()+0.5) }}; + + 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))); + + for(uint64_t k = 0u; k < sch::D2Q9::Q; ++k){ + + saw::data> n_pcell_pos {{ + p_cell_pos.at({0u}).get() + dfi::directions[k][0], + p_cell_pos.at({1u}).get() + dfi::directions[k][1] + }}; + + //auto n_cell = + } + // Interpolate this from close U cells. // For now pick the closest U auto& closest_u = macros.at(p_cell_pos).template get<"velocity">(); @@ -407,7 +424,7 @@ void lbm_step( component coll{0.5384}; component bb; component> inlet{1.01 * dfi::cs2}; - component> outlet{1.0 * dfi::cs2}; + component> outlet{1.0 * dfi::cs2 * 2.0 / 3.0}; auto meta = latt.meta(); @@ -576,7 +593,7 @@ int main(int argc, char** argv){ p_cell_pos.at({1u}).set(dim.at({1u}).get() - 1u ); } - macros(p_cell_pos).template get<"particle">().set(i.get()); + macros(p_cell_pos).template get<"particle">().set(i.get() + 1u); } { -- cgit v1.2.3