From e7f5a1110bfafcd605b9330f9c7d3f5147298ed3 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Wed, 2 Apr 2025 23:36:32 +0200 Subject: Reworking the current structure --- .nix/derivation.nix | 6 +++++- c++/collide_and_stream.h | 6 ------ c++/converter.h | 13 ------------- c++/converter.hpp | 13 +++++++++++++ c++/equilibrium.hpp | 39 +++++++++++++++++++++++++++++++++++++++ c++/geometry.h | 6 ------ c++/lbm_unit.h | 33 --------------------------------- c++/lbm_unit.hpp | 33 +++++++++++++++++++++++++++++++++ 8 files changed, 90 insertions(+), 59 deletions(-) delete mode 100644 c++/collide_and_stream.h delete mode 100644 c++/converter.h create mode 100644 c++/converter.hpp create mode 100644 c++/equilibrium.hpp delete mode 100644 c++/geometry.h delete mode 100644 c++/lbm_unit.h create mode 100644 c++/lbm_unit.hpp diff --git a/.nix/derivation.nix b/.nix/derivation.nix index 7dc7c7f..7ce23e2 100644 --- a/.nix/derivation.nix +++ b/.nix/derivation.nix @@ -7,7 +7,7 @@ stdenv.mkDerivation { pname = "kel-lbm"; - version = "0.0.0"; + version = "0.0.1"; src = ./..; nativeBuildInputs = [ @@ -23,6 +23,10 @@ stdenv.mkDerivation { ]; doCheck = true; + checkPhase = '' + scons test + ./bin/tests + ''; outputs = [ "out" "dev" ]; } diff --git a/c++/collide_and_stream.h b/c++/collide_and_stream.h deleted file mode 100644 index 5cbb551..0000000 --- a/c++/collide_and_stream.h +++ /dev/null @@ -1,6 +0,0 @@ -#pragma once - -namespace kel { -namespace lbm { -} -} diff --git a/c++/converter.h b/c++/converter.h deleted file mode 100644 index bc307f5..0000000 --- a/c++/converter.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once - -#include "lbm_unit.h" - -namespace kel { -namespace lbm { -class converter { -private: -public: - converter() = delete; -}; -} -} diff --git a/c++/converter.hpp b/c++/converter.hpp new file mode 100644 index 0000000..bc307f5 --- /dev/null +++ b/c++/converter.hpp @@ -0,0 +1,13 @@ +#pragma once + +#include "lbm_unit.h" + +namespace kel { +namespace lbm { +class converter { +private: +public: + converter() = delete; +}; +} +} diff --git a/c++/equilibrium.hpp b/c++/equilibrium.hpp new file mode 100644 index 0000000..8342ed4 --- /dev/null +++ b/c++/equilibrium.hpp @@ -0,0 +1,39 @@ +#pragma once + +#include "descriptor.hpp" + +namespace kel { +namespace lbm { +template +saw::data> equilibrium(saw::data rho, saw::data> vel){ + using dfi = df_info; + + saw::data> eq; + saw::data vel_vel{}; + for(uint64_t j = 0u; j < Descriptor::D; ++j){ + vel_vel = vel_vel + vel.at(j) * vel.at(j); + } + + for(uint64_t i = 0u; i < eq.get_dim_size<0u>(); ++i){ + saw::data vel_c{}; + for(uint64_t j = 0u; j < Descriptor::D; ++j){ + vel_c = vel_c + (vel.at(j) * {dfi::directions[i][j]}); + } + + auto vel_c_cs2 = vel_c * {dfi::inv_cs2}; + + eq.at(i).set( + dfi::weights[i] * rho.get() * + ( + 1.0 + + vel_c_cs2 + - dfi::inv_cs2 * 0.5 * vel_vel.get() + + vel_c_cs2 * vel_c_cs2 * 0.5 + ) + ); + + return eq; + } +} +} +} diff --git a/c++/geometry.h b/c++/geometry.h deleted file mode 100644 index 5cbb551..0000000 --- a/c++/geometry.h +++ /dev/null @@ -1,6 +0,0 @@ -#pragma once - -namespace kel { -namespace lbm { -} -} diff --git a/c++/lbm_unit.h b/c++/lbm_unit.h deleted file mode 100644 index c4d09f6..0000000 --- a/c++/lbm_unit.h +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once - -#include - -#include - -namespace kel { -namespace lbm { -namespace lbm_type { -struct meter { - static constexpr std::string_view name = "meter_l"; - static constexpr std::string_view short_name = "m_l"; -}; - -struct second { - static constexpr std::string_view name = "second_l"; - static constexpr std::string_view short_name = "s_l"; -}; -} - -template -using lbm_meter = unit>; - -template -using lbm_second = unit>; - -template -using lbm_velocity = unit, unit_component>; - -template -using lbm_acceleration = unit, unit_component>; -} -} diff --git a/c++/lbm_unit.hpp b/c++/lbm_unit.hpp new file mode 100644 index 0000000..c4d09f6 --- /dev/null +++ b/c++/lbm_unit.hpp @@ -0,0 +1,33 @@ +#pragma once + +#include + +#include + +namespace kel { +namespace lbm { +namespace lbm_type { +struct meter { + static constexpr std::string_view name = "meter_l"; + static constexpr std::string_view short_name = "m_l"; +}; + +struct second { + static constexpr std::string_view name = "second_l"; + static constexpr std::string_view short_name = "s_l"; +}; +} + +template +using lbm_meter = unit>; + +template +using lbm_second = unit>; + +template +using lbm_velocity = unit, unit_component>; + +template +using lbm_acceleration = unit, unit_component>; +} +} -- cgit v1.2.3