From 5dade743e7c1e6b0b6001b4265bf792f0b05f93a Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Wed, 19 Aug 2026 16:36:14 +0200 Subject: Dangling --- examples/stdkr_2d_bgk/init.hpp | 124 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 examples/stdkr_2d_bgk/init.hpp (limited to 'examples/stdkr_2d_bgk/init.hpp') diff --git a/examples/stdkr_2d_bgk/init.hpp b/examples/stdkr_2d_bgk/init.hpp new file mode 100644 index 0000000..abc2a26 --- /dev/null +++ b/examples/stdkr_2d_bgk/init.hpp @@ -0,0 +1,124 @@ +#pragma once + +#include "common.hpp" + +namespace kel { +namespace lbm { + +template +saw::error_or init( + const converter& conv, + saw::data>& fields, + saw::data>& macros +){ + (void) conv; + + auto& info_f = fields.template get<"info">(); + auto& porous_f = macros.template get<"porosity">(); + // Set everything as walls + iterator::apply( + [&](auto& index){ + info_f.at(index).set(1u); + }, + {}, + info_f.get_dims(), + {} + ); + // Fluid + iterator::apply( + [&](auto& index){ + info_f.at(index).set(2u); + }, + {}, + info_f.get_dims(), + {{1u,1u}} + ); + + // Inflow + iterator::apply( + [&](auto& index){ + info_f.at(index).set(3u); + }, + {{0u,0u}}, + {{1u,dim_y}}, + {{0u,1u}} + ); + + // Outflow + iterator::apply( + [&](auto& index){ + info_f.at(index).set(4u); + }, + {{dim_x-1u,0u}}, + {{dim_x, dim_y}}, + {{0u,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::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(rho,vel); + + df = eq; + }, + {},// 0-index + df_f.get_dims() + ); + + iterator::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(rho,vel); + + df = eq; + }, + {},// 0-index + df_f.get_dims(), + {{1u,1u}} + ); + + { + + } + { + saw::data> radius_p; + radius_p.at({}).set(conv.meter_si_to_lbm({{0.05}}).handle().get()); + std::cout<<"RADIUS: "<> dense_p; + dense_p.at({}).set(1); + /* + 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(); +} + +} +} -- cgit v1.2.3 From 5cd236287542b47016fe3c49aa56bb66d74c4ad7 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Thu, 20 Aug 2026 18:59:00 +0200 Subject: Feierabend --- examples/stdkr_2d_bgk/init.hpp | 46 ++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 24 deletions(-) (limited to 'examples/stdkr_2d_bgk/init.hpp') diff --git a/examples/stdkr_2d_bgk/init.hpp b/examples/stdkr_2d_bgk/init.hpp index abc2a26..3127c88 100644 --- a/examples/stdkr_2d_bgk/init.hpp +++ b/examples/stdkr_2d_bgk/init.hpp @@ -14,7 +14,6 @@ saw::error_or init( (void) conv; auto& info_f = fields.template get<"info">(); - auto& porous_f = macros.template get<"porosity">(); // Set everything as walls iterator::apply( [&](auto& index){ @@ -57,13 +56,11 @@ saw::error_or init( 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::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(rho,vel); @@ -92,31 +89,32 @@ saw::error_or init( {{1u,1u}} ); - { + iterator::apply( + [&](const auto& index){ + auto& info = info_f.at(index); + saw::data> radius_p; + radius_p.at({}).set(conv.meter_si_to_lbm({{0.05}}).handle().get()); + saw::data> dense_p; + dense_p.at({}).set(1); - } - { - saw::data> radius_p; - radius_p.at({}).set(conv.meter_si_to_lbm({{0.05}}).handle().get()); - std::cout<<"RADIUS: "<> dense_p; - dense_p.at({}).set(1); - /* - auto& parts = particles.template get<"particles">(); + saw::data> middle,ind_vec; + middle.at({{0u}}) = conv.meter_si_to_lbm({{0.16}}).handle(); + middle.at({{1u}}) = conv.meter_si_to_lbm({{0.2}}).handle(); - { - 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(); + for(uint64_t i{0u}; i < Desc::D; ++i){ + ind_vec.at({{i}}) = index.at({i}).template cast_to(); + } - p_posold = p_pos; - } - */ - } + auto dist = ind_vec - middle; + auto dist_2 = saw::math::dot(dist,dist); + if(dist_2.at({}) < radius_p.at({}) * radius_p.at({})){ + info_f.at(index) = 1u; + } + }, + {},// 0-index + df_f.get_dims() + ); return saw::make_void(); } -- cgit v1.2.3