summaryrefslogtreecommitdiff
path: root/examples/meta_2d
diff options
context:
space:
mode:
Diffstat (limited to 'examples/meta_2d')
-rw-r--r--examples/meta_2d/.nix/derivation.nix33
-rw-r--r--examples/meta_2d/SConscript32
-rw-r--r--examples/meta_2d/SConstruct79
-rw-r--r--examples/meta_2d/meta_2d.cpp36
4 files changed, 180 insertions, 0 deletions
diff --git a/examples/meta_2d/.nix/derivation.nix b/examples/meta_2d/.nix/derivation.nix
new file mode 100644
index 0000000..6dcc00e
--- /dev/null
+++ b/examples/meta_2d/.nix/derivation.nix
@@ -0,0 +1,33 @@
+{ lib
+, stdenv
+, scons
+, clang-tools
+, forstio
+, pname
+, version
+, kel-lbm
+}:
+
+stdenv.mkDerivation {
+ pname = pname + "-examples-" + "meta_2d";
+ inherit version;
+ src = ./..;
+
+ nativeBuildInputs = [
+ scons
+ clang-tools
+ ];
+
+ buildInputs = [
+ forstio.core
+ forstio.async
+ forstio.codec
+ forstio.codec-unit
+ forstio.codec-json
+ kel-lbm
+ ];
+
+ preferLocalBuild = true;
+
+ outputs = [ "out" "dev" ];
+}
diff --git a/examples/meta_2d/SConscript b/examples/meta_2d/SConscript
new file mode 100644
index 0000000..f14fd77
--- /dev/null
+++ b/examples/meta_2d/SConscript
@@ -0,0 +1,32 @@
+#!/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.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, ['meta_2d.cpp'], shared=False);
+examples_env.meta_2d = examples_env.Program('#bin/meta_2d', [examples_objects]);
+
+# Set Alias
+env.examples = [
+ examples_env.meta_2d
+];
+env.Alias('examples', env.examples);
+env.targets += ['examples'];
+env.Install('$prefix/bin/', env.examples);
diff --git a/examples/meta_2d/SConstruct b/examples/meta_2d/SConstruct
new file mode 100644
index 0000000..a7201cb
--- /dev/null
+++ b/examples/meta_2d/SConstruct
@@ -0,0 +1,79 @@
+#!/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'
+ ],
+ 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('SConscript')
+
+env.Alias('cdb', env.cdb);
+env.Alias('all', [env.targets]);
+env.Default('all');
+
+env.Alias('install', '$prefix')
diff --git a/examples/meta_2d/meta_2d.cpp b/examples/meta_2d/meta_2d.cpp
new file mode 100644
index 0000000..6d19800
--- /dev/null
+++ b/examples/meta_2d/meta_2d.cpp
@@ -0,0 +1,36 @@
+#include <kel/lbm/lbm.hpp>
+
+#include <iostream>
+
+int main(int argc, char** argv){
+ using namespace kel::lbm;
+
+ std::string_view cfg_file_name = "config.json";
+ if(argc > 1){
+ cfg_file_name = argv[1];
+ }
+
+ auto eo_conf = load_lbm_config<sch::Float64,sch::Descriptor<2,9>>(cfg_file_name);
+ if(eo_conf.is_error()){
+ auto& err = eo_conf.get_error();
+ std::cerr<<"[Error]: "<<err.get_category();
+ auto err_msg = err.get_message();
+ if(!err_msg.empty()){
+ std::cerr<<" - "<<err_msg;
+ }
+ std::cerr<<std::endl;
+
+ return err.get_id();
+ }
+
+ auto& conf = eo_conf.get_value();
+
+ converter<sch::Float64> conv{
+ {conf.template get<"delta_x">()},
+ {conf.template get<"delta_t">()}
+ };
+
+ print_lbm_meta<sch::Float64,sch::Descriptor<2,9>>(conv, {conf.template get<"kinematic_viscosity">()});
+
+ return 0;
+}