summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudius "keldu" Holeksa <mail@keldu.de>2025-06-27 21:27:20 +0200
committerClaudius "keldu" Holeksa <mail@keldu.de>2025-06-27 21:27:20 +0200
commit5be771eb356263bf43c57056eba77df7235c78f4 (patch)
tree620a74332a95a48e54d602cfc934808a6c26aa6f
parentbffab324ca4d71c0eacb2389f1441638ac465b2e (diff)
Fixing things
-rw-r--r--examples/cavity_2d.cpp26
-rw-r--r--examples/poiseulle_2d.cpp56
2 files changed, 52 insertions, 30 deletions
diff --git a/examples/cavity_2d.cpp b/examples/cavity_2d.cpp
index 6ecdb23..6332bcf 100644
--- a/examples/cavity_2d.cpp
+++ b/examples/cavity_2d.cpp
@@ -52,33 +52,7 @@ using MacroStruct = Struct<
>;
using CavityFieldD2Q9 = CellField<D2Q9, CellStruct<D2Q9>>;
-}
-
-/**
- * Calculates the equilibrium for each direction
- */
-template<typename Desc>
-std::array<typename saw::native_data_type<sch::T>::type,Desc::Q> equilibrium(
- typename saw::native_data_type<sch::T>::type rho,
- const std::array<typename saw::native_data_type<sch::T>::type, Desc::D>& vel
-){
- using dfi = df_info<sch::T, Desc>;
-
- typename std::array<saw::native_data_type<sch::T>::type,Desc::Q> eq;
-
- for(std::size_t i = 0u; i < eq.size(); ++i){
- auto vel_c = (vel[0u]*dfi::directions[i][0u] + vel[1u]*dfi::directions[i][1u]);
- auto vel_c_cs2 = vel_c * dfi::inv_cs2;
- eq[i] = dfi::weights[i] * rho * (
- 1.0
- + vel_c_cs2
- - dfi::inv_cs2 * 0.5 * ( vel[0u] * vel[0u] + vel[1u] * vel[1u] )
- + vel_c_cs2 * vel_c_cs2 * 0.5
- );
- }
- return eq;
-}
/*
template<typename T, typename Encode>
diff --git a/examples/poiseulle_2d.cpp b/examples/poiseulle_2d.cpp
index 0ec4fc0..2f60ffd 100644
--- a/examples/poiseulle_2d.cpp
+++ b/examples/poiseulle_2d.cpp
@@ -44,6 +44,55 @@ using CavityFieldD2Q9 = CellField<D2Q9, CellStruct<D2Q9>>;
}
}
+void set_geometry(saw::data<kel::lbm::sch::CavityFieldD2Q9>& latt){
+ using namespace kel::lbm;
+
+ auto meta = latt.meta();
+ for(saw::data<sch::UInt64> i{0u}; i < meta.at(0u); ++i){
+ for(saw::data<sch::UInt64> j{0u}; j < meta.at(1u); ++j ){
+ auto& cell = latt({{i,j}});
+ auto& info = cell.template get<"info">();
+
+
+ }
+ }
+
+}
+
+void set_initial_conditions(saw::data<kel::lbm::sch::CavityFieldD2Q9>& latt){
+ using namespace kel::lbm;
+
+ typename saw::native_data_type<sch::T>::type rho = 1.0;
+ auto meta = latt.meta();
+
+ // Collide
+ for(saw::data<sch::UInt64> i{0u}; i < meta.at(0u); ++i){
+ for(saw::data<sch::UInt64> j{0u}; j < meta.at(1u); ++j ){
+ auto& cell = latt({{i,j}});
+ auto& info = cell.template get<"info">();
+
+ }
+ }
+ /*
+ {
+ std::array<typename saw::native_data_type<sch::T>::type, sch::D2Q9::D> vel = {0.0, 0.0};
+ auto eq = equilibrium<sch::D2Q9>(rho, vel);
+
+ apply_for_cells([&eq](auto& cell, std::size_t i, std::size_t j){
+ (void) i;
+ (void) j;
+ auto& dfs = cell.template get<"dfs">();
+ auto& dfs_old = cell.template get<"dfs_old">();
+ auto info = cell.template get<"info">()(0u).get();
+ for(uint64_t k = 0; k < sch::D2Q9::Q; ++k){
+ dfs(k).set(eq[k]);
+ dfs_old(k).set(eq[k]);
+ }
+ }, latt);
+ }
+ */
+}
+
int main(int argc, char** argv){
using namespace kel::lbm;
@@ -52,7 +101,7 @@ int main(int argc, char** argv){
cfg_file_name = argv[1];
}
- auto eo_conf = load_lbm_config<sch::Float64,sch::Descriptor<2,9>>(cfg_file_name);
+ auto eo_conf = load_lbm_config<sch::Float64,sch::Descriptor<2u,9u>>(cfg_file_name);
if(eo_conf.is_error()){
auto& err = eo_conf.get_error();
std::cerr<<"[Error]: "<<err.get_category();
@@ -72,10 +121,9 @@ int main(int argc, char** argv){
{conf.template get<"delta_t">()}
};
- print_lbm_meta<sch::Float64,sch::Descriptor<2,9>>(conv, {conf.template get<"kinematic_viscosity">()});
-
- saw::data<sch::FixedArray<sch::UInt64,sch::D2Q9::D>> dim{{128, 128}};
+ print_lbm_meta<sch::Float64,sch::Descriptor<2u,9u>>(conv, {conf.template get<"kinematic_viscosity">()});
+ saw::data<sch::FixedArray<sch::UInt64,sch::D2Q9::D>> dim{{1024, 128}};
saw::data<sch::CavityFieldD2Q9, saw::encode::Native> lattice{dim};
return 0;