diff options
| author | Claudius "keldu" Holeksa <mail@keldu.de> | 2026-06-01 20:36:51 +0200 |
|---|---|---|
| committer | Claudius "keldu" Holeksa <mail@keldu.de> | 2026-06-01 20:36:51 +0200 |
| commit | da25b3a1e7776a810d3bda5af3f363cf3e986cae (patch) | |
| tree | 96b1625e2559e227e2f12802796450d64ab4ce45 | |
| parent | 7fd9bfd5946472230a3b74c52f88e19c15741faf (diff) | |
| download | libs-lbm-da25b3a1e7776a810d3bda5af3f363cf3e986cae.tar.gz | |
Helping getting porosity checks against particles
| -rw-r--r-- | lib/core/c++/hlbm.hpp | 33 | ||||
| -rw-r--r-- | lib/core/c++/particle/porosity.hpp | 54 |
2 files changed, 86 insertions, 1 deletions
diff --git a/lib/core/c++/hlbm.hpp b/lib/core/c++/hlbm.hpp index 196de73..7590cc2 100644 --- a/lib/core/c++/hlbm.hpp +++ b/lib/core/c++/hlbm.hpp @@ -7,10 +7,39 @@ namespace kel { namespace lbm { namespace cmpt { +struct HlbmInit {}; struct Hlbm {}; struct HlbmParticle {}; } +template<typename T, typename Descriptor, typename Encode> +class component<T, Descriptor, cmpt::HlbmInit, Encode> final { +private: + typename saw::native_data_type<T>::type relaxation_; + saw::data<T> frequency_; +public: + component(typename saw::native_data_type<T>::type relaxation__): + relaxation_{relaxation__}, + frequency_{typename saw::native_data_type<T>::type(1) / relaxation_} + {} + + template<typename CellFieldSchema, typename MacroFieldSchema> + void apply(const saw::data<CellFieldSchema, Encode>& field, const saw::data<MacroFieldSchema,Encode>& macros, saw::data<sch::FixedArray<sch::UInt64,Descriptor::D>> index, saw::data<sch::UInt64> time_step) const { + auto& porosity_f = macros.template get<"porosity">(); + auto& particle_N_f = field.template get<"particle_N">(); + auto& particle_D_f = field.template get<"particle_D">(); + + auto& por = porosity_f.at(index); + por = {}; + + auto& pnf = particle_N_f.at(index); + pnf = {}; + + auto& pnd = particle_D_f.at(index); + pnd = {}; + } +}; + /** * HLBM collision operator for LBM */ @@ -61,8 +90,9 @@ public: dfs_old_f.at(index).at({i}) = dfs_old_f.at(index).at({i}) + frequency_ * (eq.at(i) - dfs_old_f.at(index).at({i})); } - // porosity.at({}) = 1.0; + porosity.at({}) = 1.0; D.at({}) = 0.0; + N = {}; } }; @@ -80,6 +110,7 @@ public: /// Iterate over the grid bounds // auto& grid = p.template get<"grid">(); + } }; diff --git a/lib/core/c++/particle/porosity.hpp b/lib/core/c++/particle/porosity.hpp new file mode 100644 index 0000000..aa1ce5b --- /dev/null +++ b/lib/core/c++/particle/porosity.hpp @@ -0,0 +1,54 @@ +#pragma once + +#include "particle.hpp" +#include "../math/n_closest.hpp" + +namespace kel { +namespace lbm { +template<typename T, uint64_t D, typename Coll> +class particle_porosity { +public: + saw::data<sch::Scalar<T>> calculate(const saw::data<>& part_group, uint64_t p_i, const saw::data<sch::Vector<T,D>>& lbm_pos){ + auto& mask = part_group.template get<"mask">(); + + auto& particles = part_group.template get<"particles">(); + auto& part_i = particles.at({p_i}); + + auto& part_i_rb = part_i.template get<"rigid_body">(); + auto& pirb = part_i_rb.template get<"position">(); + + auto& dist = lbm_pos = lbm_pos - pirb; + + // index 0 is at + + return {}; + } +}; + + +template<typename T, uint64_t D, typename saw::native_data_type<T>::type radius> +class particle_porosity<T, D, coll::ParticleCollisionSpheroid<T,radius>> final { +public: + saw::data<sch::Scalar<T>> calculate(const saw::data<sch::Particle>&, uint64_t i, const saw::data<sch::Vector<T,D>>& lbm_pos){ + saw::data<sch::Scalar<T>> por; + por.at({}); + + saw::data<sch::Scalar<T>> dps_2; + for(uint64_t i{0u}; i < D; ++i){ + auto& dps_i = lbm_pos.at({{i}}); + dps_2.at({}) = dps_i * dps_i; + } + + saw::data<sch::Scalar<T>> rad_2; + rad_2.at({}).set(radius*radius); + + saw::data<sch::Scalar<T>> inside; + if(dps_2.at({}).get() < rad_2.at({}).get()){ + inside.at({}).set(1); + } + return inside; + } +}; + +} +} |
