summaryrefslogtreecommitdiff
path: root/modules/core/tests/math.cpp
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/math.cpp
parent9a3147bc79caf3c0fb1a9cdee29d156b5ff092c7 (diff)
downloadlibs-lbm-c0549d71b2109f10c1238db8b22362e7826ba61b.tar.gz
Just rename from lib to modules
Diffstat (limited to 'modules/core/tests/math.cpp')
-rw-r--r--modules/core/tests/math.cpp79
1 files changed, 79 insertions, 0 deletions
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");
+}
+
+}