summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudius "keldu" Holeksa <mail@keldu.de>2025-04-02 23:36:32 +0200
committerClaudius "keldu" Holeksa <mail@keldu.de>2025-04-02 23:36:32 +0200
commite7f5a1110bfafcd605b9330f9c7d3f5147298ed3 (patch)
tree7825d5b93a1d7c8d1b9eba871bf4513fcc0e88cf
parent98c91326f5952e951247b42299a2a56515603025 (diff)
Reworking the current structure
-rw-r--r--.nix/derivation.nix6
-rw-r--r--c++/collide_and_stream.h6
-rw-r--r--c++/converter.hpp (renamed from c++/converter.h)0
-rw-r--r--c++/equilibrium.hpp39
-rw-r--r--c++/geometry.h6
-rw-r--r--c++/lbm_unit.hpp (renamed from c++/lbm_unit.h)0
6 files changed, 44 insertions, 13 deletions
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.hpp
index bc307f5..bc307f5 100644
--- a/c++/converter.h
+++ b/c++/converter.hpp
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<typename T, typename Descriptor>
+saw::data<sch::FixedArray<T, Descriptor::Q>> equilibrium(saw::data<sch::T> rho, saw::data<sch::FixedArray<T,Descriptor::D>> vel){
+ using dfi = df_info<T, Descriptor>;
+
+ saw::data<sch::FixedArray<T,Descriptor::Q>> eq;
+ saw::data<T> 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<T> 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.hpp
index c4d09f6..c4d09f6 100644
--- a/c++/lbm_unit.h
+++ b/c++/lbm_unit.hpp