From 6a918f0827a6e8806f77e39e0348b1a2abed71f2 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Fri, 19 Dec 2025 14:11:57 +0100 Subject: Rewriting large portion for simpler approach --- lib/core/tests/flatten.cpp | 22 ++++++ lib/core/tests/particle_flow_coupling.cpp | 23 ------ lib/core/tests/particles.cpp | 105 --------------------------- lib/core/tests/particles.dummy | 114 ++++++++++++++++++++++++++++++ lib/core/tests/vtk_write.cpp | 28 ++++++++ 5 files changed, 164 insertions(+), 128 deletions(-) create mode 100644 lib/core/tests/flatten.cpp delete mode 100644 lib/core/tests/particle_flow_coupling.cpp delete mode 100644 lib/core/tests/particles.cpp create mode 100644 lib/core/tests/particles.dummy (limited to 'lib/core/tests') 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 + +#include "../c++/flatten.hpp" + +namespace { +namespace sch { +using namespace saw::schema; +} + +SAW_TEST("Flatten Index Stride"){ + using namespace kel; + + constexpr saw::data zero = lbm::flatten_index::stride<0u>({{2u,4u,3u}}); + constexpr saw::data one = lbm::flatten_index::stride<1u>({{2u,4u,3u}}); + constexpr saw::data two = lbm::flatten_index::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 - -#include -#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> system; - - /// What are the steps?# - /// - /// Collide and Stream - -} -} diff --git a/lib/core/tests/particles.cpp b/lib/core/tests/particles.cpp deleted file mode 100644 index 79a6471..0000000 --- a/lib/core/tests/particles.cpp +++ /dev/null @@ -1,105 +0,0 @@ -#include - -#include -#include "../c++/particle/geometry/circle.hpp" - - -namespace { -namespace sch { -using namespace kel::lbm::sch; - -using T = Float64; -} -SAW_TEST("Verlet step 2D - Planar"){ - using namespace kel; - - - saw::data> 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}); - - lbm::verlet_step_lambda(particle,{0.5}); - - 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("Minor Test for mask"){ - using namespace kel; - - lbm::particle_circle_geometry geo; - - auto mask = geo.generate_mask(9u,1u); - - auto& grid = mask.template get<"grid">(); - - for(saw::data i{0u}; i < grid.template get_dim_size<0>(); ++i){ - for(saw::data j{0u}; j < grid.template get_dim_size<1>(); ++j){ - std::cout<> reference_mask{{{4+2,4+2}}}; - //reference_mask.at({{0,0}}); -} -*/ -/* -SAW_TEST("Verlet integration test 2D"){ - using namespace kel; - lbm::particle_system> system; - - { - saw::data> 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 i{0u}; i < saw::data{2u}; ++i){ - std::cout<{1e-1}); - - { - auto& p = system.at({0u}); - auto& rb = p.template get<"rigid_body">(); - auto& pos = rb.template get<"position">(); - - for(saw::data i{0u}; i < saw::data{2u}; ++i){ - std::cout< + +#include +//#include "../c++/particle/geometry/circle.hpp" + + +namespace { +namespace sch { +using namespace kel::lbm::sch; + +using T = Float64; +} +SAW_TEST("Verlet step 2D - Planar"){ +/* + using namespace kel; + + + saw::data> 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}); + + lbm::verlet_step_lambda(particle,{0.5}); + + 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 part_a; + saw::data part_b; +} + +/* +SAW_TEST("Minor Test for mask"){ + using namespace kel; + + lbm::particle_circle_geometry geo; + + auto mask = geo.generate_mask(9u,1u); + + auto& grid = mask.template get<"grid">(); + + for(saw::data i{0u}; i < grid.template get_dim_size<0>(); ++i){ + for(saw::data j{0u}; j < grid.template get_dim_size<1>(); ++j){ + std::cout<> reference_mask{{{4+2,4+2}}}; + //reference_mask.at({{0,0}}); +} +*/ +/* +SAW_TEST("Verlet integration test 2D"){ + using namespace kel; + lbm::particle_system> system; + + { + saw::data> 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 i{0u}; i < saw::data{2u}; ++i){ + std::cout<{1e-1}); + + { + auto& p = system.at({0u}); + auto& rb = p.template get<"rigid_body">(); + auto& pos = rb.template get<"position">(); + + for(saw::data i{0u}; i < saw::data{2u}; ++i){ + std::cout<::type; } + +SAW_TEST("VTK Write raw test example"){ + using namespace kel; + + // write_vtk(); + + std::stringstream sstream; + + saw::data, 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,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<::type; +} + } -- cgit v1.2.3