summaryrefslogtreecommitdiff
path: root/examples/moving_poiseulle_particles_2d_psm_gpu
diff options
context:
space:
mode:
Diffstat (limited to 'examples/moving_poiseulle_particles_2d_psm_gpu')
-rw-r--r--examples/moving_poiseulle_particles_2d_psm_gpu/sim.cpp62
1 files changed, 44 insertions, 18 deletions
diff --git a/examples/moving_poiseulle_particles_2d_psm_gpu/sim.cpp b/examples/moving_poiseulle_particles_2d_psm_gpu/sim.cpp
index a27c402..0bfefba 100644
--- a/examples/moving_poiseulle_particles_2d_psm_gpu/sim.cpp
+++ b/examples/moving_poiseulle_particles_2d_psm_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,7 +53,7 @@ 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<ScalarChunk<T,Desc>, "porosity">,
Member<VelChunk<T,Desc>, "force">
@@ -109,7 +117,7 @@ kel::lbm::error_or<void> init(
auto& dfs_old_f = fields.template get<"dfs_old">();
auto& dfs_f = fields.template get<"dfs">();
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">();
auto& force_f = macros.template get<"force">();
@@ -136,7 +144,7 @@ kel::lbm::error_or<void> init(
dfs_f.get_dims()
);
- 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;
@@ -150,7 +158,12 @@ kel::lbm::error_or<void> init(
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">() = {};
@@ -165,11 +178,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::PsmReset,encode::Sycl<kel::lbm::enc::Native>> psm_reset;
@@ -204,9 +217,9 @@ kel::lbm::error_or<void> step(
}
p_reset.apply(particles,index,t_i);
- p_gather.apply(fields,macros,particles,index,t_i,{16u});
- p_contact.apply(particles,index,t_i,{16u});
- p_integrate.apply(particles,index,t_i,{16u});
+ p_gather.apply(fields,macros,particles,index,t_i,sub_steps);
+ p_contact.apply(particles,index,t_i,sub_steps);
+ p_integrate.apply(particles,index,t_i,sub_steps);
});
}).wait();
@@ -267,15 +280,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_psm_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_psm_gpu";
+ auto& out_dir = lbm_env.name_dir;
{
std::error_code ec;
@@ -287,9 +313,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});
@@ -371,7 +397,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;
}