summaryrefslogtreecommitdiff
path: root/examples/moving_poiseulle_particles_2d_hlbm_gpu/sim.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/moving_poiseulle_particles_2d_hlbm_gpu/sim.cpp')
-rw-r--r--examples/moving_poiseulle_particles_2d_hlbm_gpu/sim.cpp60
1 files changed, 43 insertions, 17 deletions
diff --git a/examples/moving_poiseulle_particles_2d_hlbm_gpu/sim.cpp b/examples/moving_poiseulle_particles_2d_hlbm_gpu/sim.cpp
index 86f0ded..d96fa1b 100644
--- a/examples/moving_poiseulle_particles_2d_hlbm_gpu/sim.cpp
+++ b/examples/moving_poiseulle_particles_2d_hlbm_gpu/sim.cpp
@@ -17,6 +17,14 @@ constexpr uint64_t particle_amount = 1ul;
namespace sch {
+using LbmArgs = Args<
+ Struct<
+ Member<String, "name">,
+ Member<UInt64, "sub_steps">
+ >,
+ Tuple<>
+>;
+
using InfoChunk = Chunk<UInt8, 0u, dim_x, dim_y>;
template<typename T, typename Desc>
@@ -45,8 +53,9 @@ using RhoChunk = Chunk<Scalar<T>, 0u, dim_x, dim_y>;
template<typename T, typename Desc>
using MacroStruct = Struct<
- Member<VelChunk<T,Desc>, "momentum">,
+ Member<VelChunk<T,Desc>, "velocity">,
Member<RhoChunk<T>, "density">,
+ Member<VelChunk<T,Desc>, "force">,
Member<ScalarChunk<T,Desc>, "porosity">
>;
@@ -66,7 +75,6 @@ kel::lbm::error_or<void> setup_initial_conditions(
kel::lbm::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){
@@ -108,7 +116,7 @@ kel::lbm::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<"momentum">();
+ auto& vel_f = macros.template get<"velocity">();
auto& por_f = macros.template get<"porosity">();
iterator<Desc::D>::apply(
@@ -144,7 +152,7 @@ kel::lbm::error_or<void> setup_initial_conditions(
{{1u,1u}}
);
- kel::lbm::data<sch::Scalar<T>> rad;
+ kel::lbm::data<sch::LbmMeter<sch::Scalar<T>>> rad;
rad.at({}) = dim_y * 0.1f;
kel::lbm::data<sch::Scalar<T>> dense;
dense.at({}) = 1.0f;
@@ -158,7 +166,12 @@ kel::lbm::error_or<void> setup_initial_conditions(
kel::lbm::data<sch::Vector<T,Desc::D>> zero;
zero.at({{0u}}) = 0.0f;
zero.at({{1u}}) = 0.0f;
- rb.template get<"acceleration">() = zero;
+ // Acceleration is unit typed, so its zero has to be too.
+ kel::lbm::data<sch::LbmAcceleration<sch::Vector<T,Desc::D>>> zero_acc;
+ for(uint64_t i{0u}; i < Desc::D; ++i){
+ zero_acc.at({{i}}).set(0);
+ }
+ rb.template get<"acceleration">() = zero_acc;
rb.template get<"rotation">() = {};
rb.template get<"rotation_old">() = {};
rb.template get<"angular_acceleration">() = {};
@@ -173,11 +186,11 @@ kel::lbm::error_or<void> step(
kel::lbm::data<sch::Ptr<sch::MacroStruct<T,Desc>>,encode::Sycl<kel::lbm::enc::Native>>& macros,
kel::lbm::data<sch::Ptr<sch::ParticleSpheroidGroup<T,Desc>>,encode::Sycl<kel::lbm::enc::Native>>& particles,
kel::lbm::data<sch::UInt64> t_i,
+ kel::lbm::data<sch::UInt64> sub_steps,
device& dev
){
auto& q = dev.get_handle();
auto& info_f = fields.template get<"info">();
- auto& porous_f = macros.template get<"porosity">();
q.submit([&](acpp::sycl::handler& h){
component<T,Desc,cmpt::HlbmReset,encode::Sycl<kel::lbm::enc::Native>> hlbm_reset;
@@ -200,7 +213,7 @@ kel::lbm::error_or<void> step(
index.at({{i}}).set(idx[i]);
}
- hlbm_one_part.apply(fields,macros,particles,index,t_i,{16u});
+ hlbm_one_part.apply(fields,macros,particles,index,t_i,sub_steps);
});
}).wait();
@@ -269,15 +282,28 @@ template<typename T, typename Desc>
kel::lbm::error_or<void> lbm_main(int argc, char** argv){
using namespace kel::lbm;
- using dfi = df_info<T,Desc>;
-
- auto eo_lbm_dir = output_directory();
- if(eo_lbm_dir.is_error()){
- return std::move(eo_lbm_dir.get_error());
+ kel::lbm::data<sch::LbmArgs> args;
+ {
+ auto& args_n = args.template get<"args">();
+ auto& name = args_n.template get<"name">();
+ name.set("moving_poiseulle_particles_2d_hlbm_gpu");
+ auto& sub_steps_arg = args_n.template get<"sub_steps">();
+ sub_steps_arg.set(16u);
+ }
+ {
+ auto eov = kel::lbm::parse_args(args,argc,argv);
+ if(eov.is_error()){
+ return eov;
+ }
+ }
+ kel::lbm::data<sch::UInt64> sub_steps = args.template get<"args">().template get<"sub_steps">();
+ auto eo_lbm_env = init_lbm_env(args);
+ if(eo_lbm_env.is_error()){
+ return std::move(eo_lbm_env.get_error());
}
- auto& lbm_dir = eo_lbm_dir.get_value();
+ const auto& lbm_env = eo_lbm_env.get_value();
- auto out_dir = lbm_dir / "moving_poiseulle_particles_2d_hlbm_gpu";
+ auto& out_dir = lbm_env.name_dir;
{
std::error_code ec;
@@ -289,9 +315,9 @@ kel::lbm::error_or<void> lbm_main(int argc, char** argv){
converter<T> conv {
// delta_x
- {{1.0}},
+ {1.0},
// delta_t
- {{1.0}}
+ {1.0}
};
print_lbm_meta<T,Desc>(conv,{0.1},{1e-4},{0.4 * dim_y});
@@ -373,7 +399,7 @@ kel::lbm::error_or<void> lbm_main(int argc, char** argv){
for(kel::lbm::data<sch::UInt64> i{0u}; i < time_steps and krun; ++i){
// BC + Collision
{
- auto eov = step<T,Desc>(lsd_view,lsdm_view,lsdp_view,i,dev);
+ auto eov = step<T,Desc>(lsd_view,lsdm_view,lsdp_view,i,sub_steps,dev);
if(eov.is_error()){
return eov;
}