From 346d979dcdea3e3f37d3ad55680b4f0469d7220c Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Wed, 27 May 2026 15:58:45 +0200 Subject: Dangliung --- lib/core/c++/abstract/data.hpp | 1 + lib/core/c++/math/n_closest.hpp | 24 ++++++++++++++++++++++++ lib/core/c++/particle/particle.hpp | 16 +++++++++------- 3 files changed, 34 insertions(+), 7 deletions(-) create mode 100644 lib/core/c++/math/n_closest.hpp (limited to 'lib') diff --git a/lib/core/c++/abstract/data.hpp b/lib/core/c++/abstract/data.hpp index 0075718..ed23268 100644 --- a/lib/core/c++/abstract/data.hpp +++ b/lib/core/c++/abstract/data.hpp @@ -48,4 +48,5 @@ template struct schema { using Type = Sch; }; + } diff --git a/lib/core/c++/math/n_closest.hpp b/lib/core/c++/math/n_closest.hpp new file mode 100644 index 0000000..ddc89be --- /dev/null +++ b/lib/core/c++/math/n_closest.hpp @@ -0,0 +1,24 @@ +#pragma once + +#include "../common.hpp" +#include "../iterator.hpp" + +namespace kel { +namespace lbm { + +template +auto n_closest_read(saw::data, const saw::data>& frac_ind){ + + 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{0.5}; + if(shift_frac_ind.at({{i}}).get() < 0){ + shift_frac_ind.at({{i}}) = {}; + } + } + + auto shift_ind = frac_ind.template cast_to(); +} +} +} diff --git a/lib/core/c++/particle/particle.hpp b/lib/core/c++/particle/particle.hpp index 5449b88..37bdc28 100644 --- a/lib/core/c++/particle/particle.hpp +++ b/lib/core/c++/particle/particle.hpp @@ -51,22 +51,25 @@ using Particle = Struct< // Member, "mask">, >; -template> +template> using ParticleGroup = Struct< Member, "mask">, + Member,1u>, "mask_step">, Member,1u>, "density">, Member,1u>, "center_of_mass">, Member,1u>, "total_mass">, - Member>, "particles"> + Member,1u>, "particles"> >; } + + template::type radius> saw::data>> create_spheroid_particle_group( saw::data> density_p, const saw::data& mask_resolution ){ - saw::data>> part; + saw::data>> part; auto& mask = part.template get<"mask">(); auto& density = part.template get<"density">().at({{0u}}); @@ -82,13 +85,14 @@ saw::data>> cre for(uint64_t i = 0u; i < D; ++i){ mask_dims.at({i}) = mask_resolution; } - saw::data> mask_step; saw::data rad_d{radius}; saw::data dia_d = rad_d * 2; - mask_step.at({}) = dia_d / mask_resolution.template cast_to(); mask = {mask_dims}; + auto& mask_step = part.template get<"mask_step">().at({{0u}}); + mask_step.at({}) = dia_d.at({}) / mask_resolution.template cast_to(); + auto& com = part.template get<"center_of_mass">().at({{0u}}); // Paranoia for(uint64_t i = 0u; i < D; ++i){ @@ -110,8 +114,6 @@ saw::data>> cre saw::data> offset_index = saw::math::vectorize_data(index).template cast_to() - center; - - auto& dpi = mask.at(index); for(uint64_t i = 0u; i < D; ++i){ -- cgit v1.2.3