summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudius "keldu" Holeksa <mail@keldu.de>2025-11-11 15:51:01 +0100
committerClaudius "keldu" Holeksa <mail@keldu.de>2025-11-11 15:51:01 +0100
commit40d2986127a3efe62f4f5d7c0b401ecb1296912b (patch)
treec4e087eb7845efdf6809eae1b513655000cb7a08
parent7b3cc7174856a6ae72fe2e037814a5312d429d74 (diff)
downloadlibs-lbm-40d2986127a3efe62f4f5d7c0b401ecb1296912b.tar.gz
Dangling changes and shenanigans
-rw-r--r--.gitignore3
-rw-r--r--examples/poiseulle_3d/poiseulle_3d.cpp12
-rw-r--r--examples/wind_wheel_3d/.nix/derivation.nix38
-rw-r--r--examples/wind_wheel_3d/SConscript34
-rw-r--r--examples/wind_wheel_3d/SConstruct82
-rw-r--r--examples/wind_wheel_3d/wind_wheel_3d.cpp33
6 files changed, 196 insertions, 6 deletions
diff --git a/.gitignore b/.gitignore
index d3d9200..05bedeb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,3 +7,6 @@ log
tmp
vgcore.*
*.kate-swp
+.sconsign.dblite
+.cache
+compile_commands.json
diff --git a/examples/poiseulle_3d/poiseulle_3d.cpp b/examples/poiseulle_3d/poiseulle_3d.cpp
index 707212d..83d1af1 100644
--- a/examples/poiseulle_3d/poiseulle_3d.cpp
+++ b/examples/poiseulle_3d/poiseulle_3d.cpp
@@ -294,8 +294,8 @@ saw::error_or<void> lbm_step(
using dfi = df_info<sch::T,sch::Desc>;
bool even_step = ((time_step.get() % 2u) == 0u);
- component<sch::T, sch::Desc, cmpt::BGK, saw::encode::Sycl<saw::encode::Native>> coll{0.5384};
- component<sch::T, sch::Desc, cmpt::BounceBack, saw::encode::Sycl<saw::encode::Native>> bb;
+ component<sch::T, sch::Desc, cmpt::BGK, saw::encode::Native> coll{0.5384};
+ component<sch::T, sch::Desc, cmpt::BounceBack, saw::encode::Native> bb;
/**
* Collision
@@ -307,11 +307,11 @@ saw::error_or<void> lbm_step(
switch(info({0u}).get()){
case 1u: {
- bb.apply(latt, index, time_step);
+ bb.apply(&latt[0u], meta, index, time_step);
break;
}
case 2u: {
- coll.apply(latt, index, time_step);
+ coll.apply(&latt[0u], meta, index, time_step);
break;
}
case 3u: {
@@ -326,7 +326,7 @@ saw::error_or<void> lbm_step(
break;
}
- }, {{0u,0u}}, meta);
+ }, {}, meta);
// Stream
iterator<sch::Desc::D>::apply([&](const saw::data<sch::FixedArray<sch::UInt64,sch::Desc::D>>& index){
@@ -351,7 +351,7 @@ saw::error_or<void> lbm_step(
df_new({k}) = df_old({k});
}
}
- }, {{0u,0u}}, meta);
+ }, {}, meta);
return saw::make_void();
}
diff --git a/examples/wind_wheel_3d/.nix/derivation.nix b/examples/wind_wheel_3d/.nix/derivation.nix
new file mode 100644
index 0000000..eb13bc3
--- /dev/null
+++ b/examples/wind_wheel_3d/.nix/derivation.nix
@@ -0,0 +1,38 @@
+{ lib
+, stdenv
+, scons
+, clang-tools
+, forstio
+, pname
+, version
+, kel-lbm
+}:
+
+stdenv.mkDerivation {
+ pname = pname + "-examples-" + "wind_wheel_3d";
+ inherit version;
+ src = ./..;
+
+ nativeBuildInputs = [
+ scons
+ clang-tools
+ ];
+
+ buildInputs = [
+ forstio.core
+ forstio.async
+ forstio.io
+ forstio.io_codec
+ forstio.codec
+ forstio.codec-unit
+ forstio.codec-json
+ forstio.remote
+ forstio.remote-filesystem
+ forstio.remote-io
+ kel-lbm
+ ];
+
+ preferLocalBuild = true;
+
+ outputs = [ "out" "dev" ];
+}
diff --git a/examples/wind_wheel_3d/SConscript b/examples/wind_wheel_3d/SConscript
new file mode 100644
index 0000000..fe61675
--- /dev/null
+++ b/examples/wind_wheel_3d/SConscript
@@ -0,0 +1,34 @@
+#!/bin/false
+
+import os
+import os.path
+import glob
+
+
+Import('env')
+
+dir_path = Dir('.').abspath
+
+# Environment for base library
+examples_env = env.Clone();
+examples_env['CXX'] = 'syclcc-clang';
+examples_env['CXXFLAGS'] += ['-O3'];
+
+examples_env.sources = sorted(glob.glob(dir_path + "/*.cpp"))
+examples_env.headers = sorted(glob.glob(dir_path + "/*.hpp"))
+
+env.sources += examples_env.sources;
+env.headers += examples_env.headers;
+
+# Cavity2D
+examples_objects = [];
+examples_env.add_source_files(examples_objects, ['wind_wheel_3d.cpp'], shared=False);
+examples_env.wind_wheel_3d = examples_env.Program('#bin/wind_wheel_3d', [examples_objects]);
+
+# Set Alias
+env.examples = [
+ examples_env.wind_wheel_3d
+];
+env.Alias('examples', env.examples);
+env.targets += ['examples'];
+env.Install('$prefix/bin/', env.examples);
diff --git a/examples/wind_wheel_3d/SConstruct b/examples/wind_wheel_3d/SConstruct
new file mode 100644
index 0000000..fe206e1
--- /dev/null
+++ b/examples/wind_wheel_3d/SConstruct
@@ -0,0 +1,82 @@
+#!/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_vars.Add('build_examples',
+ help='If examples should be built',
+ default="true"
+)
+
+env=Environment(ENV=os.environ, variables=env_vars, CPPPATH=[],
+ CPPDEFINES=['SAW_UNIX'],
+ CXXFLAGS=[
+ '-std=c++20',
+ '-g',
+ '-Wall',
+ '-Wextra',
+ '-isystem', 'AdaptiveCpp'
+ ],
+ LIBS=[
+ 'forstio-core',
+ 'acpp-rt',
+ 'omp'
+ ]
+);
+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('SConscript')
+
+env.Alias('cdb', env.cdb);
+env.Alias('all', [env.targets]);
+env.Default('all');
+
+env.Alias('install', '$prefix')
diff --git a/examples/wind_wheel_3d/wind_wheel_3d.cpp b/examples/wind_wheel_3d/wind_wheel_3d.cpp
new file mode 100644
index 0000000..990652a
--- /dev/null
+++ b/examples/wind_wheel_3d/wind_wheel_3d.cpp
@@ -0,0 +1,33 @@
+#include <forstio/error.hpp>
+#include <iostream>
+
+namespace kel {
+namespace sch {
+using namespace saw::schema;
+using KelConfig = Struct<
+ Member<String,"resolution">
+>;
+}
+
+saw::error_or<void> real_main(int argc, char** argv){
+ return saw::make_void();
+}
+}
+
+int main(int argc, char** argv){
+ auto eov = kel::kel_main(argc, argv);
+ if(eov.is_error()){
+ auto& err = eov.get_error();
+ auto err_msg = err.get_message();
+ std::cerr<<"[Error]: "<<err.get_category();
+
+ if(not err_msg.empty()){
+ std::cerr<<" - "<<err_msg;
+ }
+ std::cerr<<std::endl;
+
+ return err.get_id();
+ }
+
+ return 0;
+}