summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples/one_particle_sedimentation_2d/sim.cpp21
-rw-r--r--examples/one_particle_sedimentation_2d/step.hpp11
-rw-r--r--modules/core/c++/collision.hpp6
-rw-r--r--modules/core/c++/converter.hpp5
-rw-r--r--modules/core/c++/fplbm.hpp11
-rw-r--r--modules/core/c++/hlbm.hpp5
-rw-r--r--modules/core/c++/psm.hpp5
7 files changed, 51 insertions, 13 deletions
diff --git a/examples/one_particle_sedimentation_2d/sim.cpp b/examples/one_particle_sedimentation_2d/sim.cpp
index 0cb3ce0..86a7b1c 100644
--- a/examples/one_particle_sedimentation_2d/sim.cpp
+++ b/examples/one_particle_sedimentation_2d/sim.cpp
@@ -48,10 +48,13 @@ saw::error_or<void> lbm_main(const saw::data<args::LbmArgs>& args){
// delta_x
{{0.02 / dim_x}},
// delta_t
- {{1.5e-6}}
+ {{3e-7}}
};
+ saw::data<sch::SiKinematicViscosity<T>> kin_vis_si{1e-3};
+ auto kin_vis_lbm = conv.kinematic_viscosity_si_to_lbm(kin_vis_si);
+ auto tau = conv.template kinematic_viscosity_lbm_to_tau<Desc>(kin_vis_lbm);
- print_lbm_meta<T,Desc>(conv,{1e-3},{1e-4},{2});
+ print_lbm_meta<T,Desc>(conv,kin_vis_si,{1e-4},{2});
std::cout<<"Position: "<<conv.meter_si_to_lbm({{0.01}}).handle().get()<<", "<<conv.meter_si_to_lbm({{0.04}}).handle().get()<<std::endl;
// saw::data<sch::FixedArray<sch::UInt64,Desc::D>> meta{{dim_x,dim_y}};
@@ -123,21 +126,29 @@ saw::error_or<void> lbm_main(const saw::data<args::LbmArgs>& args){
auto lsdm_view = make_view(lbm_sycl_macro_data);
auto lsdp_view = make_view(lbm_sycl_particle_data);
- saw::data<sch::UInt64> time_steps{64u*1024ul};
+ saw::data<sch::UInt64> time_steps{1024ul * 1024ul};
auto& info_f = lsd_view.template get<"info">();
for(saw::data<sch::UInt64> i{0u}; i < time_steps and krun; ++i){
// BC + Collision
{
- auto eov = step<T,Desc,Coll>(conv,lsd_view,lsdm_view,lsdp_view,i,dev);
+ auto eov = step<T,Desc,Coll>(
+ conv,
+ tau,
+ lsd_view,
+ lsdm_view,
+ lsdp_view,
+ i,
+ dev
+ );
if(eov.is_error()){
return eov;
}
}
sycl_q.wait();
- if(i.get() % 64u == 0u){
+ if(i.get() % 1024u == 0u){
{
auto eov = dev.copy_to_host(lbm_sycl_macro_data,*lbm_macro_data_ptr);
if(eov.is_error()){
diff --git a/examples/one_particle_sedimentation_2d/step.hpp b/examples/one_particle_sedimentation_2d/step.hpp
index c3a3b8a..4bc9dde 100644
--- a/examples/one_particle_sedimentation_2d/step.hpp
+++ b/examples/one_particle_sedimentation_2d/step.hpp
@@ -8,6 +8,7 @@ namespace lbm {
template<typename T, typename Desc, typename Coll>
saw::error_or<void> step(
const converter<T>& conv,
+ const saw::data<sch::Pure<T>>& tau,
saw::data<sch::Ptr<sch::ChunkStruct<T,Desc>>,encode::Sycl<saw::encode::Native>>& fields,
saw::data<sch::Ptr<sch::MacroStruct<T,Desc>>,encode::Sycl<saw::encode::Native>>& macros,
saw::data<sch::Ptr<sch::ParticleSpheroidGroup<T,Desc>>,encode::Sycl<saw::encode::Native>>& particles,
@@ -47,7 +48,7 @@ saw::error_or<void> step(
}).wait();
q.submit([&](acpp::sycl::handler& h){
- component<T,Desc,cmpt::Hlbm,encode::Sycl<saw::encode::Native>> collision{1.0};
+ component<T,Desc,cmpt::Hlbm,encode::Sycl<saw::encode::Native>> collision{tau};
component<T,Desc,cmpt::BounceBack,encode::Sycl<saw::encode::Native>> bb;
h.parallel_for(acpp::sycl::range<Desc::D>{dim_x,dim_y}, [=](acpp::sycl::id<Desc::D> idx){
@@ -99,14 +100,14 @@ saw::error_or<void> step(
index.at({{i}}).set(idx[i]);
}
- fplbm_one_part.apply(fields,macros,particles,index,t_i,{16u});
+ fplbm_one_part.apply(fields,macros,particles,index,t_i,{32u});
});
}).wait();
// auto coll_ev =
q.submit([&](acpp::sycl::handler& h){
- component<T,Desc,cmpt::BGK,encode::Sycl<saw::encode::Native>> bgk{1.0};
- component<T,Desc,cmpt::FpLbm,encode::Sycl<saw::encode::Native>> collision{1.0};
+ component<T,Desc,cmpt::BGK,encode::Sycl<saw::encode::Native>> bgk{tau};
+ component<T,Desc,cmpt::FpLbm,encode::Sycl<saw::encode::Native>> collision{tau};
component<T,Desc,cmpt::BounceBack,encode::Sycl<saw::encode::Native>> bb;
component<T,Desc,cmpt::ZouHeHorizontal<false>,encode::Sycl<saw::encode::Native>> flow_out{1.0};
@@ -182,7 +183,7 @@ saw::error_or<void> step(
// auto coll_ev =
q.submit([&](acpp::sycl::handler& h){
component<T,Desc,cmpt::BGK,encode::Sycl<saw::encode::Native>> bgk{1.0};
- component<T,Desc,cmpt::Psm,encode::Sycl<saw::encode::Native>> collision{1.0};
+ component<T,Desc,cmpt::Psm,encode::Sycl<saw::encode::Native>> collision{tau};
component<T,Desc,cmpt::BounceBack,encode::Sycl<saw::encode::Native>> bb;
component<T,Desc,cmpt::ZouHeHorizontal<false>,encode::Sycl<saw::encode::Native>> flow_out{1.0};
diff --git a/modules/core/c++/collision.hpp b/modules/core/c++/collision.hpp
index 39514b8..ec21b5f 100644
--- a/modules/core/c++/collision.hpp
+++ b/modules/core/c++/collision.hpp
@@ -4,6 +4,7 @@
#include "component.hpp"
#include "equilibrium.hpp"
#include "chunk.hpp"
+#include "lbm_unit.hpp"
namespace kel {
namespace lbm {
@@ -31,6 +32,11 @@ public:
frequency_{saw::data<T>{1} / relaxation_}
{}
+ component(const saw::data<sch::Pure<T>>& relaxation__):
+ relaxation_{relaxation__.handle()},
+ frequency_{saw::data<T>{typename saw::native_data_type<T>::type(1)} / relaxation_}
+ {}
+
using Component = cmpt::BGK;
/**
diff --git a/modules/core/c++/converter.hpp b/modules/core/c++/converter.hpp
index 600db0d..3f0638b 100644
--- a/modules/core/c++/converter.hpp
+++ b/modules/core/c++/converter.hpp
@@ -86,6 +86,11 @@ public:
saw::data<sch::Pure<T>> kinematic_viscosity_si_to_tau(const saw::data<sch::SiKinematicViscosity<T>>& kin_si) const {
return saw::data<sch::Pure<T>>{saw::data<typename saw::unit_division<sch::Pure<T>, sch::LbmKinematicViscosity<T>>::Schema >{df_info<T,Desc>::inv_cs2} * kinematic_viscosity_si_to_lbm(kin_si) + saw::data<sch::Pure<T>>{0.5}};
}
+
+ template<typename Desc>
+ saw::data<sch::Pure<T>> kinematic_viscosity_lbm_to_tau(const saw::data<sch::LbmKinematicViscosity<T>>& kin_lbm) const {
+ return saw::data<sch::Pure<T>>{saw::data<typename saw::unit_division<sch::Pure<T>, sch::LbmKinematicViscosity<T>>::Schema >{df_info<T,Desc>::inv_cs2} * kin_lbm + saw::data<sch::Pure<T>>{0.5}};
+ }
};
}
}
diff --git a/modules/core/c++/fplbm.hpp b/modules/core/c++/fplbm.hpp
index 0ab7903..d0cf023 100644
--- a/modules/core/c++/fplbm.hpp
+++ b/modules/core/c++/fplbm.hpp
@@ -60,6 +60,9 @@ private:
saw::data<T> relaxation_;
saw::data<T> frequency_;
public:
+ using Component = cmpt::FpLbm;
+public:
+
component(typename saw::native_data_type<T>::type relaxation__):
relaxation_{{relaxation__}},
frequency_{saw::data<T>{1} / relaxation_}
@@ -70,8 +73,10 @@ public:
frequency_{saw::data<T>{1} / relaxation_}
{}
- using Component = cmpt::FpLbm;
-
+ component(const saw::data<sch::Pure<T>>& relaxation__):
+ relaxation_{relaxation__.handle()},
+ frequency_{saw::data<T>{typename saw::native_data_type<T>::type(1)} / relaxation_}
+ {}
template<typename CellFieldSchema, typename MacroFieldSchema>
void apply(const saw::data<CellFieldSchema, Encode>& field, const saw::data<MacroFieldSchema,Encode>& macros, saw::data<sch::FixedArray<sch::UInt64,Descriptor::D>> index, saw::data<sch::UInt64> time_step) const {
@@ -359,7 +364,7 @@ public:
}, aabb.template get<"a">(), aabb.template get<"b">());
auto& pirb_acc = pirb.template get<"acceleration">();
- pirb_acc = force_p / (pg.template get<"total_mass">().at({}));
+ pirb_acc = global_force_ + force_p / (pg.template get<"total_mass">().at({}));
for(saw::data<sch::UInt64> i{0u}; i < sub_steps; ++i){
verlet_step_lambda<T,Descriptor::D>(pi,one / sss);
diff --git a/modules/core/c++/hlbm.hpp b/modules/core/c++/hlbm.hpp
index 0df5896..fc61f6a 100644
--- a/modules/core/c++/hlbm.hpp
+++ b/modules/core/c++/hlbm.hpp
@@ -59,6 +59,11 @@ public:
frequency_{typename saw::native_data_type<T>::type(1) / relaxation_}
{}
+ component(const saw::data<sch::Pure<T>>& relaxation__):
+ relaxation_{relaxation__.handle().get()},
+ frequency_{typename saw::native_data_type<T>::type(1) / relaxation_}
+ {}
+
template<typename CellFieldSchema, typename MacroFieldSchema>
void apply(const saw::data<CellFieldSchema, Encode>& field, const saw::data<MacroFieldSchema,Encode>& macros, saw::data<sch::FixedArray<sch::UInt64,Desc::D>> index, saw::data<sch::UInt64> time_step) const {
diff --git a/modules/core/c++/psm.hpp b/modules/core/c++/psm.hpp
index f5a8452..40323b3 100644
--- a/modules/core/c++/psm.hpp
+++ b/modules/core/c++/psm.hpp
@@ -48,6 +48,11 @@ public:
frequency_ = one / relaxation_;
}
+ component(const saw::data<sch::Pure<T>>& relaxation__):
+ relaxation_{relaxation__.handle()},
+ frequency_{saw::data<T>{typename saw::native_data_type<T>::type(1)} / relaxation_}
+ {}
+
template<typename CellFieldSchema, typename MacroFieldSchema>
void apply(const saw::data<CellFieldSchema, Encode>& field, const saw::data<MacroFieldSchema,Encode>& macros, saw::data<sch::FixedArray<sch::UInt64,Descriptor::D>> index, saw::data<sch::UInt64> time_step) const {