diff options
| author | Claudius "keldu" Holeksa <mail@keldu.de> | 2026-04-22 16:49:30 +0200 |
|---|---|---|
| committer | Claudius "keldu" Holeksa <mail@keldu.de> | 2026-04-22 16:49:30 +0200 |
| commit | 1aee54ea763a19590f4aa41f991cef8f91cf6a93 (patch) | |
| tree | 7e45e43e9152520d97f991d62dd86362c27cd054 /lib/core/c++ | |
| parent | 0f0af5c3e095637c7ede1c8dc20b248a3471dc3a (diff) | |
| parent | 45ebf7411d687ab5530431ab1bcc74edb0499c69 (diff) | |
| download | libs-lbm-1aee54ea763a19590f4aa41f991cef8f91cf6a93.tar.gz | |
Merge branch 'dev'
Diffstat (limited to 'lib/core/c++')
| -rw-r--r-- | lib/core/c++/abstract/data.hpp | 26 | ||||
| -rw-r--r-- | lib/core/c++/particle.hpp | 5 | ||||
| -rw-r--r-- | lib/core/c++/particle/particle.hpp | 35 | ||||
| -rw-r--r-- | lib/core/c++/write_vtk.hpp | 4 |
4 files changed, 39 insertions, 31 deletions
diff --git a/lib/core/c++/abstract/data.hpp b/lib/core/c++/abstract/data.hpp index e8f1757..0075718 100644 --- a/lib/core/c++/abstract/data.hpp +++ b/lib/core/c++/abstract/data.hpp @@ -4,28 +4,48 @@ namespace kel { namespace sch { +struct Void {}; + struct UnsignedInteger {}; struct SignedInteger {}; struct FloatingPoint {}; template<typename StorageT, typename InterfaceT> struct MixedPrecision { + using Meta = Void; using StorageType = StorageT; using InterfaceType = InterfaceT; }; template<typename PrimType, uint64_t N> struct Primitive { - using PrimitiveType = PrimType; + using Meta = Void; + using Type = PrimType; static constexpr uint64_t Bytes = N; }; template<typename T, uint64_t... Dims> -struct Array { - using InnerType = T; +struct FixedArray { + using Meta = Void; + using Inner = T; static constexpr std::array<uint64_t,sizeof...(Dims)> Dimensions{Dims...}; }; +template<typename T, uint64_t Dims> +struct Array { + using Meta = FixedArray<UInt64,Dims>; + using Inner = T; + static constexpr std::array<uint64_t,sizeof...(Dims)> Dimensions{Dims}; +}; + +template<typename... T> +struct Tuple { +}; } + +template<typename Sch> +struct schema { + using Type = Sch; +}; } diff --git a/lib/core/c++/particle.hpp b/lib/core/c++/particle.hpp index b098ecc..691a74b 100644 --- a/lib/core/c++/particle.hpp +++ b/lib/core/c++/particle.hpp @@ -11,7 +11,12 @@ struct Particle {}; template<typename T, typename Descriptor, typename Encode> class component<T, Descriptor, cmpt::Particle, Encode> { +private: + saw::data<sch::Scalar<T>> dt_; public: + component(saw::data<sch::Scalar<T>> dt__): + dt_{dt__} + {} template<typename ParticleSchema, typename MacroFieldSchema> void apply(const saw::data<ParticleSchema, Encode>& particles, const saw::data<MacroFieldSchema,Encode>& macros, saw::data<sch::UInt64> index, saw::data<sch::UInt64> time_step) const { diff --git a/lib/core/c++/particle/particle.hpp b/lib/core/c++/particle/particle.hpp index c0d115f..7af43dc 100644 --- a/lib/core/c++/particle/particle.hpp +++ b/lib/core/c++/particle/particle.hpp @@ -40,9 +40,8 @@ using ParticleRigidBody = Struct< Member<typename impl::rotation_type_helper<T,D>::Schema, "angular_acceleration"> >; -template<typename T> +template<typename T, typename saw::native_data_type<T>::type radius = 1.0f> using ParticleCollisionSpheroid = Struct< - Member<Scalar<T>, "radius"> >; template<typename T, uint64_t D> @@ -52,42 +51,26 @@ using Particle = Struct< // Member<Array<Float64,D>, "mask">, >; -template<typename T, uint64_t D, typename CollisionType = ParticleCollisionSpheroid<T>> +template<typename T, uint64_t D, typename CollisionType = ParticleCollisionSpheroid<T,2.0f>> using ParticleGroup = Struct< Member<Array<T,D>, "mask">, - Member<CollisionType, "collision">, - Member<Scalar<T>, "mass">, + Member<FixedArray<Scalar<T>,1u>, "density">, Member<Array<Particle<T,D>>, "particles"> >; } -template<typename T, uint64_t D> -saw::data<sch::ParticleGroup<T,D, sch::ParticleCollisionSpheroid<T>>> create_spheroid_particle_group( - saw::data<sch::Scalar<T>> rad_p, +template<typename T, uint64_t D, typename saw::native_data_type<T>::type radius> +saw::data<sch::ParticleGroup<T,D, sch::ParticleCollisionSpheroid<T,radius>>> create_spheroid_particle_group( saw::data<sch::Scalar<T>> density_p, const saw::data<sch::UInt64>& mask_resolution ){ - saw::data<sch::ParticleGroup<T,D,sch::ParticleCollisionSpheroid<T>>> part; + saw::data<sch::ParticleGroup<T,D,sch::ParticleCollisionSpheroid<T,2.0f>>> part; auto& mask = part.template get<"mask">(); - auto& collision = part.template get<"collision">(); - auto& mass = part.template get<"mass">(); + auto& density = part.template get<"density">().at({{0u}}); - if constexpr ( D == 1u ){ - saw::data<sch::Scalar<T>> c; - c.at({}).set(2.0); - mass = rad_p * c * density_p; - } else if constexpr ( D == 2u){ - saw::data<sch::Scalar<T>> pi; - pi.at({}).set(3.14159); - mass = rad_p * rad_p * pi * density_p; - } else if constexpr ( D == 3u ){ - saw::data<sch::Scalar<T>> c; - c.at({}).set(3.14159 * 4.0 / 3.0); - mass = rad_p * rad_p * rad_p * c * density_p; - } else { - static_assert(D == 0u or D > 3u, "Dimensions only supported for Dim 1,2 & 3."); - } + static_assert(D >= 1u and D <= 3u, "Dimensions only supported for Dim 1,2 & 3."); + density = density_p; saw::data<sch::FixedArray<sch::UInt64,D>> mask_dims; for(uint64_t i = 0u; i < D; ++i){ diff --git a/lib/core/c++/write_vtk.hpp b/lib/core/c++/write_vtk.hpp index f925361..e852172 100644 --- a/lib/core/c++/write_vtk.hpp +++ b/lib/core/c++/write_vtk.hpp @@ -136,7 +136,7 @@ struct lbm_vtk_writer<sch::Vector<T,D>> { template<typename T> struct lbm_vtk_writer<sch::Scalar<T>> { static saw::error_or<void> apply_header(std::ostream& vtk_file, std::string_view name){ - vtk_file<<"SCALARS "<<name<<" float\n"; + vtk_file<<"SCALARS "<<name<<" float 1\n"; vtk_file<<"LOOKUP_TABLE default\n"; return saw::make_void(); } @@ -206,7 +206,7 @@ struct lbm_vtk_writer<sch::Struct<sch::Member<sch::Chunk<MemberT,Ghost,Dims...>, if constexpr (sizeof...(MemberT) > 0u){ // POINT DATA { - vtk_file << "POINT_DATA " << pd_size.get() <<"\n"; + vtk_file << "\nPOINT_DATA " << pd_size.get() <<"\n"; } // HEADER TO BODY |
