diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/core/c++/particle/particle.hpp | 17 | ||||
| -rw-r--r-- | lib/heterogenous/.nix/derivation.nix | 41 | ||||
| -rw-r--r-- | lib/heterogenous/SConstruct | 75 | ||||
| -rw-r--r-- | lib/heterogenous/c++/SConscript | 27 | ||||
| -rw-r--r-- | lib/heterogenous/c++/common.hpp | 12 | ||||
| -rw-r--r-- | lib/heterogenous/tests/SConscript | 32 |
6 files changed, 198 insertions, 6 deletions
diff --git a/lib/core/c++/particle/particle.hpp b/lib/core/c++/particle/particle.hpp index 3089378..6147a10 100644 --- a/lib/core/c++/particle/particle.hpp +++ b/lib/core/c++/particle/particle.hpp @@ -66,12 +66,9 @@ constexpr auto verlet_step_lambda = [](saw::data<sch::Particle<T,D>>& particle, pos = pos_new; }; -/** -* -* -*/ + template<typename T, uint64_t D> -constexpr auto broadphase_collision_check = [](saw::data<sch::Particle<T,D>>& left, saw::data<sch::Particle<T,D>>& right){ +constexpr auto broadphase_collision_distance = [](saw::data<sch::Particle<T,D>>& left, saw::data<sch::Particle<T,D>>& right) -> std::pair<bool,saw::data<sch::Scalar<T>>>{ auto rad_l = left.template get<"collision">().template get<"radius">(); auto rad_r = right.template get<"collision">().template get<"radius">(); @@ -87,7 +84,15 @@ constexpr auto broadphase_collision_check = [](saw::data<sch::Particle<T,D>>& le auto rad_ab_2 = rad_l * rad_l + rad_r * rad_r + rad_r * rad_l * static_cast<saw::native_data_type<T>::type>(2); - return (norm_2.at({}).get() < rad_ab_2.get()); + return std::make_pair((norm_2.at({}).get() < rad_ab_2.get()), norm_2); +}; +/** +* +* +*/ +template<typename T, uint64_t D> +constexpr auto broadphase_collision_check = [](saw::data<sch::Particle<T,D>>& left, saw::data<sch::Particle<T,D>>& right) -> bool{ + return broadphase_collision_distance<T,D>(left,right).first; }; template<typename T, uint64_t D, typename ParticleCollision = sch::ParticleMask<T,D> > diff --git a/lib/heterogenous/.nix/derivation.nix b/lib/heterogenous/.nix/derivation.nix new file mode 100644 index 0000000..3686e21 --- /dev/null +++ b/lib/heterogenous/.nix/derivation.nix @@ -0,0 +1,41 @@ +{ lib +, stdenv +, scons +, clang-tools +, pname +, version +, forstio +, kel-lbm +, adaptive-cpp +}: + +stdenv.mkDerivation { + pname = "${pname}-heterogenous"; + inherit version; + src = ./..; + + nativeBuildInputs = [ + scons + clang-tools + ]; + + buildInputs = [ + forstio.core + forstio.async + forstio.codec + forstio.codec-unit + forstio.codec-json + forstio.remote + kel-lbm.core + ]; + + doCheck = true; + checkPhase = '' + scons test + ./bin/tests + ''; + + preferLocalBuild = true; + + outputs = [ "out" "dev" ]; +} diff --git a/lib/heterogenous/SConstruct b/lib/heterogenous/SConstruct new file mode 100644 index 0000000..8b3ab01 --- /dev/null +++ b/lib/heterogenous/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/heterogenous/c++/SConscript b/lib/heterogenous/c++/SConscript new file mode 100644 index 0000000..b66e979 --- /dev/null +++ b/lib/heterogenous/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 +hetero_env = env.Clone(); + +hetero_env.sources = sorted(glob.glob(dir_path + "/*.cpp")); +hetero_env.headers = sorted(glob.glob(dir_path + "/*.hpp")); + +env.sources += hetero_env.sources; +env.headers += hetero_env.headers; + +## Static lib +objects = [] +hetero_env.add_source_files(objects, hetero_env.sources, shared=False); +env.library_static = hetero_env.StaticLibrary('#build/kel-lbm-hetero', [objects]); + +env.Install('$prefix/lib/', env.library_static); +env.Install('$prefix/include/kel/lbm/hetero/', hetero_env.headers); diff --git a/lib/heterogenous/c++/common.hpp b/lib/heterogenous/c++/common.hpp new file mode 100644 index 0000000..789c876 --- /dev/null +++ b/lib/heterogenous/c++/common.hpp @@ -0,0 +1,12 @@ +#pragma once + +#include <forstio/codec/data.hpp> + +namespace kel { +namespace lbm { +template<typename T, uint64_t D> +class super_block { +}; + +} +} diff --git a/lib/heterogenous/tests/SConscript b/lib/heterogenous/tests/SConscript new file mode 100644 index 0000000..d1b381e --- /dev/null +++ b/lib/heterogenous/tests/SConscript @@ -0,0 +1,32 @@ +#!/bin/false + +import os +import os.path +import glob + + +Import('env') + +dir_path = Dir('.').abspath + +# Environment for base library +test_cases_env = env.Clone(); + +test_cases_env.Append(LIBS=['forstio-test']); + +test_cases_env.sources = sorted(glob.glob(dir_path + "/*.cpp")) +test_cases_env.headers = sorted(glob.glob(dir_path + "/*.hpp")) + +env.sources += test_cases_env.sources; +env.headers += test_cases_env.headers; + +objects_static = [] +test_cases_env.add_source_files(objects_static, test_cases_env.sources, shared=False); +test_cases_env.program = test_cases_env.Program('#bin/tests', [objects_static]); +# , env.library_static]); + +# Set Alias +env.Alias('test', test_cases_env.program); +env.Alias('check', test_cases_env.program); + +env.targets += ['test','check']; |
