summaryrefslogtreecommitdiff
path: root/lib/core
diff options
context:
space:
mode:
authorClaudius "keldu" Holeksa <mail@keldu.de>2026-05-29 21:56:48 +0200
committerClaudius "keldu" Holeksa <mail@keldu.de>2026-05-29 21:56:48 +0200
commit2dd7c95a111a930e8e23140ab3fec074e7de4c8c (patch)
tree74edc82d6cdad766c31f68d4755a2f49eff4a422 /lib/core
parent346d979dcdea3e3f37d3ad55680b4f0469d7220c (diff)
downloadlibs-lbm-2dd7c95a111a930e8e23140ab3fec074e7de4c8c.tar.gz
Dangling
Diffstat (limited to 'lib/core')
-rw-r--r--lib/core/c++/chunk.hpp1
-rw-r--r--lib/core/c++/lbm.hpp2
-rw-r--r--lib/core/c++/math/math.hpp4
-rw-r--r--lib/core/c++/math/n_closest.hpp24
-rw-r--r--lib/core/c++/math/round.hpp26
-rw-r--r--lib/core/c++/particle/particle.hpp2
6 files changed, 56 insertions, 3 deletions
diff --git a/lib/core/c++/chunk.hpp b/lib/core/c++/chunk.hpp
index a1f2451..0f92437 100644
--- a/lib/core/c++/chunk.hpp
+++ b/lib/core/c++/chunk.hpp
@@ -25,6 +25,7 @@ struct chunk_schema_type_helper<Sch, Ghost, saw::tmpl_value_group<uint64_t>, saw
template<typename Sch, uint64_t Ghost, uint64_t... Sides>
struct Chunk {
using InnerSchema = typename impl::chunk_schema_type_helper<Sch, Ghost, saw::tmpl_value_group<uint64_t,Sides...>>::Schema;
+ using StoredValueSchema = Sch;
};
// Not needed for now
diff --git a/lib/core/c++/lbm.hpp b/lib/core/c++/lbm.hpp
index fbad908..b34ec10 100644
--- a/lib/core/c++/lbm.hpp
+++ b/lib/core/c++/lbm.hpp
@@ -23,6 +23,8 @@
#include "write_vtk.hpp"
#include "util.hpp"
+#include "math/math.hpp"
+
#include <forstio/codec/unit/unit_print.hpp>
#include <iostream>
diff --git a/lib/core/c++/math/math.hpp b/lib/core/c++/math/math.hpp
new file mode 100644
index 0000000..3920bec
--- /dev/null
+++ b/lib/core/c++/math/math.hpp
@@ -0,0 +1,4 @@
+#pragma once
+
+#include "n_linear.hpp"
+#include "n_closest.hpp"
diff --git a/lib/core/c++/math/n_closest.hpp b/lib/core/c++/math/n_closest.hpp
index ddc89be..13414e2 100644
--- a/lib/core/c++/math/n_closest.hpp
+++ b/lib/core/c++/math/n_closest.hpp
@@ -6,8 +6,8 @@
namespace kel {
namespace lbm {
-template<typename FieldSchema, typename T, uint64_t D>
-auto n_closest_read(saw::data<FieldSchema>, const saw::data<sch::Vector<T,D>>& frac_ind){
+template<typename FieldSchema, typename Encode, typename T, uint64_t D>
+saw::data<typename FieldSchema::InnerValueSchema> n_closest_read(const saw::data<sch::Ptr<FieldSchema>,Encode>& f, const saw::data<sch::Vector<T,D>>& frac_ind){
auto shift_frac_ind = frac_ind;
for(uint64_t i{0u}; i < D; ++i){
@@ -19,6 +19,26 @@ auto n_closest_read(saw::data<FieldSchema>, const saw::data<sch::Vector<T,D>>& f
}
auto shift_ind = frac_ind.template cast_to<sch::UInt64>();
+
+ return f.at(shift_ind);
}
+
+template<typename FieldSchema, typename Encode, typename T, uint64_t D>
+void n_closest_add(saw::data<sch::Ptr<FieldSchema>,Encode>& f, const saw::data<sch::Vector<T,D>>& frac_ind, const saw::data<typename FieldSchema::InnerValueSchema>& val){
+ auto shift_frac_ind = frac_ind;
+ for(uint64_t i{0u}; i < D; ++i){
+
+ shift_frac_ind.at({{i}}) = shift_frac_ind.at({{i}}) + saw::data<T>{0.5};
+ if(shift_frac_ind.at({{i}}).get() < 0){
+ shift_frac_ind.at({{i}}) = {};
+ }
+ }
+
+ auto shift_ind = frac_ind.template cast_to<sch::UInt64>();
+ auto& f_i = f.at(shift_ind);
+
+ f_i = f_i + val;
+}
+
}
}
diff --git a/lib/core/c++/math/round.hpp b/lib/core/c++/math/round.hpp
new file mode 100644
index 0000000..d3a2586
--- /dev/null
+++ b/lib/core/c++/math/round.hpp
@@ -0,0 +1,26 @@
+#pragma once
+
+#include "../common.hpp"
+
+namespace kel {
+namespace lbm {
+
+template<typename T, uint64_t D>
+saw::data<sch::FixedArray<sch::UInt64,D>> round_to_unsigned(const saw::data<sch::Vector<T,D>>& inp){
+ saw::data<sch::FixedArray<sch::UInt64,D>> rv;
+
+ auto zero = static_cast<saw::native_data_type<T>::type>(0);
+ auto half = static_cast<saw::native_data_type<T>::type>(0.5);
+
+ for(uint64_t i{0u}; i < D; ++i){
+ auto val = inp.at({{i}}).get()+half;
+ val = std::max(zero,val);
+
+ rv.at({i}).set(static_cast<uint64_t>(val));
+ }
+
+ return rv;
+}
+
+}
+}
diff --git a/lib/core/c++/particle/particle.hpp b/lib/core/c++/particle/particle.hpp
index 37bdc28..fec2eca 100644
--- a/lib/core/c++/particle/particle.hpp
+++ b/lib/core/c++/particle/particle.hpp
@@ -91,7 +91,7 @@ saw::data<sch::ParticleGroup<T,D, sch::ParticleCollisionSpheroid<T,radius>>> cre
mask = {mask_dims};
auto& mask_step = part.template get<"mask_step">().at({{0u}});
- mask_step.at({}) = dia_d.at({}) / mask_resolution.template cast_to<T>();
+ mask_step.at({}) = dia_d / mask_resolution.template cast_to<T>();
auto& com = part.template get<"center_of_mass">().at({{0u}});
// Paranoia