summaryrefslogtreecommitdiff
path: root/modules/core/tests
diff options
context:
space:
mode:
authorClaudius "keldu" Holeksa <mail@keldu.de>2026-07-05 15:59:23 +0200
committerClaudius "keldu" Holeksa <mail@keldu.de>2026-07-05 15:59:23 +0200
commitc0549d71b2109f10c1238db8b22362e7826ba61b (patch)
tree16cd5264fcc3afe912e1b1b67738c8940d6d1177 /modules/core/tests
parent9a3147bc79caf3c0fb1a9cdee29d156b5ff092c7 (diff)
downloadlibs-lbm-c0549d71b2109f10c1238db8b22362e7826ba61b.tar.gz
Just rename from lib to modules
Diffstat (limited to 'modules/core/tests')
-rw-r--r--modules/core/tests/SConscript32
-rw-r--r--modules/core/tests/chunk.cpp47
-rw-r--r--modules/core/tests/collision.cpp6
-rw-r--r--modules/core/tests/converter.cpp26
-rw-r--r--modules/core/tests/descriptor.cpp39
-rw-r--r--modules/core/tests/equilibrium.cpp41
-rw-r--r--modules/core/tests/flatten.cpp22
-rw-r--r--modules/core/tests/iterator.cpp72
-rw-r--r--modules/core/tests/math.cpp79
-rw-r--r--modules/core/tests/memory.cpp58
-rw-r--r--modules/core/tests/particles.cpp281
-rw-r--r--modules/core/tests/vtk_write.cpp93
12 files changed, 796 insertions, 0 deletions
diff --git a/modules/core/tests/SConscript b/modules/core/tests/SConscript
new file mode 100644
index 0000000..d1b381e
--- /dev/null
+++ b/modules/core/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'];
diff --git a/modules/core/tests/chunk.cpp b/modules/core/tests/chunk.cpp
new file mode 100644
index 0000000..008d4c6
--- /dev/null
+++ b/modules/core/tests/chunk.cpp
@@ -0,0 +1,47 @@
+#include <forstio/test/suite.hpp>
+
+#include "../c++/chunk.hpp"
+
+namespace {
+namespace sch {
+using namespace saw::schema;
+}
+
+SAW_TEST("Chunk Ghost size 0"){
+ using namespace kel;
+
+ using TestChunk = lbm::sch::Chunk<sch::UInt32, 0u, 2u, 3u, 4u>;
+ using TestArray = sch::FixedArray<sch::UInt32, 2u, 3u, 4u>;
+
+ SAW_EXPECT((std::is_same_v<TestChunk::InnerSchema,TestArray>), "Types are not identical");
+}
+
+SAW_TEST("Chunk Ghost size 1"){
+ using namespace kel;
+
+ using TestChunk = lbm::sch::Chunk<sch::UInt32,1u,2u,3u,4u>;
+ using TestArray = sch::FixedArray<sch::UInt32,4u,5u,6u>;
+
+ SAW_EXPECT((std::is_same_v<TestChunk::InnerSchema,TestArray>), "Types are not identical");
+}
+
+SAW_TEST("Chunk Ghost size 3"){
+ using namespace kel;
+
+ using TestChunk = lbm::sch::Chunk<sch::UInt32,3u,2u,3u,4u,10u,6u>;
+ using TestArray = sch::FixedArray<sch::UInt32,8u,9u,10u,16u,12u>;
+
+ SAW_EXPECT((std::is_same_v<TestChunk::InnerSchema,TestArray>), "Types are not identical");
+}
+
+SAW_TEST("Chunk 2D setup"){
+ using namespace kel;
+
+ using TestChunk = lbm::sch::Chunk<sch::Float32, 1u, 2u, 2u>;
+
+ auto chunk = saw::heap<saw::data<TestChunk>>();
+ chunk->at({{0u,0u}}).set(1.0f);
+ SAW_EXPECT((chunk->ghost_at({{1u,1u}}).get() == 1.0f),"Check if ghost is at shifted spot.");
+}
+
+}
diff --git a/modules/core/tests/collision.cpp b/modules/core/tests/collision.cpp
new file mode 100644
index 0000000..cd53336
--- /dev/null
+++ b/modules/core/tests/collision.cpp
@@ -0,0 +1,6 @@
+#include <forstio/test/suite.hpp>
+
+#include "../c++/collision.hpp"
+
+namespace {
+}
diff --git a/modules/core/tests/converter.cpp b/modules/core/tests/converter.cpp
new file mode 100644
index 0000000..4fc536f
--- /dev/null
+++ b/modules/core/tests/converter.cpp
@@ -0,0 +1,26 @@
+#include <forstio/test/suite.hpp>
+
+#include "../c++/converter.hpp"
+
+
+namespace {
+namespace sch {
+using namespace kel::lbm::sch;
+
+using T = Float64;
+}
+
+SAW_TEST("Si Meter to Lbm Meter"){
+ using namespace kel;
+
+ lbm::converter<sch::T> converter{
+ {0.1},
+ {0.1}
+ };
+
+ saw::data<sch::SiMeter<sch::T>> si_m{1.0};
+
+ auto lbm_m = converter.meter_si_to_lbm(si_m);
+ SAW_EXPECT(lbm_m.handle().get() == 10.0, "Correct si to lbm conversion");
+}
+}
diff --git a/modules/core/tests/descriptor.cpp b/modules/core/tests/descriptor.cpp
new file mode 100644
index 0000000..7f743ce
--- /dev/null
+++ b/modules/core/tests/descriptor.cpp
@@ -0,0 +1,39 @@
+#include <forstio/test/suite.hpp>
+
+#include "../c++/descriptor.hpp"
+
+
+namespace {
+template<typename Descriptor>
+void check_opposite_dirs(){
+ using namespace kel;
+
+ using dfi = lbm::df_info<lbm::sch::Float32, Descriptor>;
+
+ for(uint64_t k = 0u; k < Descriptor::Q; ++k){
+ auto k_inv = dfi::opposite_index[k];
+
+ for(uint64_t i = 0u; i < Descriptor::D; ++i){
+ SAW_EXPECT(dfi::directions[k][i] == (-1*dfi::directions[k_inv][i]), "Opposites are inconsistent");
+ }
+ }
+}
+
+SAW_TEST("Opposites and Dirs D1Q3"){
+ using namespace kel;
+ check_opposite_dirs<lbm::sch::Descriptor<1,3>>();
+}
+
+SAW_TEST("Opposites and Dirs D2Q5"){
+ using namespace kel;
+ check_opposite_dirs<lbm::sch::Descriptor<2,5>>();
+}
+SAW_TEST("Opposites and Dirs D2Q9"){
+ using namespace kel;
+ check_opposite_dirs<lbm::sch::Descriptor<2,9>>();
+}
+SAW_TEST("Opposites and Dirs D3Q27"){
+ using namespace kel;
+ check_opposite_dirs<lbm::sch::Descriptor<3,27>>();
+}
+}
diff --git a/modules/core/tests/equilibrium.cpp b/modules/core/tests/equilibrium.cpp
new file mode 100644
index 0000000..20a1f08
--- /dev/null
+++ b/modules/core/tests/equilibrium.cpp
@@ -0,0 +1,41 @@
+#include <forstio/test/suite.hpp>
+
+#include "../c++/equilibrium.hpp"
+
+
+namespace {
+
+template<typename Descriptor>
+void check_equilibrium(){
+ using namespace kel;
+
+ using dfi = lbm::df_info<lbm::sch::Float64,Descriptor>;
+
+ saw::data<lbm::sch::Scalar<lbm::sch::Float64>> rho;
+ rho.at({}).set(1.0);
+ saw::data<lbm::sch::Vector<lbm::sch::Float64,Descriptor::D>> vel;
+ for(saw::data<lbm::sch::UInt64> i{0u}; i.get() < Descriptor::D; ++i){
+ vel.at({{i}}) = {0.0};
+ }
+ auto eq = lbm::equilibrium<lbm::sch::Float64,Descriptor>(rho,vel);
+
+ for(saw::data<lbm::sch::UInt64> i{0u}; i.get() < Descriptor::Q; ++i){
+ SAW_EXPECT(eq.at(i).get() == dfi::weights[i.get()], std::string{"No velocity and normalized rho should be exactly the weights: "} + std::to_string(eq.at(i).get()) + std::string{" "} + std::to_string(dfi::weights[i.get()]));
+ }
+}
+
+SAW_TEST("Equilibrium at rest D1Q3"){
+ using namespace kel;
+ check_equilibrium<lbm::sch::Descriptor<1,3>>();
+}
+
+SAW_TEST("Equilibrium at rest D2Q5"){
+ using namespace kel;
+ check_equilibrium<lbm::sch::Descriptor<2,5>>();
+}
+
+SAW_TEST("Equilibrium at rest D2Q9"){
+ using namespace kel;
+ check_equilibrium<lbm::sch::Descriptor<2,9>>();
+}
+}
diff --git a/modules/core/tests/flatten.cpp b/modules/core/tests/flatten.cpp
new file mode 100644
index 0000000..84b3fa4
--- /dev/null
+++ b/modules/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/modules/core/tests/iterator.cpp b/modules/core/tests/iterator.cpp
new file mode 100644
index 0000000..919c12c
--- /dev/null
+++ b/modules/core/tests/iterator.cpp
@@ -0,0 +1,72 @@
+#include <forstio/test/suite.hpp>
+
+#include "../c++/iterator.hpp"
+
+#include <iostream>
+
+namespace {
+namespace sch {
+using namespace kel::lbm::sch;
+}
+
+SAW_TEST("Old Iterate"){
+ using namespace kel;
+
+ saw::data<sch::FixedArray<sch::UInt64,2u>> start{{0u,0u}};
+ saw::data<sch::FixedArray<sch::UInt64,2u>> end{{3u,3u}};
+
+ lbm::iterate_over([](const saw::data<sch::FixedArray<sch::UInt64,2u>>& index){
+ std::cout<<"Index: "<<index.at({0u}).get()<<" "<<index.at({1u}).get()<<std::endl;
+ }, start, end);
+}
+
+SAW_TEST("CT Tuple Iterator"){
+ using namespace kel;
+
+ saw::data<
+ sch::Tuple<
+ sch::Float32,
+ sch::Int16,
+ sch::Float64,
+ sch::UInt32
+ >
+ > tup;
+
+ lbm::ct_tuple_iterator<std::decay_t<decltype(tup)>::Schema>::apply([](auto& val) -> saw::error_or<void> {
+ return saw::make_void();
+ },tup);
+}
+
+SAW_TEST("Old Iterate with Distance 1"){
+ using namespace kel;
+
+ saw::data<sch::FixedArray<sch::UInt64,2u>> start{{0u,0u}};
+ saw::data<sch::FixedArray<sch::UInt64,2u>> end{{4u,4u}};
+
+ lbm::iterate_over([](const saw::data<sch::FixedArray<sch::UInt64,2u>>& index){
+ std::cout<<"Index: "<<index.at({0u}).get()<<" "<<index.at({1u}).get()<<std::endl;
+ }, start, end, {{1u,1u}});
+}
+
+SAW_TEST("Iterate - 2D"){
+ using namespace kel;
+
+ saw::data<sch::FixedArray<sch::UInt64,2u>> start{{0u,0u}};
+ saw::data<sch::FixedArray<sch::UInt64,2u>> end{{3u,3u}};
+
+ lbm::iterator<2u>::apply([](const saw::data<sch::FixedArray<sch::UInt64,2u>>& index){
+ std::cout<<"Index: "<<index.at({0u}).get()<<" "<<index.at({1u}).get()<<std::endl;
+ }, start, end);
+}
+
+SAW_TEST("Iterate with Distance 1 - 2D"){
+ using namespace kel;
+
+ saw::data<sch::FixedArray<sch::UInt64,2u>> start{{0u,0u}};
+ saw::data<sch::FixedArray<sch::UInt64,2u>> end{{4u,4u}};
+
+ lbm::iterator<2u>::apply([](const saw::data<sch::FixedArray<sch::UInt64,2u>>& index){
+ std::cout<<"Index: "<<index.at({0u}).get()<<" "<<index.at({1u}).get()<<std::endl;
+ }, start, end, {{1u,1u}});
+}
+}
diff --git a/modules/core/tests/math.cpp b/modules/core/tests/math.cpp
new file mode 100644
index 0000000..d456ce8
--- /dev/null
+++ b/modules/core/tests/math.cpp
@@ -0,0 +1,79 @@
+#include <forstio/test/suite.hpp>
+
+#include <iostream>
+#include "../c++/math/n_linear.hpp"
+
+namespace {
+namespace sch {
+using namespace saw::schema;
+}
+
+SAW_TEST("Math 1-Linear"){
+ using namespace kel;
+
+ saw::data<sch::FixedArray<sch::Vector<sch::Float64,1u>,2u>> field;
+ {
+ field.at({{0u}}).at({{0u}}).set(-1.0);
+ field.at({{1u}}).at({{0u}}).set(2.0);
+ }
+ saw::data<sch::Vector<sch::Float64,1u>> pos;
+ pos.at({{0u}}).set(0.3);
+}
+
+SAW_TEST("Math/Floor Index and Fraction from Position"){
+ using namespace kel;
+
+ saw::data<sch::Vector<sch::Float64,2u>> pos;
+
+ {
+ pos.at({{0u}}) = 43.999;
+ pos.at({{1u}}) = -50.0;
+ }
+
+ auto ind_frac = lbm::position_to_index_and_fraction(pos);
+ auto& ind = ind_frac.template get<0u>();
+ for(uint64_t i = 0u; i < 2u; ++i){
+ std::cout<<ind.at({{i}}).get()<<" ";
+ }
+ std::cout<<std::endl;
+ auto& frac = ind_frac.template get<1u>();
+ for(uint64_t i = 0u; i < 2u; ++i){
+ std::cout<<frac.at({{i}}).get()<<" ";
+ }
+ std::cout<<std::endl;
+
+ SAW_EXPECT(true, "Default true check");
+}
+
+SAW_TEST("Math/Floor Index and Fraction from Position and Bounded"){
+ using namespace kel;
+
+ saw::data<sch::Vector<sch::Float64,2u>> pos;
+
+ {
+ pos.at({{0u}}) = 43.999;
+ pos.at({{1u}}) = -50.0;
+ }
+
+ saw::data<sch::Vector<sch::UInt64,2U>> bound;
+ {
+ bound.at({{0u}}) = 32u;
+ bound.at({{1u}}) = 16u;
+ }
+
+ auto ind_frac = lbm::position_to_index_and_fraction_bounded(pos,bound);
+ auto& ind = ind_frac.template get<0u>();
+ for(uint64_t i = 0u; i < 2u; ++i){
+ std::cout<<ind.at({{i}}).get()<<" ";
+ }
+ std::cout<<std::endl;
+ auto& frac = ind_frac.template get<1u>();
+ for(uint64_t i = 0u; i < 2u; ++i){
+ std::cout<<frac.at({{i}}).get()<<" ";
+ }
+ std::cout<<std::endl;
+
+ SAW_EXPECT(true, "Default true check");
+}
+
+}
diff --git a/modules/core/tests/memory.cpp b/modules/core/tests/memory.cpp
new file mode 100644
index 0000000..d59d212
--- /dev/null
+++ b/modules/core/tests/memory.cpp
@@ -0,0 +1,58 @@
+#include <forstio/test/suite.hpp>
+
+#include "../c++/memory.hpp"
+
+namespace {
+namespace sch {
+using namespace saw::schema;
+
+using TStruct = Struct<
+ Member<Float32,"a">,
+ Member<Int8, "b">,
+ Member<UInt64, "c">
+>;
+
+using TChunk = kel::lbm::sch::Chunk<Float32,1u,2u,3u,4u>;
+using TBChunk = kel::lbm::sch::Chunk<UInt32,1u,2u,3u,4u>;
+
+using TChunkStruct = Struct<
+ Member<TChunk, "a">,
+ Member<TBChunk, "b">
+>;
+}
+
+SAW_TEST("Memory Estimate"){
+ using namespace kel::lbm;
+
+ SAW_EXPECT((memory_estimate<sch::Float32>().get() == 4u), "Float32 isn't 4 bytes" );
+ SAW_EXPECT((memory_estimate<sch::FixedArray<sch::Float32,5u,3u>>().get() == 60u), "FixedArray<Float32,5u,3u> isn't 60 bytes");
+ SAW_EXPECT((memory_estimate<sch::FixedArray<sch::Float32,5u,3u>, sch::UInt8>().get() == 61u), "FixedArray<Float32,5u,3u> + UInt8 isn't 61 bytes");
+}
+
+SAW_TEST("Memory Estimate Struct"){
+ using namespace kel::lbm;
+
+ SAW_EXPECT((memory_estimate<sch::TStruct>().get() == 13u), "TStruct isn't 13 bytes" );
+ // SAW_EXPECT((memory_estimate<sch::TStruct>().get() == 13u), "TStruct isn't 13 bytes" );
+}
+
+SAW_TEST("Memory Estimate Scalar"){
+ using namespace kel::lbm;
+
+ SAW_EXPECT((memory_estimate<sch::Scalar<sch::UInt8>>().get() == 1u), "Scalar of UInt8 isn't 1 bytes" );
+ // SAW_EXPECT((memory_estimate<sch::TStruct>().get() == 13u), "TStruct isn't 13 bytes" );
+}
+
+SAW_TEST("Memory Estimate Chunk"){
+ using namespace kel::lbm;
+
+ SAW_EXPECT((memory_estimate<sch::TChunk>().get() == 480u), std::string{"TChunk isn't 480 bytes, but is "} + std::to_string(memory_estimate<sch::TChunk>().get()) );
+}
+
+SAW_TEST("Memory Estimate Struct of Chunk"){
+ using namespace kel::lbm;
+
+ SAW_EXPECT((memory_estimate<sch::TChunkStruct>().get() == 960u), std::string{"TChunkStruct isn't 960 bytes, but is "} + std::to_string(memory_estimate<sch::TChunk>().get()) );
+}
+
+}
diff --git a/modules/core/tests/particles.cpp b/modules/core/tests/particles.cpp
new file mode 100644
index 0000000..133c343
--- /dev/null
+++ b/modules/core/tests/particles.cpp
@@ -0,0 +1,281 @@
+#include <forstio/test/suite.hpp>
+
+#include <iostream>
+#include "../c++/particle/particle.hpp"
+
+namespace {
+namespace sch {
+using namespace kel::lbm::sch;
+
+using T = Float64;
+}
+SAW_TEST("Verlet step 2D - Planar"){
+ using namespace kel;
+
+ saw::data<sch::Particle<sch::T,2u>> particle;
+ auto& body = particle.template get<"rigid_body">();
+ auto& pos = body.template get<"position">();
+ auto& pos_old = body.template get<"position_old">();
+
+ // auto& rot = body.template get<"rotation">();
+ auto& acc = body.template get<"acceleration">();
+
+ acc.at({{0}}).set({1.0});
+
+ saw::data<sch::Scalar<sch::T>> dt;
+ dt.at({}).set(0.5);
+ lbm::verlet_step_lambda<sch::T,2u>(particle,dt);
+
+ 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("No Collision Spheroid 2D"){
+ using namespace kel;
+
+ saw::data<sch::Particle<sch::T,2u>> part_a;
+ {
+ auto& body = part_a.template get<"rigid_body">();
+ auto& pos = body.template get<"position">();
+
+ pos.at({{0u}}) = 0.1;
+ pos.at({{1u}}) = 0.2;
+
+ }
+ saw::data<sch::Particle<sch::T,2u>> part_b;
+ {
+ auto& body = part_b.template get<"rigid_body">();
+ auto& pos = body.template get<"position">();
+
+ pos.at({{0u}}) = -2.1;
+ pos.at({{1u}}) = 0.0;
+ }
+
+ bool have_collided = lbm::broadphase_collision_check<sch::T,2u>(part_a,part_b);
+ SAW_EXPECT(not have_collided, "Particles shouldn't collide");
+}
+*/
+/*
+SAW_TEST("Collision Spheroid 2D"){
+ using namespace kel;
+
+ saw::data<sch::Particle<sch::T,2u>> part_a;
+ {
+ auto& body = part_a.template get<"rigid_body">();
+ auto& pos = body.template get<"position">();
+ auto& coll = part_a.template get<"collision">();
+ auto& radius = coll.template get<"radius">();
+
+ radius.at({}).set(1.0);
+
+ pos.at({{0u}}) = 0.1;
+ pos.at({{1u}}) = 0.2;
+
+ }
+ saw::data<sch::Particle<sch::T,2u>> part_b;
+ {
+ auto& body = part_b.template get<"rigid_body">();
+ auto& pos = body.template get<"position">();
+ auto& coll = part_b.template get<"collision">();
+ auto& radius = coll.template get<"radius">();
+
+ radius.at({}).set(1.0);
+
+ pos.at({{0u}}) = -1.5;
+ pos.at({{1u}}) = 0.0;
+ }
+
+ bool have_collided = lbm::broadphase_collision_check<sch::T,2u>(part_a,part_b);
+ SAW_EXPECT(have_collided, "Particles should collide");
+}
+*/
+/*
+SAW_TEST("Moving particles 2D"){
+ using namespace kel;
+
+ saw::data<sch::Particle<sch::T,2u>> part_a;
+ {
+ auto& body = part_a.template get<"rigid_body">();
+ auto& pos = body.template get<"position">();
+ auto& pos_old = body.template get<"position_old">();
+ auto& coll = part_a.template get<"collision">();
+ auto& radius = coll.template get<"radius">();
+ auto& acc = body.template get<"acceleration">();
+
+ radius.at({}).set(1.0);
+
+ pos.at({{0u}}) = -5.0;
+ pos.at({{1u}}) = 0.2;
+ pos_old = pos;
+ acc.at({{0u}}) = 0.1;
+
+ }
+ saw::data<sch::Particle<sch::T,2u>> part_b;
+ {
+ auto& body = part_b.template get<"rigid_body">();
+ auto& pos = body.template get<"position">();
+ auto& pos_old = body.template get<"position_old">();
+ auto& coll = part_b.template get<"collision">();
+ auto& radius = coll.template get<"radius">();
+ auto& acc = body.template get<"acceleration">();
+
+ radius.at({}).set(1.0);
+
+ pos.at({{0u}}) = 5.0;
+ pos.at({{1u}}) = 0.0;
+ pos_old = pos;
+ acc.at({{0u}}) = -0.1;
+ }
+
+ saw::data<sch::Scalar<sch::T>> dt;
+ dt.at({}).set(0.5);
+ bool has_collided = false;
+ for(uint64_t i = 0u; i < 32u; ++i){
+ lbm::verlet_step_lambda<sch::T,2u>(part_a,dt);
+ lbm::verlet_step_lambda<sch::T,2u>(part_b,dt);
+
+ has_collided = lbm::broadphase_collision_check<sch::T,2u>(part_a,part_b);
+ if(has_collided){
+ std::cout<<"Collided at: "<<i<<std::endl;
+ break;
+ }
+ }
+
+ SAW_EXPECT(has_collided, "Expecting collision within those steps");
+}
+*/
+SAW_TEST("Particle Matrix Rotation"){
+ using namespace kel;
+
+ saw::data<sch::Particle<sch::T,2u>> part_a;
+ {
+ auto& body = part_a.template get<"rigid_body">();
+ auto& pos = body.template get<"position">();
+ auto& pos_old = body.template get<"position_old">();
+ auto& acc = body.template get<"acceleration">();
+
+ pos.at({{0u}}) = -5.0;
+ pos.at({{1u}}) = 0.2;
+ pos_old = pos;
+ }
+}
+/*
+
+SAW_TEST("Particle Collision Impulse"){
+ using namespace kel;
+
+ saw::data<sch::Particle<sch::T,2u>> part_a;
+ {
+ auto& body = part_a.template get<"rigid_body">();
+ auto& pos = body.template get<"position">();
+ auto& pos_old = body.template get<"position_old">();
+ auto& coll = part_a.template get<"collision">();
+ auto& radius = coll.template get<"radius">();
+ auto& acc = body.template get<"acceleration">();
+
+ radius.at({}).set(1.0);
+
+ pos.at({{0u}}) = -5.0;
+ pos.at({{1u}}) = 0.2;
+ pos_old = pos;
+ acc.at({{0u}}) = 0.1;
+
+ }
+ saw::data<sch::Particle<sch::T,2u>> part_b;
+ {
+ auto& body = part_b.template get<"rigid_body">();
+ auto& pos = body.template get<"position">();
+ auto& pos_old = body.template get<"position_old">();
+ auto& coll = part_b.template get<"collision">();
+ auto& radius = coll.template get<"radius">();
+ auto& acc = body.template get<"acceleration">();
+
+ radius.at({}).set(1.5);
+
+ pos.at({{0u}}) = 5.0;
+ pos.at({{1u}}) = 0.0;
+ pos_old = pos;
+ acc.at({{0u}}) = -0.1;
+ }
+}
+*/
+/*
+
+SAW_TEST("Minor Test for mask"){
+ using namespace kel;
+
+ lbm::particle_circle_geometry<sch::T> geo;
+
+ auto mask = geo.generate_mask<sch::T>(9u,1u);
+
+ auto& grid = mask.template get<"grid">();
+
+ for(saw::data<sch::UInt64> i{0u}; i < grid.template get_dim_size<0>(); ++i){
+ for(saw::data<sch::UInt64> j{0u}; j < grid.template get_dim_size<1>(); ++j){
+ std::cout<<grid.at({{i,j}}).get()<<" ";
+ }
+ std::cout<<"\n";
+ }
+ std::cout<<std::endl;
+
+ //saw::data<sch::Array<sch::T,2>> reference_mask{{{4+2,4+2}}};
+ //reference_mask.at({{0,0}});
+}
+*/
+/*
+SAW_TEST("Verlet integration test 2D"){
+ using namespace kel;
+ lbm::particle_system<sch::T,2,sch::Particle<sch::T,2>> system;
+
+ {
+ saw::data<sch::Particle<sch::T,2>> particle;
+ auto& rb = particle.template get<"rigid_body">();
+ auto& acc = rb.template get<"acceleration">();
+ auto& pos = rb.template get<"position">();
+ auto& pos_old = rb.template get<"position_old">();
+ pos = {{1e-1,1e-1}};
+ pos_old = {{0.0, 0.0}};
+ acc = {{0.0,-1e1}};
+
+ auto eov = system.add_particle(std::move(particle));
+ SAW_EXPECT(eov.is_value(), "Expected no error :)");
+ }
+ {
+ auto& p = system.at({0u});
+ auto& rb = p.template get<"rigid_body">();
+ auto& pos = rb.template get<"position">();
+
+ for(saw::data<sch::UInt64> i{0u}; i < saw::data<sch::UInt64>{2u}; ++i){
+ std::cout<<pos.at(i).get()<<" ";
+ }
+ std::cout<<std::endl;
+ }
+
+ for(uint64_t i = 0u; i < 36u; ++i){
+ system.step(saw::data<sch::T>{1e-1});
+
+ {
+ auto& p = system.at({0u});
+ auto& rb = p.template get<"rigid_body">();
+ auto& pos = rb.template get<"position">();
+
+ for(saw::data<sch::UInt64> i{0u}; i < saw::data<sch::UInt64>{2u}; ++i){
+ std::cout<<pos.at(i).get()<<" ";
+ }
+ std::cout<<"\n";
+
+ if(pos.at({1u}).get() < 0.0){
+ break;
+ }
+ }
+
+ }
+}
+*/
+
+SAW_TEST("Spheroid Particle / AABB"){
+ using namespace kel;
+
+
+}
+}
diff --git a/modules/core/tests/vtk_write.cpp b/modules/core/tests/vtk_write.cpp
new file mode 100644
index 0000000..c99d752
--- /dev/null
+++ b/modules/core/tests/vtk_write.cpp
@@ -0,0 +1,93 @@
+#include <forstio/test/suite.hpp>
+
+#include <iostream>
+#include "../c++/write_vtk.hpp"
+
+#include <sstream>
+
+namespace {
+namespace sch {
+using namespace kel::lbm::sch;
+
+using T = Float64;
+using D2Q5 = Descriptor<2,5>;
+using D2Q9 = Descriptor<2,9>;
+
+template<typename Desc>
+using DfCell = Cell<T, Desc, 0, 0, 1>;
+
+template<typename Desc>
+using CellInfo = Cell<UInt8, D2Q9, 1, 0, 0>;
+
+/**
+ * Basic type for simulation
+ */
+template<typename Desc>
+using CellStruct = Struct<
+ Member<DfCell<Desc>, "dfs">,
+ Member<DfCell<Desc>, "dfs_old">,
+ Member<CellInfo<Desc>, "info">
+>;
+
+template<typename T, uint64_t D>
+using MacroStruct = Struct<
+ Member<FixedArray<T,D>, "velocity">,
+ Member<T, "pressure">
+>;
+
+}
+/*
+SAW_TEST("VTK Write test example"){
+ using namespace kel;
+
+ // write_vtk();
+
+ std::stringstream sstream;
+
+ saw::data<sch::Array<sch::MacroStruct<sch::T,2>, 2>> cells{{{2u,2u}}};
+
+ 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<sch::Array<sch::MacroStruct<sch::T,2>, 2>>::apply(sstream, cells);
+ 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;
+}
+
+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;
+}
+*/
+
+}