From 7abcc7c96ce891128858089e34afc2e986b1ab19 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Mon, 3 Mar 2025 14:01:10 +0100 Subject: wip --- .nix/derivation.nix | 3 +-- c++/descriptor.h | 15 +++++++-------- c++/examples/cavity_2d.cpp | 46 ++++++++++++++++++++++++---------------------- default.nix | 11 +---------- 4 files changed, 33 insertions(+), 42 deletions(-) diff --git a/.nix/derivation.nix b/.nix/derivation.nix index 895a2f2..b328e56 100644 --- a/.nix/derivation.nix +++ b/.nix/derivation.nix @@ -3,7 +3,6 @@ , scons , clang-tools , forstio -, kel-unit }: stdenv.mkDerivation { @@ -20,7 +19,7 @@ stdenv.mkDerivation { forstio.core forstio.async forstio.codec - kel-unit + forstio.codec-unit ]; outputs = [ "out" "dev" ]; diff --git a/c++/descriptor.h b/c++/descriptor.h index e1be1e9..0752a51 100644 --- a/c++/descriptor.h +++ b/c++/descriptor.h @@ -7,19 +7,19 @@ namespace lbm { namespace sch { using namespace saw::schema; -template +template struct Descriptor { - static constexpr uint64_t D = D; - static constexpr uint64_t Q = Q; + static constexpr uint64_t D = DV; + static constexpr uint64_t Q = QV; }; -template +template struct Field { using Alias = Sch; using Descriptor = Desc; - static constexpr uint64_t SC = SC; - static constexpr uint64_t DC = DC; - static constexpr uint64_t QC = QC; + static constexpr uint64_t SC = SC_V; + static constexpr uint64_t DC = DC_V; + static constexpr uint64_t QC = QC_V; }; /** @@ -29,7 +29,6 @@ template using CellData = Struct< CellT... >; -^ /** * T is an array of CellData */ diff --git a/c++/examples/cavity_2d.cpp b/c++/examples/cavity_2d.cpp index aaf6ba3..90799ad 100644 --- a/c++/examples/cavity_2d.cpp +++ b/c++/examples/cavity_2d.cpp @@ -6,7 +6,8 @@ namespace kel { namespace lbm { -namespace schema { +namespace sch { +using namespace saw::schema; /** * Basic distribution function @@ -18,6 +19,7 @@ namespace schema { * Q factor */ using T = Float32; +using D2Q5 = Descriptor<2,5>; using DfCell2D = Field; using CellInfo2D = Field; @@ -34,7 +36,7 @@ using Cell = CellData< template struct cell_type { - using Type = schema::Field; + using Type = sch::Field; }; template @@ -44,11 +46,11 @@ class df_cell_view; * Minor helper for the AA-Pull Pattern */ template -class df_cell_view> { +class df_cell_view> { private: - std::array::type>*, QN> view_; + std::array::type>*, QN> view_; public: - df_cell_view(const std::array::type>*, QN>& view): + df_cell_view(const std::array::type>*, QN>& view): view_{view} {} }; @@ -56,15 +58,15 @@ public: template class collision { public: - typename saw::native_data_type::type relaxation_; + typename saw::native_data_type::type relaxation_; public: - std::array::type,Desc::Q> equilibrium( - typename saw::native_data_type::type rho, - std::array::type, Desc::D> vel + std::array::type,Desc::Q> equilibrium( + typename saw::native_data_type::type rho, + std::array::type, Desc::D> vel ){ - using dfi = df_info; + using dfi = df_info; - typename std::array::type,Desc::Q> eq; + typename std::array::type,Desc::Q> eq; for(std::size_t i = 0; i < eq.size(); ++i){ auto vel_c = (vel[0]*dfi::directions[i][0] + vel[1]*dfi::directions[i][1]); @@ -82,15 +84,15 @@ public: void compute_rho_u( saw::data& dfs, - typename saw::native_data_type::type& rho, - std::array::type, 2>& vel + typename saw::native_data_type::type& rho, + std::array::type, 2>& vel ){ - using dfi = df_info>; + using dfi = df_info; rho = 0; std::fill(vel.begin(), vel.end(), 0); - for(size_t i = 0; i < Q; ++i){ + for(size_t i = 0; i < Desc::Q; ++i){ rho += dfs.at(i).get(); vel[0] += dfi::directions[i][0] * dfs.at(i).get(); vel[1] += dfi::directions[i][1] * dfs.at(i).get(); @@ -120,7 +122,7 @@ struct rectangle { }; template -void apply_for_cells(Func&& func, saw::data>& dat){ +void apply_for_cells(Func&& func, saw::data>& dat){ for(std::size_t i = 0; i < dat.get_dim_size(0); ++i){ for(std::size_t j = 0; j < dat.get_dim_size(1); ++j){ func(dat.at(i,j), i, j); @@ -128,7 +130,7 @@ void apply_for_cells(Func&& func, saw::data>& da } } -void set_geometry(saw::data>& latt){ +void set_geometry(saw::data>& latt){ using namespace kel::lbm; apply_for_cells([](auto& cell, std::size_t i, std::size_t j){ uint8_t val = 0; @@ -145,7 +147,7 @@ void set_geometry(saw::data> }, latt); } -void set_initial_conditions(saw::data>& latt){ +void set_initial_conditions(saw::data>& latt){ using namespace kel::lbm; apply_for_cells([](auto& cell, std::size_t i, std::size_t j){ (void) i; @@ -155,8 +157,8 @@ void set_initial_conditions(saw::data>& old_latt, - saw::data>& new_latt + saw::data>& old_latt, + saw::data>& new_latt ){ } @@ -165,8 +167,8 @@ int main(){ using namespace kel::lbm; saw::data< - schema::FixedArray< - schema::Lattice, 2 + sch::FixedArray< + sch::Lattice, 2 > ,saw::encode::Native > lattices; //{dim_x, dim_y}; diff --git a/default.nix b/default.nix index 2ed8c2a..d92720d 100644 --- a/default.nix +++ b/default.nix @@ -1,5 +1,5 @@ { pkgs ? import {} -, stdenv ? pkgs.stdenv +, stdenv ? pkgs.llvmPackages_19.stdenv , clang-tools ? pkgs.clang-tools_16 }: @@ -12,17 +12,8 @@ let inherit clang-tools; }).forstio; - kel-unit = (import ((builtins.fetchGit { - url = "git@git.keldu.de:libs/unit"; - ref = "dev"; - }).outPath + "/default.nix"){ - inherit stdenv; - inherit clang-tools; - }); - in pkgs.callPackage ./.nix/derivation.nix { inherit forstio; - inherit kel-unit; inherit stdenv; inherit clang-tools; } -- cgit v1.2.3