diff options
| author | Claudius "keldu" Holeksa <mail@keldu.de> | 2026-07-23 16:53:05 +0200 |
|---|---|---|
| committer | Claudius "keldu" Holeksa <mail@keldu.de> | 2026-07-23 16:53:05 +0200 |
| commit | 3489ac1d725c0eadb7d75329f9e6074ed177d125 (patch) | |
| tree | 81e00012524b5b303770e0977769c24716d1f181 /modules/core | |
| parent | 25a1c2485c5187c61a8efc9f5b62d4d942124d47 (diff) | |
| download | libs-lbm-3489ac1d725c0eadb7d75329f9e6074ed177d125.tar.gz | |
Somethings wrong with the particle interaction
Diffstat (limited to 'modules/core')
| -rw-r--r-- | modules/core/c++/abstract/schema.hpp | 25 | ||||
| -rw-r--r-- | modules/core/c++/environment.hpp | 15 | ||||
| -rw-r--r-- | modules/core/c++/hlbm.hpp | 28 | ||||
| -rw-r--r-- | modules/core/c++/particle/particle.hpp | 12 | ||||
| -rw-r--r-- | modules/core/tests/schema.cpp | 3 |
5 files changed, 67 insertions, 16 deletions
diff --git a/modules/core/c++/abstract/schema.hpp b/modules/core/c++/abstract/schema.hpp index 8305005..8bc23b4 100644 --- a/modules/core/c++/abstract/schema.hpp +++ b/modules/core/c++/abstract/schema.hpp @@ -4,6 +4,7 @@ #include "templates.hpp" namespace kel { +namespace lbm { namespace sch { struct Void {}; @@ -26,6 +27,27 @@ struct Primitive { static constexpr uint64_t Bytes = N; }; +using UInt8 = Primitive<UnsignedInteger,1u>; +using UInt16 = Primitive<UnsignedInteger,2u>; +using UInt32 = Primitive<UnsignedInteger,4u>; +using UInt64 = Primitive<UnsignedInteger,8u>; + +using Int8 = Primitive<SignedInteger,1u>; +using Int16 = Primitive<SignedInteger,2u>; +using Int32 = Primitive<SignedInteger,4u>; +using Int64 = Primitive<SignedInteger,8u>; + +using Float8 = Primitive<FloatingPoint,1u>; +using Float16 = Primitive<FloatingPoint,2u>; +using Float32 = Primitive<FloatingPoint,4u>; +using Float64 = Primitive<FloatingPoint,8u>; + +template<typename Sch, uint64_t StorageBytes, uint64_t InterfaceBytes> +struct MixedPrecision { + using Meta = Void; + using Inner = Sch; +}; + template<typename T, uint64_t... Dims> struct FixedArray { using Meta = Void; @@ -37,7 +59,7 @@ 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}; + static constexpr std::array<uint64_t,1u> Dimensions{Dims}; }; template<typename... T> @@ -58,3 +80,4 @@ struct schema { }; } +} diff --git a/modules/core/c++/environment.hpp b/modules/core/c++/environment.hpp index d8aa9ae..ed9cd40 100644 --- a/modules/core/c++/environment.hpp +++ b/modules/core/c++/environment.hpp @@ -7,16 +7,23 @@ namespace kel { namespace lbm { -struct environment { +class environment { +public: std::string name; std::filesystem::path lbm_dir; std::filesystem::path data_dir; + std::filesystem::path name_dir; +public: }; -saw::error_or<environment> setup_lbm_env(const std::string_view name){ +template<typename ArgSch> +saw::error_or<environment> init_lbm_env(const saw::data<ArgSch>& args){ namespace fs = std::filesystem; + auto& args_n = args.template get<"args">(); + auto& name = args_n.template get<"name">(); + const char* home_dir = std::getenv("HOME"); if(not home_dir){ return saw::make_error<saw::err::not_found>("Couldn't find home dir"); @@ -42,6 +49,10 @@ saw::error_or<environment> setup_lbm_env(const std::string_view name){ } } + { + env.name_dir = env.data_dir / name.view(); + } + return env; } diff --git a/modules/core/c++/hlbm.hpp b/modules/core/c++/hlbm.hpp index 799d2b5..9356264 100644 --- a/modules/core/c++/hlbm.hpp +++ b/modules/core/c++/hlbm.hpp @@ -82,7 +82,7 @@ public: // Convex combination of velocities vel = vel * porosity + [&]() -> saw::data<sch::Vector<T,Desc::D>> { - return (D.at({}).get() > 0.0 ? N * flip_porosity / D : N); + return (D.at({}).get() > 0.0) ? ( N * flip_porosity / D ): N; }(); // Equilibrium auto eq = equilibrium<T,Desc>(rho,vel); @@ -125,7 +125,6 @@ public: auto& particle_N_f = field.template get<"particle_N">(); auto& particle_D_f = field.template get<"particle_D">(); - { auto parts = part_spheroid_group.template get<"particles">(); auto parts_size = parts.meta().at({0u}); @@ -136,6 +135,11 @@ public: auto& pi = parts.at(index); auto& pirb = pi.template get<"rigid_body">(); auto& pirb_pos = pirb.template get<"position">(); + auto& pirb_pos_old = pirb.template get<"position_old">(); + + // TODO !!!! Divide by actual time step - for now it's ok + saw::data<sch::Scalar<T>> ts; + ts.at({}) = 1.0f; saw::data<sch::FixedArray<sch::UInt64,Desc::D>> start; saw::data<sch::FixedArray<sch::UInt64,Desc::D>> stop; @@ -185,21 +189,23 @@ public: eps.at({}) = 1.5f; mpor = particle_porosity<T,Desc::D,1u,por::ParticleSpheroid<T>>::calculate(rel_dist,p_rad,eps); force_p = force_p + momentum * mpor; - - auto& N = particle_N_f.at(index_f); - auto& D = particle_D_f.at(index_f); - auto flip_porosity = one - mpor; - D = D + flip_porosity; - N = N + mvel_f.at(index_f) * flip_porosity; },start,stop); auto& pirb_acc = pirb.template get<"acceleration">(); - pirb_acc = force_p; + pirb_acc = force_p / part_spheroid_group.template get<"total_mass">().at({}); - saw::data<sch::Scalar<T>> ts; - ts.at({}) = 1u; verlet_step_lambda<T,Desc::D>(pi,ts); + auto vel_p = (pirb_pos-pirb_pos_old) / ts; + iterator<Desc::D>::apply([&](const auto& index_f){ + auto& N = particle_N_f.at(index_f); + auto& D = particle_D_f.at(index_f); + auto& mpor = mpor_f.at(index_f); + auto flip_porosity = one - mpor; + + D = D + flip_porosity; + N = N + vel_p * flip_porosity; + },start,stop); // Check } } diff --git a/modules/core/c++/particle/particle.hpp b/modules/core/c++/particle/particle.hpp index f759c8d..a3669b4 100644 --- a/modules/core/c++/particle/particle.hpp +++ b/modules/core/c++/particle/particle.hpp @@ -74,9 +74,19 @@ saw::data<sch::ParticleGroup<T, D, PartAmount, coll::Spheroid<T>>> create_sphero } total_mass.at({}) = total_mass.at({}) + dpi; - },{},mask_dims); + + // TODO ? Do mass properly + if constexpr ( D == 2u ) { + total_mass.at({}) = rad_d * rad_d * density.at({}) * 3.141592; + }else if constexpr ( D == 3u ){ + + }else if constexpr ( D== 1u ){ + + } + std::cout<<"Total Mass: "<<total_mass.at({}).get()<<std::endl; + for(uint64_t i = 0u; i < D; ++i){ com.at({{i}}) = com.at({{i}}) / total_mass.at({}); } diff --git a/modules/core/tests/schema.cpp b/modules/core/tests/schema.cpp index b705af0..5c884b4 100644 --- a/modules/core/tests/schema.cpp +++ b/modules/core/tests/schema.cpp @@ -1,5 +1,6 @@ #include <forstio/test/suite.hpp> +/* #include "../c++/abstract/schema.hpp" namespace { @@ -15,5 +16,5 @@ SAW_TEST("Abstract/Schema/Ptr"){ // static_assert(std::is_same_v<typename schema_decay<ts::TPtr>::Schema, ts::TVal>, "schema decay failed"); } - } +*/ |
