summaryrefslogtreecommitdiff
path: root/examples/stokes_drag_particle_2d_hlbm_gpu/sim.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/stokes_drag_particle_2d_hlbm_gpu/sim.cpp')
-rw-r--r--examples/stokes_drag_particle_2d_hlbm_gpu/sim.cpp60
1 files changed, 20 insertions, 40 deletions
diff --git a/examples/stokes_drag_particle_2d_hlbm_gpu/sim.cpp b/examples/stokes_drag_particle_2d_hlbm_gpu/sim.cpp
index a8ba21f..81498e2 100644
--- a/examples/stokes_drag_particle_2d_hlbm_gpu/sim.cpp
+++ b/examples/stokes_drag_particle_2d_hlbm_gpu/sim.cpp
@@ -13,7 +13,7 @@ namespace lbm {
constexpr uint64_t dim_y = 1024ul;
constexpr uint64_t dim_x = dim_y * 2ul;
-constexpr uint64_t particle_amount = 1ul;
+// constexpr uint64_t particle_amount = 1ul;
namespace sch {
using namespace saw::schema;
@@ -47,6 +47,7 @@ using RhoChunk = Chunk<Scalar<T>, 0u, dim_x, dim_y>;
template<typename T, typename Desc>
using MacroStruct = Struct<
Member<VelChunk<T,Desc>, "velocity">,
+ Member<VelChunk<T,Desc>, "force">,
Member<RhoChunk<T>, "density">,
Member<ScalarChunk<T,Desc>, "porosity">
>;
@@ -158,25 +159,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.5;
- 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({}) = 0.0;
- }
- },
- {},// 0-index
- df_f.get_dims()
- );
-
return saw::make_void();
}
@@ -196,12 +178,16 @@ saw::error_or<void> step(
component<T,Desc,cmpt::BounceBack,encode::Sycl<saw::encode::Native>> bb;
component<T,Desc,cmpt::AntiBounceBack<0u>,encode::Sycl<saw::encode::Native>> abb;
- saw::data<sch::Scalar<T>> rho_b;
- rho_b.at({}) = 1.0;
- saw::data<sch::Vector<T,Desc::D>> vel_b;
- vel_b.at({{0u}}) = 0.015;
-
- component<T,Desc,cmpt::Equilibrium,encode::Sycl<saw::encode::Native>> equi{rho_b,vel_b};
+ saw::data<sch::Scalar<T>> eps;
+ eps.at({}).set(1.5f);
+ saw::data<sch::Scalar<T>> rad;
+ rad.at({}).set(dim_y*0.1*0.25);
+ saw::data<sch::Vector<T,Desc::D>> p_pos;
+ {
+ 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};
component<T,Desc,cmpt::ZouHeHorizontal<true>,encode::Sycl<saw::encode::Native>> flow_in{
[&](){
@@ -230,6 +216,7 @@ saw::error_or<void> step(
abb.apply(fields,index,t_i);
break;
case 2u:
+ opa.apply(macros,index,t_i);
collision.apply(fields,macros,index,t_i);
break;
case 3u:
@@ -385,20 +372,7 @@ saw::error_or<void> lbm_main(int argc, char** argv){
}
}
*/
- if(i.get() % 32u == 0u){
- {
- auto eov = dev.copy_to_host(lbm_sycl_macro_data,*lbm_macro_data_ptr);
- if(eov.is_error()){
- return eov;
- }
- }
- {
- auto eov = write_csv_file(out_dir,"m",i.get(), *lbm_macro_data_ptr);
- if(eov.is_error()){
- return eov;
- }
- }
- }
+
// Stream
sycl_q.submit([&](acpp::sycl::handler& h){
component<T,Desc,cmpt::Stream,encode::Sycl<saw::encode::Native>> stream;
@@ -438,6 +412,12 @@ saw::error_or<void> lbm_main(int argc, char** argv){
return eov;
}
}
+ {
+ auto eov = write_csv_file(out_dir,"m",time_steps.get(), *lbm_macro_data_ptr);
+ if(eov.is_error()){
+ return eov;
+ }
+ }
sycl_q.wait();
return saw::make_void();