diff options
author | Claudius "keldu" Holeksa <mail@keldu.de> | 2025-08-30 11:25:09 +0200 |
---|---|---|
committer | Claudius "keldu" Holeksa <mail@keldu.de> | 2025-08-30 11:25:09 +0200 |
commit | 1fbfad0b44b5a3689d54d2b43940e94388b90803 (patch) | |
tree | 480d66bca3a117e520aced26c4e3ebc7f9bc1ff9 | |
parent | f17796404c1b0c4817e7232ba16dc667df9d7f68 (diff) |
Adding dangling changes
-rw-r--r-- | c++/converter.hpp | 16 | ||||
-rw-r--r-- | c++/particle/geometry/.circle.hpp.kate-swp | bin | 0 -> 62 bytes | |||
-rw-r--r-- | default.nix | 2 | ||||
-rw-r--r-- | examples/poiseulle_particles_channel_2d.cpp | 40 | ||||
-rw-r--r-- | tests/converter.cpp | 1 |
5 files changed, 44 insertions, 15 deletions
diff --git a/c++/converter.hpp b/c++/converter.hpp index 6e0a7a6..5c19c68 100644 --- a/c++/converter.hpp +++ b/c++/converter.hpp @@ -1,10 +1,18 @@ #pragma once #include "lbm_unit.hpp" +#include "descriptor.hpp" namespace kel { namespace lbm { +namespace sch { +using namespace saw::schema; +} + +/** + * Helps converting from SI types to LBM types + */ template<typename T> class converter { private: @@ -59,9 +67,13 @@ public: } saw::data<sch::LbmKinematicViscosity<T>> kinematic_viscosity_si_to_lbm (const saw::data<sch::SiKinematicViscosity<T>>& kin_si) const { - return kin_si / (meter_conv_ * meter_conv_) * second_conv_; + return (kin_si / (meter_conv_ * meter_conv_)) * second_conv_; } -}; + template<typename Desc> + saw::data<sch::Pure<T>> kinematic_viscosity_si_to_tau(const saw::data<sch::SiKinematicViscosity<T>>& kin_si) const { + return saw::data<sch::Pure<T>>{saw::data<typename saw::unit_division<sch::Pure<T>, sch::LbmKinematicViscosity<T>>::Schema >{df_info<T,Desc>::inv_cs2} * kinematic_viscosity_si_to_lbm(kin_si) + saw::data<sch::Pure<T>>{0.5}}; + } +}; } } diff --git a/c++/particle/geometry/.circle.hpp.kate-swp b/c++/particle/geometry/.circle.hpp.kate-swp Binary files differnew file mode 100644 index 0000000..b28db57 --- /dev/null +++ b/c++/particle/geometry/.circle.hpp.kate-swp diff --git a/default.nix b/default.nix index d92720d..883b70e 100644 --- a/default.nix +++ b/default.nix @@ -1,6 +1,6 @@ { pkgs ? import <nixpkgs> {} , stdenv ? pkgs.llvmPackages_19.stdenv -, clang-tools ? pkgs.clang-tools_16 +, clang-tools ? pkgs.clang-tools_19 }: let diff --git a/examples/poiseulle_particles_channel_2d.cpp b/examples/poiseulle_particles_channel_2d.cpp index f6a5dd0..e2d7200 100644 --- a/examples/poiseulle_particles_channel_2d.cpp +++ b/examples/poiseulle_particles_channel_2d.cpp @@ -9,7 +9,6 @@ #include <cmath> - namespace kel { namespace lbm { namespace sch { @@ -619,7 +618,7 @@ int main(int argc, char** argv){ uint64_t lbm_steps = 4096u * 4u; for(uint64_t i = 0u; i < lbm_steps; ++i){ - print_progress_bar(i+1u,lbm_steps); + print_progress_bar(i,lbm_steps-1u); bool even_step = ((i % 2u) == 0u); { @@ -642,20 +641,39 @@ int main(int argc, char** argv){ auto& p_rb = p.template get<"rigid_body">(); auto& p_pos = p_rb.template get<"position">(); + auto& p_mask = p_rb.template get<"mask">(); + auto& p_mask_grid = p_mask.template get<"grid">(); + auto p_mask_grid_dims = p_mask_grid.dims(); + + saw::data<sch::Vector<sch::T,2u>> p_mask_grid_shift; + p_mask_grid_shift.at({{0u}}) = (p_mask_grid_dims.at({0u}).template cast_to<sch::T>() - 1.0) / 2.0; + p_mask_grid_shift.at({{1u}}) = (p_mask_grid_dims.at({1u}).template cast_to<sch::T>() - 1.0) / 2.0; + auto p_pos_lie = p_pos + mask_shift; + + // Cast down to get lower corner. + // Before casting shift by 0.5 for closest pick saw::data<sch::FixedArray<sch::UInt64,2u>> p_cell_pos {{ - static_cast<uint64_t>(p_pos.at({{0u}}).get()+0.5), - static_cast<uint64_t>(p_pos.at({{1u}}).get()+0.5) + static_cast<uint64_t>(p_pos_lie.at({{0u}}).get()+0.5), + static_cast<uint64_t>(p_pos_lie.at({{1u}}).get()+0.5) }}; - if(p_cell_pos.at({0u}) >= dim.at({0u}) ){ - p_cell_pos.at({0u}).set(dim.at({0u}).get() - 1u ); - } - if(p_cell_pos.at({1u}) >= dim.at({1u}) ){ - p_cell_pos.at({1u}).set(dim.at({1u}).get() - 1u ); - } + // Iterate + iterate_over([&](const saw::data<sch::FixedArray<sch::UInt64,2u>>& index){ + + saw::data<sch::Vector<sch::T,2u>> index_shift; + index_shift.at({{0u}}) = index.at({0u}).template cast_to<sch::T>() - p_mask_grid_shift.at({{0u}}); + index_shift.at({{1u}}) = index.at({0u}).template cast_to<sch::T>() - p_mask_grid_shift.at({{1u}}); + + if(p_cell_pos.at({0u}) >= dim.at({0u}) ){ + p_cell_pos.at({0u}).set(dim.at({0u}).get() - 1u ); + } + if(p_cell_pos.at({1u}) >= dim.at({1u}) ){ + p_cell_pos.at({1u}).set(dim.at({1u}).get() - 1u ); + } - macros(p_cell_pos).template get<"particle">().set(i.get() + 1u); + macros(p_cell_pos).template get<"particle">().set(i.get() + 1u); + }, {{0u,0u}}, p_mask_grid_dims); } { diff --git a/tests/converter.cpp b/tests/converter.cpp index d7f3d67..4fc536f 100644 --- a/tests/converter.cpp +++ b/tests/converter.cpp @@ -21,7 +21,6 @@ SAW_TEST("Si Meter to Lbm Meter"){ saw::data<sch::SiMeter<sch::T>> si_m{1.0}; auto lbm_m = converter.meter_si_to_lbm(si_m); - SAW_EXPECT(lbm_m.handle().get() == 10.0, "Correct si to lbm conversion"); } } |