From 803bf67093d621509d4d8d4af326fa2c66c299bc Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Sat, 4 Jul 2026 21:58:38 +0200 Subject: Dangling changes --- examples/poiseulle_particles_2d_fplbm_gpu/sim.cpp | 21 ------------------- examples/stokes_drag_particle_2d_bgk_gpu/sim.cpp | 21 +++++++------------ examples/stokes_drag_particle_2d_fplbm_gpu/sim.cpp | 24 ++++++++++++++++++---- lib/core/c++/abstract/templates.hpp | 3 ++- lib/core/c++/environment.hpp | 5 ++++- lib/core/tests/particles.cpp | 4 ++-- scripts/python/csv_magnitude_sum.py | 19 +++++++++++++++++ 7 files changed, 54 insertions(+), 43 deletions(-) create mode 100755 scripts/python/csv_magnitude_sum.py diff --git a/examples/poiseulle_particles_2d_fplbm_gpu/sim.cpp b/examples/poiseulle_particles_2d_fplbm_gpu/sim.cpp index 3d16884..c6aac92 100644 --- a/examples/poiseulle_particles_2d_fplbm_gpu/sim.cpp +++ b/examples/poiseulle_particles_2d_fplbm_gpu/sim.cpp @@ -145,27 +145,6 @@ saw::error_or setup_initial_conditions( {{1u,1u}} ); - /* - iterator::apply( - [&](auto& index){ - saw::data> middle, ind_vec; - middle.at({{0u}}) = dim_x * 0.25; - middle.at({{1u}}) = dim_y * 0.5; - - ind_vec.at({{0u}}) = index.at({{0u}}).template cast_to(); - ind_vec.at({{1u}}) = index.at({{1u}}).template cast_to(); - - auto dist = middle - ind_vec; - auto dist_2 = saw::math::dot(dist,dist); - if(dist_2.at({}).get() < dim_y*dim_y*0.01){ - porous_f.at(index).at({}) = 1.0; - } - }, - {},// 0-index - df_f.get_dims() - ); - */ - return saw::make_void(); } diff --git a/examples/stokes_drag_particle_2d_bgk_gpu/sim.cpp b/examples/stokes_drag_particle_2d_bgk_gpu/sim.cpp index 911d84a..9426371 100644 --- a/examples/stokes_drag_particle_2d_bgk_gpu/sim.cpp +++ b/examples/stokes_drag_particle_2d_bgk_gpu/sim.cpp @@ -10,8 +10,8 @@ namespace kel { namespace lbm { -constexpr uint64_t dim_y = 256ul; -constexpr uint64_t dim_x = dim_y * 20ul; +constexpr uint64_t dim_y = 1024ul; +constexpr uint64_t dim_x = dim_y * 2ul; constexpr uint64_t particle_amount = 1ul; @@ -50,8 +50,7 @@ using ForceChunk = Chunk, 0u, dim_x, dim_y>; template using MacroStruct = Struct< Member, "velocity">, - Member, "density">, - Member, "porosity"> + Member, "density"> >; //template @@ -66,7 +65,6 @@ saw::error_or setup_initial_conditions( saw::data>& macros ){ auto& info_f = fields.template get<"info">(); - auto& porous_f = macros.template get<"porosity">(); // Set everything as walls iterator::apply( [&](auto& index){ @@ -109,13 +107,11 @@ saw::error_or setup_initial_conditions( auto& df_f = fields.template get<"dfs_old">(); auto& rho_f = macros.template get<"density">(); auto& vel_f = macros.template get<"velocity">(); - auto& por_f = macros.template get<"porosity">(); iterator::apply( [&](auto& index){ auto& df = df_f.at(index); auto& rho = rho_f.at(index); - por_f.at(index).at({}) = {0}; rho.at({}) = {1}; auto& vel = vel_f.at(index); auto eq = equilibrium(rho,vel); @@ -144,11 +140,10 @@ saw::error_or setup_initial_conditions( {{1u,1u}} ); - /* iterator::apply( [&](auto& index){ saw::data> middle, ind_vec; - middle.at({{0u}}) = dim_x * 0.25; + middle.at({{0u}}) = dim_x * 0.5; middle.at({{1u}}) = dim_y * 0.5; ind_vec.at({{0u}}) = index.at({{0u}}).template cast_to(); @@ -156,14 +151,13 @@ saw::error_or setup_initial_conditions( auto dist = middle - ind_vec; auto dist_2 = saw::math::dot(dist,dist); - if(dist_2.at({}).get() < dim_y*dim_y*0.01){ - porous_f.at(index).at({}) = 1.0; + if(dist_2.at({}).get() < dim_y*dim_y*0.01 / 16.0){ + info_f.at(index).set(5u); } }, {},// 0-index df_f.get_dims() ); - */ return saw::make_void(); } @@ -177,7 +171,6 @@ saw::error_or step( ){ auto& q = dev.get_handle(); auto& info_f = fields.template get<"info">(); - auto& porous_f = macros.template get<"porosity">(); // auto coll_ev = q.submit([&](acpp::sycl::handler& h){ @@ -192,7 +185,7 @@ saw::error_or step( rad.at({}).set(dim_y*0.1); saw::data> p_pos; { - p_pos.at({{0u}}) = dim_x * 0.25; + p_pos.at({{0u}}) = dim_x * 0.5; p_pos.at({{1u}}) = dim_y * 0.5; } component> opa{p_pos,rad,eps}; diff --git a/examples/stokes_drag_particle_2d_fplbm_gpu/sim.cpp b/examples/stokes_drag_particle_2d_fplbm_gpu/sim.cpp index 17df764..78e7ba5 100644 --- a/examples/stokes_drag_particle_2d_fplbm_gpu/sim.cpp +++ b/examples/stokes_drag_particle_2d_fplbm_gpu/sim.cpp @@ -10,8 +10,8 @@ namespace kel { namespace lbm { -constexpr uint64_t dim_y = 256ul; -constexpr uint64_t dim_x = dim_y * 20ul; +constexpr uint64_t dim_y = 1024ul; +constexpr uint64_t dim_x = dim_y * 2ul; constexpr uint64_t particle_amount = 1ul; @@ -86,7 +86,23 @@ saw::error_or setup_initial_conditions( info_f.get_dims(), {{1u,1u}} ); - + // Corners + /// Inflow + iterator::apply( + [&](auto& index){ + info_f.at(index).set(5u); + }, + {{0u,0u}}, + {{1u,dim_y}} + ); + /// Outflow + iterator::apply( + [&](auto& index){ + info_f.at(index).set(5u); + }, + {{dim_x-1u,0u}}, + {{dim_x, dim_y}} + ); // Inflow iterator::apply( [&](auto& index){ @@ -193,7 +209,7 @@ saw::error_or step( rad.at({}).set(dim_y*0.1); saw::data> p_pos; { - p_pos.at({{0u}}) = dim_x * 0.25; + p_pos.at({{0u}}) = dim_x * 0.5; p_pos.at({{1u}}) = dim_y * 0.5; } component> opa{p_pos,rad,eps}; diff --git a/lib/core/c++/abstract/templates.hpp b/lib/core/c++/abstract/templates.hpp index f675a99..d9d9faa 100644 --- a/lib/core/c++/abstract/templates.hpp +++ b/lib/core/c++/abstract/templates.hpp @@ -2,6 +2,7 @@ namespace kel { namespace lbm { - +template +constexpr bool always_false = false; } } diff --git a/lib/core/c++/environment.hpp b/lib/core/c++/environment.hpp index 27d8f3a..d8aa9ae 100644 --- a/lib/core/c++/environment.hpp +++ b/lib/core/c++/environment.hpp @@ -8,11 +8,13 @@ namespace kel { namespace lbm { struct environment { + std::string name; + std::filesystem::path lbm_dir; std::filesystem::path data_dir; }; -saw::error_or lbm_directory(){ +saw::error_or setup_lbm_env(const std::string_view name){ namespace fs = std::filesystem; const char* home_dir = std::getenv("HOME"); @@ -25,6 +27,7 @@ saw::error_or lbm_directory(){ env.lbm_dir = std::filesystem::path{home_dir} / ".lbm"; { + // Set default data location to "${lbm_dir}/data" env.data_dir = env.lbm_dir / "data"; // LBM Data Location auto lbm_dir_config = env.lbm_dir / "data_dir_location.txt"; diff --git a/lib/core/tests/particles.cpp b/lib/core/tests/particles.cpp index de9477c..133c343 100644 --- a/lib/core/tests/particles.cpp +++ b/lib/core/tests/particles.cpp @@ -273,9 +273,9 @@ SAW_TEST("Verlet integration test 2D"){ } */ -SAW_TEST("Particle / AABB"){ +SAW_TEST("Spheroid Particle / AABB"){ using namespace kel; - + } } diff --git a/scripts/python/csv_magnitude_sum.py b/scripts/python/csv_magnitude_sum.py new file mode 100755 index 0000000..773ce52 --- /dev/null +++ b/scripts/python/csv_magnitude_sum.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python3 + +import argparse +import numpy as np + + +def main(): + parser = argparse.ArgumentParser(description="Compute the sum of magnitude"); + parser.add_argument("one"); + args = parser.parse_args(); + + a = np.loadtxt(args.one, delimiter=","); + + print(np.sum(np.linalg.norm(a,axis=1))); +#enddef + +if __name__ == "__main__": + main(); +#enddef -- cgit v1.2.3 From 360bd807b005531d53f5cf5a702535867b4d9d0f Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Sat, 4 Jul 2026 22:17:47 +0200 Subject: Png module? --- lib/png/.nix/derivation.nix | 38 +++++++++++++++++++++++ lib/png/SConstruct | 75 +++++++++++++++++++++++++++++++++++++++++++++ lib/png/c++/SConscript | 27 ++++++++++++++++ lib/png/c++/png.cpp | 1 + lib/png/c++/png.hpp | 7 +++++ 5 files changed, 148 insertions(+) create mode 100644 lib/png/.nix/derivation.nix create mode 100644 lib/png/SConstruct create mode 100644 lib/png/c++/SConscript create mode 100644 lib/png/c++/png.cpp create mode 100644 lib/png/c++/png.hpp diff --git a/lib/png/.nix/derivation.nix b/lib/png/.nix/derivation.nix new file mode 100644 index 0000000..6e52083 --- /dev/null +++ b/lib/png/.nix/derivation.nix @@ -0,0 +1,38 @@ +{ lib +, stdenv +, scons +, clang-tools +, pname +, version +, forstio +, kel-lbm +, adaptive-cpp +}: + +stdenv.mkDerivation { + pname = "${pname}-png"; + inherit version; + src = ./..; + + nativeBuildInputs = [ + scons + clang-tools + ]; + + buildInputs = [ + forstio.core + forstio.async + forstio.codec + kel-lbm.core + ]; + + doCheck = true; + checkPhase = '' + scons test + ./bin/tests + ''; + + preferLocalBuild = true; + + outputs = [ "out" "dev" ]; +} diff --git a/lib/png/SConstruct b/lib/png/SConstruct new file mode 100644 index 0000000..8b3ab01 --- /dev/null +++ b/lib/png/SConstruct @@ -0,0 +1,75 @@ +#!/usr/bin/env python3 + +import sys +import os +import os.path +import glob +import re + + +if sys.version_info < (3,): + def isbasestring(s): + return isinstance(s,basestring) +else: + def isbasestring(s): + return isinstance(s, (str,bytes)) + +def add_kel_source_files(self, sources, filetype, lib_env=None, shared=False, target_post=""): + + if isbasestring(filetype): + dir_path = self.Dir('.').abspath + filetype = sorted(glob.glob(dir_path+"/"+filetype)) + + for path in filetype: + target_name = re.sub( r'(.*?)(\.cpp|\.c\+\+)', r'\1' + target_post, path ) + if shared: + target_name+='.os' + sources.append( self.SharedObject( target=target_name, source=path ) ) + else: + target_name+='.o' + sources.append( self.StaticObject( target=target_name, source=path ) ) + pass + +def isAbsolutePath(key, dirname, env): + assert os.path.isabs(dirname), "%r must have absolute path syntax" % (key,) + +env_vars = Variables( + args=ARGUMENTS +) + +env_vars.Add('prefix', + help='Installation target location of build results and headers', + default='/usr/local/', + validator=isAbsolutePath +) + +env=Environment(ENV=os.environ, variables=env_vars, CPPPATH=[], + CPPDEFINES=['SAW_UNIX'], + CXXFLAGS=[ + '-std=c++20', + '-g', + '-Wall', + '-Wextra' + ], + LIBS=[ + 'forstio-core' + ] +); +env.__class__.add_source_files = add_kel_source_files +env.Tool('compilation_db'); +env.cdb = env.CompilationDatabase('compile_commands.json'); + +env.objects = []; +env.sources = []; +env.headers = []; +env.targets = []; + +Export('env') +SConscript('c++/SConscript') +SConscript('tests/SConscript') + +env.Alias('cdb', env.cdb); +env.Alias('all', [env.targets]); +env.Default('all'); + +env.Alias('install', '$prefix') diff --git a/lib/png/c++/SConscript b/lib/png/c++/SConscript new file mode 100644 index 0000000..75b8645 --- /dev/null +++ b/lib/png/c++/SConscript @@ -0,0 +1,27 @@ +#!/bin/false + +import os +import os.path +import glob + + +Import('env') + +dir_path = Dir('.').abspath + +# Environment for base library +png_env = env.Clone(); + +png_env.sources = sorted(glob.glob(dir_path + "/*.cpp")); +png_env.headers = sorted(glob.glob(dir_path + "/*.hpp")); + +env.sources += png_env.sources; +env.headers += png_env.headers; + +## Static lib +objects = [] +png_env.add_source_files(objects, png_env.sources, shared=False); +env.library_static = png_env.StaticLibrary('#build/kel-lbm-png', [objects]); + +env.Install('$prefix/lib/', env.library_static); +env.Install('$prefix/include/kel/lbm/png/', png_env.headers); diff --git a/lib/png/c++/png.cpp b/lib/png/c++/png.cpp new file mode 100644 index 0000000..248a8a5 --- /dev/null +++ b/lib/png/c++/png.cpp @@ -0,0 +1 @@ +#include "png.hpp" diff --git a/lib/png/c++/png.hpp b/lib/png/c++/png.hpp new file mode 100644 index 0000000..f675a99 --- /dev/null +++ b/lib/png/c++/png.hpp @@ -0,0 +1,7 @@ +#pragma once + +namespace kel { +namespace lbm { + +} +} -- cgit v1.2.3 From 7c2b3e234409da04d2bf943c35a83e4a8f049e8d Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Sat, 4 Jul 2026 22:18:11 +0200 Subject: hlbm momentum? --- lib/core/c++/hlbm.hpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/core/c++/hlbm.hpp b/lib/core/c++/hlbm.hpp index 726f2d8..df6f173 100644 --- a/lib/core/c++/hlbm.hpp +++ b/lib/core/c++/hlbm.hpp @@ -14,6 +14,8 @@ namespace cmpt { struct HlbmInit {}; struct Hlbm {}; struct HlbmParticle {}; + +struct HlbmOneParticleMomentumExchange {}; } template @@ -153,5 +155,14 @@ public: } }; + +template +class component final { +public: + template + void apply(const saw::data& field, const saw::data& macros, const saw::data& part_group, saw::data> index, saw::data time_step) const { + // + } +}; } } -- cgit v1.2.3 From 275ded2ed5a5bdb92c78a801e40926fc000fb25b Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Sat, 4 Jul 2026 22:21:37 +0200 Subject: Hlbm prep momentum fix --- lib/core/c++/hlbm.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/core/c++/hlbm.hpp b/lib/core/c++/hlbm.hpp index df6f173..18c32a5 100644 --- a/lib/core/c++/hlbm.hpp +++ b/lib/core/c++/hlbm.hpp @@ -157,7 +157,7 @@ public: }; template -class component final { +class component final { public: template void apply(const saw::data& field, const saw::data& macros, const saw::data& part_group, saw::data> index, saw::data time_step) const { -- cgit v1.2.3