blob: d456ce813c8f4c57e9a33166e50fac1d8d9a9ff7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
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");
}
}
|