diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/core/c++/hlbm.hpp | 22 | ||||
| -rw-r--r-- | lib/core/c++/iterator.hpp | 31 | ||||
| -rw-r--r-- | lib/core/c++/math/n_linear.hpp | 3 | ||||
| -rw-r--r-- | lib/core/c++/particle/particle.hpp | 21 | ||||
| -rw-r--r-- | lib/core/c++/term_renderer.hpp | 6 | ||||
| -rw-r--r-- | lib/core/tests/iterator.cpp | 17 |
6 files changed, 91 insertions, 9 deletions
diff --git a/lib/core/c++/hlbm.hpp b/lib/core/c++/hlbm.hpp index 41e2e27..196de73 100644 --- a/lib/core/c++/hlbm.hpp +++ b/lib/core/c++/hlbm.hpp @@ -7,14 +7,15 @@ namespace kel { namespace lbm { namespace cmpt { -struct HLBM {}; +struct Hlbm {}; +struct HlbmParticle {}; } /** * HLBM collision operator for LBM */ template<typename T, typename Descriptor, typename Encode> -class component<T, Descriptor, cmpt::HLBM, Encode> final { +class component<T, Descriptor, cmpt::Hlbm, Encode> final { private: typename saw::native_data_type<T>::type relaxation_; saw::data<T> frequency_; @@ -65,5 +66,22 @@ public: } }; +template<typename T, typename Descriptor, typename Encode> +class component<T, Descriptor, cmpt::HlbmParticle, Encode> final { +private: + typename saw::native_data_type<T>::type relaxation_; + saw::data<T> frequency_; +public: + + template<typename CellFieldSchema, typename MacroFieldSchema, typename ParticleSchema> + void apply(const saw::data<CellFieldSchema, Encode>& field, const saw::data<MacroFieldSchema,Encode>& macros, const saw::data<ParticleSchema,Encode>& particles, saw::data<sch::FixedArray<sch::UInt64,1u>> index, saw::data<sch::UInt64> time_step) const { + /// Figure out how to access the particle list + // auto& p = particles.at(i); + + /// Iterate over the grid bounds + // auto& grid = p.template get<"grid">(); + + } +}; } } diff --git a/lib/core/c++/iterator.hpp b/lib/core/c++/iterator.hpp index 866543a..7fd6f58 100644 --- a/lib/core/c++/iterator.hpp +++ b/lib/core/c++/iterator.hpp @@ -50,6 +50,37 @@ public: } }; +template<typename Tupl> +struct ct_tuple_iterator; + +template<typename... Tup> +struct ct_tuple_iterator<sch::Tuple<Tup...>> final { +private: + template<typename Func, uint64_t i> + static constexpr saw::error_or<void> apply_i( + Func& func, + saw::data<sch::Tuple<Tup...>>& tup + ){ + if constexpr ( i < sizeof...(Tup) ){ + auto eov = func(tup.template get<i>()); + if(eov.is_error()){ + return eov; + } + return apply_i<Func,i+1u>(func,tup); + } + + return saw::make_void(); + } +public: + template<typename Func> + static constexpr saw::error_or<void> apply( + Func&& func, + saw::data<sch::Tuple<Tup...>>& tup + ){ + return apply_i<Func,0u>(func,tup); + } +}; + /* Ambiguous template<typename Func> void iterate_over(Func&& func, const saw::data<sch::FixedArray<sch::UInt64,3u>>& start, const saw::data<sch::FixedArray<sch::UInt64,3u>>& end, const saw::data<sch::FixedArray<sch::UInt64,3u>>& dist = {{{0u,0u,0u}}}){ diff --git a/lib/core/c++/math/n_linear.hpp b/lib/core/c++/math/n_linear.hpp index 8fb0600..b378440 100644 --- a/lib/core/c++/math/n_linear.hpp +++ b/lib/core/c++/math/n_linear.hpp @@ -122,6 +122,9 @@ auto n_linear_interpolate( } }, {}, ones_ind); + + /// TODO I need to actually calc stuff + return field.at({}); } template<typename FieldSchema, typename T> diff --git a/lib/core/c++/particle/particle.hpp b/lib/core/c++/particle/particle.hpp index 7af43dc..5110893 100644 --- a/lib/core/c++/particle/particle.hpp +++ b/lib/core/c++/particle/particle.hpp @@ -55,6 +55,8 @@ template<typename T, uint64_t D, typename CollisionType = ParticleCollisionSpher using ParticleGroup = Struct< Member<Array<T,D>, "mask">, Member<FixedArray<Scalar<T>,1u>, "density">, + Member<Vector<T,D>, "center_of_mass">, + Member<Scalar<T>, "total_mass">, Member<Array<Particle<T,D>>, "particles"> >; } @@ -76,10 +78,20 @@ saw::data<sch::ParticleGroup<T,D, sch::ParticleCollisionSpheroid<T,radius>>> cre for(uint64_t i = 0u; i < D; ++i){ mask_dims.at({i}) = mask_resolution; } + saw::data<sch::Scalar<T>> mask_step; + saw::data<T> dia_d{radius*2}; + mask_step.at({}) = dia_d / mask_resolution.template cast_to<T>(); mask = {mask_dims}; + + auto& com = part.template get<"center_of_mass">(); + for(uint64_t i = 0u; i < D; ++i){ + com.at({{i}}) = {}; + } + saw::data<sch::UInt64> ele_ctr{0u}; iterator<D>::apply([&](const auto& index){ - + ++ele_ctr; + },{},mask_dims); return part; @@ -238,5 +250,12 @@ constexpr auto broadphase_collision_check = []( ) -> bool{ return broadphase_collision_distance_squared<T,D,Collision>(left,coll_l,right,coll_r).first; }; + + + +namespace impl { + +} + } } diff --git a/lib/core/c++/term_renderer.hpp b/lib/core/c++/term_renderer.hpp deleted file mode 100644 index 5cbb551..0000000 --- a/lib/core/c++/term_renderer.hpp +++ /dev/null @@ -1,6 +0,0 @@ -#pragma once - -namespace kel { -namespace lbm { -} -} diff --git a/lib/core/tests/iterator.cpp b/lib/core/tests/iterator.cpp index 261765a..919c12c 100644 --- a/lib/core/tests/iterator.cpp +++ b/lib/core/tests/iterator.cpp @@ -20,6 +20,23 @@ SAW_TEST("Old Iterate"){ }, start, end); } +SAW_TEST("CT Tuple Iterator"){ + using namespace kel; + + saw::data< + sch::Tuple< + sch::Float32, + sch::Int16, + sch::Float64, + sch::UInt32 + > + > tup; + + lbm::ct_tuple_iterator<std::decay_t<decltype(tup)>::Schema>::apply([](auto& val) -> saw::error_or<void> { + return saw::make_void(); + },tup); +} + SAW_TEST("Old Iterate with Distance 1"){ using namespace kel; |
