diff options
| -rw-r--r-- | modules/core/c++/hlbm.hpp | 15 | ||||
| -rw-r--r-- | modules/core/tests/particles.cpp | 11 |
2 files changed, 20 insertions, 6 deletions
diff --git a/modules/core/c++/hlbm.hpp b/modules/core/c++/hlbm.hpp index 346ec04..d9fb3de 100644 --- a/modules/core/c++/hlbm.hpp +++ b/modules/core/c++/hlbm.hpp @@ -155,25 +155,34 @@ public: template<typename T, typename Desc, typename Encode> class component<T, Desc, cmpt::HlbmOneParticleMomentumExchange, Encode> final { public: - template<typename CellFieldSchema, typename MacroFieldSchema, typename ParticleSchema> + 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 { // using dfi = df_info<T,Desc>; bool is_even = ((time_step.get() % 2) == 0); auto& dfs_old_f = (is_even) ? field.template get<"dfs_old">() : field.template get<"dfs">(); + auto& dfs = dfs_old_f.at(index); saw::data<sch::Vector<T,Desc::D>> momentum; for(uint64_t i = 0u; i < Desc::Q; ++i){ - saw::data<sch::Vector<sch::Int32,Desc::D>> e_i; + saw::data<sch::Vector<T,Desc::D>> e_i; + saw::data<sch::FixedArray<sch::UInt64,Desc::D>> n_ind_i; for(uint64_t k{0u}; k < Desc::D; ++k){ e_i.at({{k}}) = dfi::directions[i][k]; + n_ind_i.at({k}) = (dfi::directions[i])[k]; } + uint64_t i_opp = dfi::opposite_index[i]; - momentum = momentum + e_i * (dfs_old_f.at({{i}}) + dfs_old_f.at({{i_opp}})); + saw::data<T> dfs_added = dfs.at({i}) + dfs_old_f.at(n_ind_i).at({i_opp}); + saw::data<sch::Scalar<T>> dfs_added_v; + dfs_added_v.at({}) = dfs_added; + auto ei_dfs = e_i * dfs_added_v; + + momentum = momentum + ei_dfs; } auto& force_f = macros.template get<"force">(); diff --git a/modules/core/tests/particles.cpp b/modules/core/tests/particles.cpp index f474e3b..08da227 100644 --- a/modules/core/tests/particles.cpp +++ b/modules/core/tests/particles.cpp @@ -276,10 +276,15 @@ SAW_TEST("Verlet integration test 2D"){ SAW_TEST("Spheroid Particle / AABB"){ using namespace kel; - auto spheroid_pgrp = lbm::create_spheroid_particle_group<sch::Float64, lbm::coll::Spheroid<sch::Float64>>({},{},{8u}); + using T = sch::Float64; - auto res = lbm::particle_aabb<sch::Float64,sch::ParticleGroup<T,D,coll::Spheroid<T>>>::calculate(spheroid_pgrp); + saw::data<sch::Scalar<T>> radi,dense; + radi.at({}) = 2.0f; + dense.at({}) = 1.0f; + auto spheroid_pgrp = lbm::create_spheroid_particle_group<T,2u>(radi,dense,{8u}); - std::cout<<res<<std::endl; + // auto res = lbm::particle_aabb<sch::Float64,sch::ParticleGroup<T,D,coll::Spheroid<T>>>::calculate(spheroid_pgrp); + + // std::cout<<res<<std::endl; } } |
