summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--default.nix7
-rw-r--r--examples/heterogeneous_computing/.nix/derivation.nix39
-rw-r--r--examples/heterogeneous_computing/SConscript34
-rw-r--r--examples/heterogeneous_computing/SConstruct82
-rw-r--r--examples/heterogeneous_computing/heterogeneous_computing.cpp33
-rw-r--r--examples/poiseulle_2d_gpu/poiseulle_2d_gpu.cpp48
-rw-r--r--lib/core/c++/flatten.hpp44
-rw-r--r--lib/core/c++/particle/particle.hpp19
-rw-r--r--lib/core/c++/write_vtk.hpp129
-rw-r--r--lib/core/tests/flatten.cpp22
-rw-r--r--lib/core/tests/particle_flow_coupling.cpp23
-rw-r--r--lib/core/tests/particles.dummy (renamed from lib/core/tests/particles.cpp)11
-rw-r--r--lib/core/tests/vtk_write.cpp28
13 files changed, 463 insertions, 56 deletions
diff --git a/default.nix b/default.nix
index 674c8a5..bc8130b 100644
--- a/default.nix
+++ b/default.nix
@@ -13,7 +13,7 @@ let
forstio = (import ((builtins.fetchTarball {
url = "https://git.keldu.de/forstio-forstio/snapshot/master.tar.gz";
- sha256 = "sha256:0qjishg8za7s4z5nb5zi27zyx70b662mjrfqag9mrxlch866a0fx";
+ sha256 = "sha256:0p9k04q4jhxzypawjg2rjpff1f3plrr1azigjlb4l2l9r128jmkm";
}) + "/default.nix"){
inherit stdenv;
inherit clang-tools;
@@ -72,6 +72,11 @@ in rec {
inherit pname version stdenv forstio adaptive-cpp;
inherit kel-lbm;
};
+
+ heterogeneous_computing = pkgs.callPackage ./examples/heterogeneous_computing/.nix/derivation.nix {
+ inherit pname version stdenv forstio adaptive-cpp;
+ inherit kel-lbm;
+ };
};
debug = {
diff --git a/examples/heterogeneous_computing/.nix/derivation.nix b/examples/heterogeneous_computing/.nix/derivation.nix
new file mode 100644
index 0000000..48dfc7a
--- /dev/null
+++ b/examples/heterogeneous_computing/.nix/derivation.nix
@@ -0,0 +1,39 @@
+{ lib
+, stdenv
+, scons
+, clang-tools
+, forstio
+, pname
+, version
+, kel-lbm
+}:
+
+stdenv.mkDerivation {
+ pname = pname + "-examples-" + "heterogeneous_computing";
+ 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
+ forstio.remote-sycl
+ kel-lbm.core
+ ];
+
+ preferLocalBuild = true;
+
+ outputs = [ "out" "dev" ];
+}
diff --git a/examples/heterogeneous_computing/SConscript b/examples/heterogeneous_computing/SConscript
new file mode 100644
index 0000000..1e52d88
--- /dev/null
+++ b/examples/heterogeneous_computing/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, ['heterogeneous_computing.cpp'], shared=False);
+examples_env.heterogeneous_computing = examples_env.Program('#bin/heterogeneous_computing', [examples_objects]);
+
+# Set Alias
+env.examples = [
+ examples_env.heterogeneous_computing
+];
+env.Alias('examples', env.examples);
+env.targets += ['examples'];
+env.Install('$prefix/bin/', env.examples);
diff --git a/examples/heterogeneous_computing/SConstruct b/examples/heterogeneous_computing/SConstruct
new file mode 100644
index 0000000..fe206e1
--- /dev/null
+++ b/examples/heterogeneous_computing/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/heterogeneous_computing/heterogeneous_computing.cpp b/examples/heterogeneous_computing/heterogeneous_computing.cpp
new file mode 100644
index 0000000..990652a
--- /dev/null
+++ b/examples/heterogeneous_computing/heterogeneous_computing.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;
+}
diff --git a/examples/poiseulle_2d_gpu/poiseulle_2d_gpu.cpp b/examples/poiseulle_2d_gpu/poiseulle_2d_gpu.cpp
index 56bcdaf..6dda469 100644
--- a/examples/poiseulle_2d_gpu/poiseulle_2d_gpu.cpp
+++ b/examples/poiseulle_2d_gpu/poiseulle_2d_gpu.cpp
@@ -70,6 +70,10 @@ saw::error_or<void> set_geometry(
acpp::sycl::queue& sycl_q
){
using namespace kel::lbm;
+
+ saw::data<sch::T> rho{1.0};
+ saw::data<sch::FixedArray<sch::T,sch::D2Q9::D>> vel{{0.0,0.0}};
+ auto eq = equilibrium<sch::T,sch::D2Q9>(rho, vel);
sycl_q.submit([&](acpp::sycl::handler& h){
h.parallel_for(acpp::sycl::range<2>{meta.at({0}).get(), meta.at({1}).get()},[=](acpp::sycl::id<2> idx){
@@ -79,6 +83,8 @@ saw::error_or<void> set_geometry(
size_t acc_id = j * meta.at({0u}).get() + i;
auto& c = cells[acc_id];
auto& info = c.template get<"info">()({0});
+ auto& dfs = c.template get<"dfs">();
+ auto& dfs_old = c.template get<"dfs_old">();
if(i >= 2u and j >= 2u and (i+2u) < meta.at({0u}).get() and (j+2u) < meta.at({1u}).get()){
// Fluid
@@ -95,23 +101,16 @@ saw::error_or<void> set_geometry(
}else {
info.set({0u});
}
+ for(saw::data<sch::UInt64> k{0u}; k < saw::data<sch::UInt64>{Desc::Q}; ++k){
+ dfs(k) = eq.at(k);
+ dfs_old(k) = eq.at(k);
+ }
});
});
- return saw::make_void();
-}
-
-void set_initial_conditions(
- saw::data<sch::CellStruct>* cells,
- const saw::data<sch::FixedArray<sch::UInt64,sch::D2Q9::D>>& meta,
- acpp::sycl::queue& sycl_q
-){
- using namespace kel::lbm;
-
- saw::data<sch::T> rho{1.0};
- saw::data<sch::FixedArray<sch::T,sch::D2Q9::D>> vel{{0.0,0.0}};
- auto eq = equilibrium<sch::T,sch::D2Q9>(rho, vel);
+ sycl_q.wait();
+ return saw::make_void();
}
void lbm_step(
@@ -178,26 +177,23 @@ saw::error_or<void> kel_main(int argc, char** argv){
}
}
- sycl_q.wait();
- sycl_q.memcpy(&host_cells[0u], cells, x_d * y_d * sizeof(saw::data<lbm::sch::CellStruct>) );
- sycl_q.wait();
- acpp::sycl::free(cells, sycl_q);
- sycl_q.wait();
-
std::string vtk_f_name{"tmp/poiseulle_2d_gpu_"};
vtk_f_name += std::to_string(0u) + ".vtk";
// write_vtk_file(vtk_f_name,host_cells);
- for(uint64_t i = 0u; i < x_d; ++i){
- for(uint64_t j = 0u; j < y_d; ++j){
+ for(uint64_t i = 0u; i < 1024u*1204u; ++i){
+ if(i%128u == 0u){
- size_t acc_id = j * x_d + i;
-
- std::cout<<static_cast<uint64_t>(host_cells.at(acc_id).template get<"info">()({0u}).get())<<" ";
}
- std::cout<<"\n";
+ lbm_step(cells,meta,i,sycl_q);
+
}
- std::cout<<std::endl;
+
+ sycl_q.wait();
+ sycl_q.memcpy(&host_cells[0u], cells, x_d * y_d * sizeof(saw::data<lbm::sch::CellStruct>) );
+ sycl_q.wait();
+ acpp::sycl::free(cells, sycl_q);
+ sycl_q.wait();
return saw::make_void();
}
diff --git a/lib/core/c++/flatten.hpp b/lib/core/c++/flatten.hpp
new file mode 100644
index 0000000..164bb77
--- /dev/null
+++ b/lib/core/c++/flatten.hpp
@@ -0,0 +1,44 @@
+#pragma once
+
+#include <forstio/error.hpp>
+#include <forstio/codec/data.hpp>
+
+namespace kel {
+namespace lbm {
+namespace sch {
+using namespace saw::schema;
+}
+
+template<typename T, uint64_t D>
+struct flatten_index {
+public:
+ template<uint64_t i>
+ static constexpr saw::data<sch::UInt64> stride(const saw::data<sch::FixedArray<sch::UInt64,D>>& meta) {
+ if constexpr (i > 0u){
+ return stride<i-1u>(meta) * meta.at({i-1u});
+ }
+
+ return 1u;
+ }
+
+private:
+ /// 2,3,4 => 2,6,24
+ /// i + j * 2 + k * 3*2
+ /// 1 + 2 * 2 + 3 * 3*2 = 1+4+18 = 23
+ template<uint64_t i>
+ static void apply_i(saw::data<sch::UInt64>& flat_ind, const saw::data<sch::FixedArray<T,D>>& index, const saw::data<sch::FixedArray<T,D>>& meta){
+ if constexpr ( D > i ) {
+ flat_ind = flat_ind + index.at({i}) * stride<i>(meta);
+ apply_i<i+1u>(flat_ind,index,meta);
+ }
+ }
+public:
+ static saw::data<T> apply(const saw::data<sch::FixedArray<T,D>>& index, const saw::data<sch::FixedArray<T,D>>& meta){
+ saw::data<T> flat_ind{0u};
+
+ apply_i<0u>(flat_ind, index, meta);
+ return flat_ind;
+ }
+};
+}
+}
diff --git a/lib/core/c++/particle/particle.hpp b/lib/core/c++/particle/particle.hpp
index 446e8a3..b647ebe 100644
--- a/lib/core/c++/particle/particle.hpp
+++ b/lib/core/c++/particle/particle.hpp
@@ -34,10 +34,11 @@ using ParticleCollisionSpheroid = Struct<
Member<T, "radius">
>;
-template<typename T, uint64_t D>
+template<typename T, uint64_t D, typename CollisionType = ParticleCollisionSpheroid<T>>
using Particle = Struct<
Member<ParticleRigidBody<T,D>, "rigid_body">,
Member<ParticleMask<T,D>, "mask">,
+ Member<CollisionType, "collision">,
Member<T, "mass">,
Member<T, "size">
>;
@@ -65,6 +66,22 @@ constexpr auto verlet_step_lambda = [](saw::data<sch::Particle<T,D>>& particle,
pos = pos_new;
};
+/**
+*
+*
+*/
+template<typename T, uint64_t>
+constexpr auto broadphase_collision_check = [](saw::data<sch::Particle<T,D>>& left, saw::data<sch::Particle<T,D>>& right){
+ auto rad_l = left.template get<"collision">().template get<"radius">();
+ auto rad_r = right.template get<"collision">().template get<"radius">();
+
+ auto& rb_l = left.template get<"rigid_body">();
+ auto& rb_r = right.template get<"rigid_body">();
+
+ auto& pos_l = rb_l.template get<"position">();
+ auto& pos_r = rb_r.template get<"position">();
+}
+
template<typename T, uint64_t D, typename ParticleCollision = sch::ParticleMask<T,D> >
class particle_system {
private:
diff --git a/lib/core/c++/write_vtk.hpp b/lib/core/c++/write_vtk.hpp
index 0647db5..7d42bc9 100644
--- a/lib/core/c++/write_vtk.hpp
+++ b/lib/core/c++/write_vtk.hpp
@@ -6,6 +6,7 @@
#include <forstio/codec/data_math.hpp>
#include "descriptor.hpp"
+#include "flatten.hpp"
#include <fstream>
#include <filesystem>
@@ -186,19 +187,139 @@ struct lbm_vtk_writer<sch::Array<sch::Struct<sch::Member<StructT,StructN>...> ,
return saw::make_void();
}
};
+
+template<typename StructT, uint64_t Dim>
+struct lbm_vtk_writer_raw {
+ template<uint64_t i, uint64_t Dep>
+ static saw::error_or<void> write_i_iterate_d(std::ostream& vtk_file, const saw::data<StructT>* field, const saw::data<sch::FixedArray<sch::UInt64,Dim>>& meta, saw::data<sch::FixedArray<sch::UInt64,Dim>>& index){
+ constexpr auto Lit = saw::schema_type_at_index<i, StructT>::Type::KeyLiteral;
+ using Type = typename saw::schema_type_at_index<i, StructT>::Type::ValueType;
+
+ if constexpr (Dep == 0u){
+ auto flat_index = flatten_index<sch::UInt64,Dim>::apply(index, meta);
+ return lbm_vtk_writer<Type>::apply(vtk_file, field[flat_index.get()].template get<Lit>());
+ } else {
+ // Dep < Dim // I hope
+ static_assert(Dep > 0u, "Don't fall into this case");
+ for(index.at({Dep-1u}) = 0; index.at({Dep-1u}) < meta.at({Dep-1u}); ++index.at({Dep-1u})){
+ auto eov = write_i_iterate_d<i,Dep-1u>(vtk_file, field, meta, index);
+ if(eov.is_error()){
+ return eov;
+ }
+ }
+ }
+ return saw::make_void();
+ }
+
+ template<uint64_t i>
+ static saw::error_or<void> write_i(std::ostream& vtk_file, const saw::data<StructT>* field, const saw::data<sch::FixedArray<sch::UInt64,Dim>>& meta){
+ constexpr auto Lit = saw::schema_type_at_index<i, StructT>::Type::KeyLiteral;
+
+ // auto meta = field.get_dims();
+ saw::data<sch::FixedArray<sch::UInt64,Dim>> index;
+ for(saw::data<sch::UInt64> it{0}; it.get() < Dim; ++it){
+ index.at({0u}).set(0u);
+ }
+ // vtk_file write?
+ // Data header
+ {
+
+ auto eov = lbm_vtk_writer<typename saw::schema_type_at_index<i,StructT>::Type::ValueType>::apply_header(vtk_file, Lit.view());
+ if(eov.is_error()){
+ return eov;
+ }
+
+ }
+ return write_i_iterate_d<i,Dim>(vtk_file, field, meta, index);
+ }
+ template<uint64_t i>
+ static saw::error_or<void> iterate_i(std::ostream& vtk_file, const saw::data<StructT>* field,
+ const saw::data<sch::FixedArray<sch::UInt64,Dim>>& meta){
+ {
+ auto eov = write_i<i>(vtk_file, field, meta);
+ if(eov.is_error()){
+ return eov;
+ }
+ }
+ if constexpr ( (i+1u) < saw::schema_width<StructT>::value ){
+ return iterate_i<i+1u>(vtk_file, field, meta);
+ }
+ return saw::make_void();
+ }
+
+ static saw::error_or<void> apply(std::ostream& vtk_file, const saw::data<StructT>* field,
+ const saw::data<sch::FixedArray<sch::UInt64,Dim>>& meta){
+
+ vtk_file
+ <<"# vtk DataFile Version 3.0\n"
+ <<"LBM File\n"
+ <<"ASCII\n"
+ <<"DATASET STRUCTURED_POINTS\n"
+ <<"SPACING 1.0 1.0 1.0\n"
+ <<"ORIGIN 0.0 0.0 0.0\n"
+ ;
+
+ saw::data<sch::UInt64> pd_size{1u};
+ // DIMENSIONS
+
+ {
+ vtk_file << "DIMENSIONS";
+ for(saw::data<sch::UInt64> i{0u}; i.get() < Dim; ++i){
+ pd_size = pd_size * meta.at(i);
+ vtk_file << " " << meta.at(i).get();
+ }
+ for(saw::data<sch::UInt64> i{Dim}; i.get() < 3u; ++i){
+ vtk_file << " 1";
+ }
+
+ vtk_file << "\n";
+ }
+
+ if constexpr (saw::schema_width<StructT>::value > 0u){
+ // POINT DATA
+ {
+ vtk_file << "POINT_DATA " << pd_size.get() <<"\n";
+ }
+
+ // HEADER TO BODY
+ {
+ vtk_file << "\n";
+ }
+
+ return iterate_i<0u>(vtk_file, field,meta);
+ }
+
+ return saw::make_void();
+ }
+};
}
-template<typename Struct>
-saw::error_or<void> write_vtk_file(const std::filesystem::path& file_name, const saw::data<Struct>& field){
+template<typename Sch>
+saw::error_or<void> write_vtk_file(const std::filesystem::path& file_name, const saw::data<Sch>& field){
std::ofstream vtk_file{file_name};
- if(!vtk_file.is_open()){
+ if( not vtk_file.is_open() ){
return saw::make_error<saw::err::critical>("Could not open file.");
}
+ auto eov = impl::lbm_vtk_writer<Sch>::apply(vtk_file, field);
+ return eov;
+}
+
+template<typename StructInRaw, uint64_t D>
+saw::error_or<void> write_vtk_file(
+ const std::filesystem::path& file_name,
+ const saw::data<StructInRaw>* field,
+ const saw::data<sch::FixedArray<sch::UInt64,D>>& meta
+ ){
+ std::ofstream vtk_file{file_name};
+
+ if( not vtk_file.is_open() ){
+ return saw::make_error<saw::err::critical>("Could not open file.");
+ }
- auto eov = impl::lbm_vtk_writer<Struct>::apply(vtk_file, field);
+ auto eov = impl::lbm_vtk_writer_raw<StructInRaw,D>::apply(vtk_file, field, meta);
return eov;
}
}
diff --git a/lib/core/tests/flatten.cpp b/lib/core/tests/flatten.cpp
new file mode 100644
index 0000000..84b3fa4
--- /dev/null
+++ b/lib/core/tests/flatten.cpp
@@ -0,0 +1,22 @@
+#include <forstio/test/suite.hpp>
+
+#include "../c++/flatten.hpp"
+
+namespace {
+namespace sch {
+using namespace saw::schema;
+}
+
+SAW_TEST("Flatten Index Stride"){
+ using namespace kel;
+
+ constexpr saw::data<sch::UInt64> zero = lbm::flatten_index<sch::UInt64,3u>::stride<0u>({{2u,4u,3u}});
+ constexpr saw::data<sch::UInt64> one = lbm::flatten_index<sch::UInt64,3u>::stride<1u>({{2u,4u,3u}});
+ constexpr saw::data<sch::UInt64> two = lbm::flatten_index<sch::UInt64,3u>::stride<2u>({{2u,4u,3u}});
+
+ SAW_EXPECT(zero.get() == 1u, "Zero is correct");
+ SAW_EXPECT(one.get() == 2u, "Zero is correct");
+ SAW_EXPECT(two.get() == 8u, "Zero is correct");
+}
+
+}
diff --git a/lib/core/tests/particle_flow_coupling.cpp b/lib/core/tests/particle_flow_coupling.cpp
deleted file mode 100644
index c3e3769..0000000
--- a/lib/core/tests/particle_flow_coupling.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-#include <forstio/test/suite.hpp>
-
-#include <iostream>
-#include "../c++/particle/geometry/circle.hpp"
-
-
-namespace {
-namespace sch {
-using namespace kel::lbm::sch;
-
-using T = Float64;
-}
-
-SAW_TEST("Particle Coupling"){
- using namespace kel;
- lbm::particle_system<sch::T,2,sch::Particle<sch::T,2>> system;
-
- /// What are the steps?#
- ///
- /// Collide and Stream
-
-}
-}
diff --git a/lib/core/tests/particles.cpp b/lib/core/tests/particles.dummy
index 79a6471..cbbeefa 100644
--- a/lib/core/tests/particles.cpp
+++ b/lib/core/tests/particles.dummy
@@ -1,7 +1,7 @@
#include <forstio/test/suite.hpp>
#include <iostream>
-#include "../c++/particle/geometry/circle.hpp"
+//#include "../c++/particle/geometry/circle.hpp"
namespace {
@@ -11,6 +11,7 @@ using namespace kel::lbm::sch;
using T = Float64;
}
SAW_TEST("Verlet step 2D - Planar"){
+/*
using namespace kel;
@@ -28,6 +29,14 @@ SAW_TEST("Verlet step 2D - Planar"){
SAW_EXPECT(pos.at({{0}}).get() == 0.25, std::string{"Incorrect Pos X: "} + std::to_string(pos.at({{0}}).get()));
SAW_EXPECT(pos.at({{1}}).get() == 0.0, std::string{"Incorrect Pos Y: "} + std::to_string(pos.at({{1}}).get()));
+*/
+}
+
+SAW_TEST("Collision spheroid Test"){
+ using namespace kel;
+
+ saw::data<sch::Particle<sch::T,2u> part_a;
+ saw::data<sch::Particle<sch::T,2u> part_b;
}
/*
diff --git a/lib/core/tests/vtk_write.cpp b/lib/core/tests/vtk_write.cpp
index 0df9998..231fd37 100644
--- a/lib/core/tests/vtk_write.cpp
+++ b/lib/core/tests/vtk_write.cpp
@@ -61,4 +61,32 @@ SAW_TEST("VTK Write test example"){
// using Type = typename parameter_pack_type<i,T...>::type;
}
+
+SAW_TEST("VTK Write raw test example"){
+ using namespace kel;
+
+ // write_vtk();
+
+ std::stringstream sstream;
+
+ saw::data<sch::Array<sch::MacroStruct<sch::T,2>, 2>> cells{{{2u,2u}}};
+
+ auto meta = cells.dims();
+
+ auto& cell_0 = cells.at({{{0,0}}});
+ cell_0.template get<"velocity">()= {{0.5,-0.1}};
+ cell_0.template get<"pressure">().set(1.1);
+
+ auto eov = lbm::impl::lbm_vtk_writer_raw<sch::MacroStruct<sch::T,2u>,2u>::apply(sstream, &cell_0, meta);
+ SAW_EXPECT(eov.is_value(), "vtk writer failed to write");
+
+ // I want to print it to see it for myself. For now I have no tooling to more easily view associated and potentially generated files
+ std::cout<<sstream.str()<<std::endl;
+
+ static std::string_view comparison_str = "# vtk DataFile Version 3.0\nLBM File\nASCII\nDATASET STRUCTURED_POINTS\nSPACING 1.0 1.0 1.0\nORIGIN 0.0 0.0 0.0\nDIMENSIONS 2 2 1\nPOINT_DATA 4\n\nVECTORS velocity float\n0.5 -0.1 0\n0 0 0\n0 0 0\n0 0 0\nSCALARS pressure float\nLOOKUP_TABLE default\n1.1\n0\n0\n0\n";
+ SAW_EXPECT(sstream.str() == comparison_str, "Expected different encoding");
+
+ // using Type = typename parameter_pack_type<i,T...>::type;
+}
+
}