diff options
| -rw-r--r-- | examples/poiseulle_particles_2d_fplbm_gpu/sim.cpp | 21 | ||||
| -rw-r--r-- | examples/stokes_drag_particle_2d_bgk_gpu/sim.cpp | 21 | ||||
| -rw-r--r-- | examples/stokes_drag_particle_2d_fplbm_gpu/sim.cpp | 24 | ||||
| -rw-r--r-- | lib/core/c++/abstract/templates.hpp | 3 | ||||
| -rw-r--r-- | lib/core/c++/environment.hpp | 5 | ||||
| -rw-r--r-- | lib/core/tests/particles.cpp | 4 | ||||
| -rwxr-xr-x | scripts/python/csv_magnitude_sum.py | 19 |
7 files changed, 54 insertions, 43 deletions
diff --git a/examples/poiseulle_particles_2d_fplbm_gpu/sim.cpp b/examples/poiseulle_particles_2d_fplbm_gpu/sim.cpp index 3d16884..c6aac92 100644 --- a/examples/poiseulle_particles_2d_fplbm_gpu/sim.cpp +++ b/examples/poiseulle_particles_2d_fplbm_gpu/sim.cpp @@ -145,27 +145,6 @@ saw::error_or<void> setup_initial_conditions( {{1u,1u}} ); - /* - iterator<Desc::D>::apply( - [&](auto& index){ - saw::data<sch::Vector<T,Desc::D>> middle, ind_vec; - middle.at({{0u}}) = dim_x * 0.25; - middle.at({{1u}}) = dim_y * 0.5; - - ind_vec.at({{0u}}) = index.at({{0u}}).template cast_to<T>(); - ind_vec.at({{1u}}) = index.at({{1u}}).template cast_to<T>(); - - auto dist = middle - ind_vec; - auto dist_2 = saw::math::dot(dist,dist); - if(dist_2.at({}).get() < dim_y*dim_y*0.01){ - porous_f.at(index).at({}) = 1.0; - } - }, - {},// 0-index - df_f.get_dims() - ); - */ - return saw::make_void(); } diff --git a/examples/stokes_drag_particle_2d_bgk_gpu/sim.cpp b/examples/stokes_drag_particle_2d_bgk_gpu/sim.cpp index 911d84a..9426371 100644 --- a/examples/stokes_drag_particle_2d_bgk_gpu/sim.cpp +++ b/examples/stokes_drag_particle_2d_bgk_gpu/sim.cpp @@ -10,8 +10,8 @@ namespace kel { namespace lbm { -constexpr uint64_t dim_y = 256ul; -constexpr uint64_t dim_x = dim_y * 20ul; +constexpr uint64_t dim_y = 1024ul; +constexpr uint64_t dim_x = dim_y * 2ul; constexpr uint64_t particle_amount = 1ul; @@ -50,8 +50,7 @@ using ForceChunk = Chunk<Vector<T,Desc::D>, 0u, dim_x, dim_y>; template<typename T, typename Desc> using MacroStruct = Struct< Member<VelChunk<T,Desc>, "velocity">, - Member<RhoChunk<T>, "density">, - Member<ScalarChunk<T,Desc>, "porosity"> + Member<RhoChunk<T>, "density"> >; //template<typename T, typename Desc> @@ -66,7 +65,6 @@ saw::error_or<void> setup_initial_conditions( saw::data<sch::MacroStruct<T,Desc>>& macros ){ auto& info_f = fields.template get<"info">(); - auto& porous_f = macros.template get<"porosity">(); // Set everything as walls iterator<Desc::D>::apply( [&](auto& index){ @@ -109,13 +107,11 @@ saw::error_or<void> setup_initial_conditions( auto& df_f = fields.template get<"dfs_old">(); auto& rho_f = macros.template get<"density">(); auto& vel_f = macros.template get<"velocity">(); - 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({}) = {0}; rho.at({}) = {1}; auto& vel = vel_f.at(index); auto eq = equilibrium<T,Desc>(rho,vel); @@ -144,11 +140,10 @@ saw::error_or<void> setup_initial_conditions( {{1u,1u}} ); - /* iterator<Desc::D>::apply( [&](auto& index){ saw::data<sch::Vector<T,Desc::D>> middle, ind_vec; - middle.at({{0u}}) = dim_x * 0.25; + middle.at({{0u}}) = dim_x * 0.5; middle.at({{1u}}) = dim_y * 0.5; ind_vec.at({{0u}}) = index.at({{0u}}).template cast_to<T>(); @@ -156,14 +151,13 @@ saw::error_or<void> setup_initial_conditions( auto dist = middle - ind_vec; auto dist_2 = saw::math::dot(dist,dist); - if(dist_2.at({}).get() < dim_y*dim_y*0.01){ - porous_f.at(index).at({}) = 1.0; + if(dist_2.at({}).get() < dim_y*dim_y*0.01 / 16.0){ + info_f.at(index).set(5u); } }, {},// 0-index df_f.get_dims() ); - */ return saw::make_void(); } @@ -177,7 +171,6 @@ saw::error_or<void> step( ){ auto& q = dev.get_handle(); auto& info_f = fields.template get<"info">(); - auto& porous_f = macros.template get<"porosity">(); // auto coll_ev = q.submit([&](acpp::sycl::handler& h){ @@ -192,7 +185,7 @@ saw::error_or<void> step( rad.at({}).set(dim_y*0.1); saw::data<sch::Vector<T,Desc::D>> p_pos; { - p_pos.at({{0u}}) = dim_x * 0.25; + p_pos.at({{0u}}) = dim_x * 0.5; p_pos.at({{1u}}) = dim_y * 0.5; } component<T,Desc,cmpt::OneParticleAt,encode::Sycl<saw::encode::Native>> opa{p_pos,rad,eps}; diff --git a/examples/stokes_drag_particle_2d_fplbm_gpu/sim.cpp b/examples/stokes_drag_particle_2d_fplbm_gpu/sim.cpp index 17df764..78e7ba5 100644 --- a/examples/stokes_drag_particle_2d_fplbm_gpu/sim.cpp +++ b/examples/stokes_drag_particle_2d_fplbm_gpu/sim.cpp @@ -10,8 +10,8 @@ namespace kel { namespace lbm { -constexpr uint64_t dim_y = 256ul; -constexpr uint64_t dim_x = dim_y * 20ul; +constexpr uint64_t dim_y = 1024ul; +constexpr uint64_t dim_x = dim_y * 2ul; constexpr uint64_t particle_amount = 1ul; @@ -86,7 +86,23 @@ saw::error_or<void> setup_initial_conditions( info_f.get_dims(), {{1u,1u}} ); - + // Corners + /// Inflow + iterator<Desc::D>::apply( + [&](auto& index){ + info_f.at(index).set(5u); + }, + {{0u,0u}}, + {{1u,dim_y}} + ); + /// Outflow + iterator<Desc::D>::apply( + [&](auto& index){ + info_f.at(index).set(5u); + }, + {{dim_x-1u,0u}}, + {{dim_x, dim_y}} + ); // Inflow iterator<Desc::D>::apply( [&](auto& index){ @@ -193,7 +209,7 @@ saw::error_or<void> step( rad.at({}).set(dim_y*0.1); saw::data<sch::Vector<T,Desc::D>> p_pos; { - p_pos.at({{0u}}) = dim_x * 0.25; + p_pos.at({{0u}}) = dim_x * 0.5; p_pos.at({{1u}}) = dim_y * 0.5; } component<T,Desc,cmpt::OneParticleAt,encode::Sycl<saw::encode::Native>> opa{p_pos,rad,eps}; diff --git a/lib/core/c++/abstract/templates.hpp b/lib/core/c++/abstract/templates.hpp index f675a99..d9d9faa 100644 --- a/lib/core/c++/abstract/templates.hpp +++ b/lib/core/c++/abstract/templates.hpp @@ -2,6 +2,7 @@ namespace kel { namespace lbm { - +template<typename... T> +constexpr bool always_false = false; } } diff --git a/lib/core/c++/environment.hpp b/lib/core/c++/environment.hpp index 27d8f3a..d8aa9ae 100644 --- a/lib/core/c++/environment.hpp +++ b/lib/core/c++/environment.hpp @@ -8,11 +8,13 @@ namespace kel { namespace lbm { struct environment { + std::string name; + std::filesystem::path lbm_dir; std::filesystem::path data_dir; }; -saw::error_or<environment> lbm_directory(){ +saw::error_or<environment> setup_lbm_env(const std::string_view name){ namespace fs = std::filesystem; const char* home_dir = std::getenv("HOME"); @@ -25,6 +27,7 @@ saw::error_or<environment> lbm_directory(){ env.lbm_dir = std::filesystem::path{home_dir} / ".lbm"; { + // Set default data location to "${lbm_dir}/data" env.data_dir = env.lbm_dir / "data"; // LBM Data Location auto lbm_dir_config = env.lbm_dir / "data_dir_location.txt"; diff --git a/lib/core/tests/particles.cpp b/lib/core/tests/particles.cpp index de9477c..133c343 100644 --- a/lib/core/tests/particles.cpp +++ b/lib/core/tests/particles.cpp @@ -273,9 +273,9 @@ SAW_TEST("Verlet integration test 2D"){ } */ -SAW_TEST("Particle / AABB"){ +SAW_TEST("Spheroid Particle / AABB"){ using namespace kel; - + } } diff --git a/scripts/python/csv_magnitude_sum.py b/scripts/python/csv_magnitude_sum.py new file mode 100755 index 0000000..773ce52 --- /dev/null +++ b/scripts/python/csv_magnitude_sum.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python3 + +import argparse +import numpy as np + + +def main(): + parser = argparse.ArgumentParser(description="Compute the sum of magnitude"); + parser.add_argument("one"); + args = parser.parse_args(); + + a = np.loadtxt(args.one, delimiter=","); + + print(np.sum(np.linalg.norm(a,axis=1))); +#enddef + +if __name__ == "__main__": + main(); +#enddef |
