diff options
Diffstat (limited to 'c++')
-rw-r--r-- | c++/lbm.hpp | 1 | ||||
-rw-r--r-- | c++/macroscopic.hpp | 6 | ||||
-rw-r--r-- | c++/particle/particle.hpp | 33 |
3 files changed, 32 insertions, 8 deletions
diff --git a/c++/lbm.hpp b/c++/lbm.hpp index 1baaa0e..e5799b5 100644 --- a/c++/lbm.hpp +++ b/c++/lbm.hpp @@ -3,6 +3,7 @@ #include "descriptor.hpp" #include "converter.hpp" #include "config.hpp" +#include "write_vtk.hpp" #include <forstio/codec/unit/unit_print.hpp> #include <iostream> diff --git a/c++/macroscopic.hpp b/c++/macroscopic.hpp index e126bbe..8a25248 100644 --- a/c++/macroscopic.hpp +++ b/c++/macroscopic.hpp @@ -49,14 +49,14 @@ void compute_rho_u ( } for(size_t j = 0; j < Desc::Q; ++j){ - rho = rho + dfs(j); + rho() = rho() + dfs(j); for(size_t i = 0; i < Desc::D; ++i){ - vel[i] = vel[i] + saw::data<T>{dfi::directions[j][i]} * dfs(j); + vel().at({i}) = vel().at({i}) + saw::data<T>{static_cast<typename saw::native_data_type<T>::type>(dfi::directions[j][i])} * dfs(j); } } for(size_t i = 0; i < Desc::D; ++i){ - vel[i] = vel[i] / rho; + vel().at({i}) = vel().at({i}) / rho(); } } } diff --git a/c++/particle/particle.hpp b/c++/particle/particle.hpp index 1c7b241..35196ce 100644 --- a/c++/particle/particle.hpp +++ b/c++/particle/particle.hpp @@ -30,10 +30,10 @@ using Particle = Struct< >; } -template<typename T, uint64_t D, typename Particle> +template<typename T, uint64_t D, typename ParticleCollision = sch::ParticleMask<T,D> > class particle_system { private: - saw::data<sch::Array<Particle, D>> particles_; + saw::data<sch::Array<sch::Particle<T,D>>> particles_; void verlet_step(saw::data<sch::Particle<T,D>>& particle, saw::data<T> time_step_delta){ auto& body = particle.template get<"rigid_body">(); @@ -56,10 +56,26 @@ private: pos = pos_new; } public: + /** + * Add particle to this class and return an id representing this particle + */ + saw::error_or<saw::data<sch::UInt64>> add_particle(saw::data<sch::Particle<T,D>> particle__){ + auto size = particles_.size(); + auto eov = particles_.add(std::move(particle__)); + if(eov.is_error()){ + return std::move(eov.get_error()); + } - void step(T time_step_delta){ - for(auto& iter : particles_){ - verlet_step(time_step_delta); + return size; + } + + saw::data<sch::Particle<T,D>>& get_particle(saw::data<sch::UInt64> id){ + + } + + void step(saw::data<T> time_step_delta){ + for(saw::data<sch::UInt64> i{0u}; i < particles_.size(); ++i){ + verlet_step(particles_.at(i), time_step_delta); } } @@ -68,6 +84,13 @@ public: for(auto& iter : particles_){ } } + + /** + * Mostly meant for unforeseen use cases. + */ + saw::data<sch::Particle<T,D>>& at(saw::data<sch::UInt64> i){ + return particles_.at(i); + } }; } } |