summaryrefslogtreecommitdiff
path: root/examples/one_particle_sedimentation_2d/init.hpp
diff options
context:
space:
mode:
authorClaudius "keldu" Holeksa <mail@keldu.de>2026-08-22 22:24:37 +0200
committerClaudius "keldu" Holeksa <mail@keldu.de>2026-08-22 22:24:37 +0200
commit4f8ba172c7c6cbe278cbf20927df543cd6c58c28 (patch)
tree0724726c6b16ba27fa7972fffb64501b22e89eda /examples/one_particle_sedimentation_2d/init.hpp
parent72f95bbed0d53d45858c7fb586f4d1876a384efd (diff)
parente6168bb3f656ebab9b63be697c79819b08fc1ae0 (diff)
downloadlibs-lbm-4f8ba172c7c6cbe278cbf20927df543cd6c58c28.tar.gz
Merge branch 'dev'
Diffstat (limited to 'examples/one_particle_sedimentation_2d/init.hpp')
-rw-r--r--examples/one_particle_sedimentation_2d/init.hpp101
1 files changed, 101 insertions, 0 deletions
diff --git a/examples/one_particle_sedimentation_2d/init.hpp b/examples/one_particle_sedimentation_2d/init.hpp
new file mode 100644
index 0000000..a35c6e8
--- /dev/null
+++ b/examples/one_particle_sedimentation_2d/init.hpp
@@ -0,0 +1,101 @@
+#pragma once
+
+#include "common.hpp"
+
+namespace kel {
+namespace lbm {
+
+template<typename T, typename Desc, typename Coll>
+saw::error_or<void> init(
+ const converter<T>& conv,
+ saw::data<sch::ChunkStruct<T,Desc>>& fields,
+ saw::data<sch::MacroStruct<T,Desc>>& macros,
+ saw::data<sch::ParticleSpheroidGroup<T,Desc>>& particles
+){
+ auto& info_f = fields.template get<"info">();
+ auto& porous_f = macros.template get<"porosity">();
+
+ // Set everything as walls
+ iterator<Desc::D>::apply(
+ [&](auto& index){
+ info_f.at(index).set(1u);
+ },
+ {},
+ info_f.get_dims(),
+ {}
+ );
+
+ // Fluid
+ iterator<Desc::D>::apply(
+ [&](auto& index){
+ info_f.at(index).set(2u);
+ },
+ {},
+ info_f.get_dims(),
+ {{1u,1u}}
+ );
+
+ auto& df_f = fields.template get<"dfs_old">();
+ auto& rho_f = macros.template get<"density">();
+ auto& vel_f = macros.template get<"momentum">();
+ auto& por_f = macros.template get<"porosity">();
+
+ iterator<Desc::D>::apply(
+ [&](auto& index){
+ auto& df = df_f.at(index);
+ auto& rho = rho_f.at(index);
+ por_f.at(index).at({}) = {1};
+ rho.at({}) = {1};
+ auto& vel = vel_f.at(index);
+ auto eq = equilibrium<T,Desc>(rho,vel);
+
+ df = eq;
+ },
+ {},// 0-index
+ df_f.get_dims()
+ );
+
+ iterator<Desc::D>::apply(
+ [&](auto& index){
+ auto& df = df_f.at(index);
+ auto& rho = rho_f.at(index);
+ rho.at({}) = {1};
+ auto& vel = vel_f.at(index);
+ if(info_f.at(index).get() == 2u){
+ vel.at({{0u}}) = 0.0;
+ }
+ auto eq = equilibrium<T,Desc>(rho,vel);
+
+ df = eq;
+ },
+ {},// 0-index
+ df_f.get_dims(),
+ {{1u,1u}}
+ );
+
+ {
+ saw::data<sch::Scalar<T>> radius_p;
+ radius_p.at({}).set(conv.meter_si_to_lbm({{0.05}}).handle().get());
+ std::cout<<"RADIUS: "<<radius_p.at({}).get()<<std::endl;
+ saw::data<sch::Scalar<T>> dense_p;
+ dense_p.at({}).set(1);
+ particles = create_spheroid_particle_group<T,Desc::D,1u>(radius_p, dense_p, {{64u}});
+ auto& parts = particles.template get<"particles">();
+
+ {
+ auto& p = parts.at({0u});
+ auto& prb = p.template get<"rigid_body">();
+ auto& p_pos = prb.template get<"position">();
+ auto& p_posold = prb.template get<"position_old">();
+ p_pos.at({{0u}}) = conv.meter_si_to_lbm({{0.16}}).handle();
+ p_pos.at({{1u}}) = conv.meter_si_to_lbm({{0.2}}).handle();
+
+ p_posold = p_pos;
+ }
+ }
+
+ return saw::make_void();
+}
+
+}
+}