diff options
| author | Claudius "keldu" Holeksa <mail@keldu.de> | 2025-11-07 15:45:14 +0100 |
|---|---|---|
| committer | Claudius "keldu" Holeksa <mail@keldu.de> | 2025-11-07 15:45:14 +0100 |
| commit | d9c7b84f757c8e2935eddce74c095a8448b99c55 (patch) | |
| tree | cbd9f6e4aff1f01692c7607ccee0d7e0f57a0c56 | |
| parent | 76c505727034567a5e8fad647f73af3b2f2141cd (diff) | |
| download | libs-lbm-d9c7b84f757c8e2935eddce74c095a8448b99c55.tar.gz | |
Adding ptr based access
| -rw-r--r-- | lib/core/c++/boundary.hpp | 22 | ||||
| -rw-r--r-- | lib/core/c++/collision.hpp | 22 |
2 files changed, 44 insertions, 0 deletions
diff --git a/lib/core/c++/boundary.hpp b/lib/core/c++/boundary.hpp index c10784c..5549a80 100644 --- a/lib/core/c++/boundary.hpp +++ b/lib/core/c++/boundary.hpp @@ -62,6 +62,28 @@ public: dfs_old({i}) = df_cpy({dfi::opposite_index.at(i)}); } } + + template<typename CellStructSchema> + void apply( + saw::data<CellStructSchema, Encode>* field, + const saw::data<sch::FixedArray<sch::UInt64,Descriptor::D>>& meta, + const saw::data<sch::FixedArray<sch::UInt64,Descriptor::D>>& index, + saw::data<sch::UInt64> time_step + ){ + bool is_even = ((time_step.get() % 2) == 0); + auto& cell = field[0u]; + + auto& dfs_old = (is_even) ? cell.template get<"dfs_old">() : cell.template get<"dfs">(); + + saw::data<T> rho; + saw::data<sch::FixedArray<T,Descriptor::D>> vel; + compute_rho_u<T,Descriptor>(dfs_old,rho,vel); + auto eq = equilibrium<T,Descriptor>(rho,vel); + + for(uint64_t i = 0u; i < Descriptor::Q; ++i){ + dfs_old({i}) = dfs_old({i}) + frequency_ * (eq.at(i) - dfs_old({i})); + } + } }; /** diff --git a/lib/core/c++/collision.hpp b/lib/core/c++/collision.hpp index 73e86ae..2f20601 100644 --- a/lib/core/c++/collision.hpp +++ b/lib/core/c++/collision.hpp @@ -62,6 +62,28 @@ public: // dfs_old({i}).set(dfs_old({i}).get() + (1.0 / relaxation_) * (eq.at(i).get() - dfs_old({i}).get())); } } + + template<typename CellStructSchema> + void apply( + saw::data<CellStructSchema, Encode>* field, + const saw::data<sch::FixedArray<sch::UInt64,Descriptor::D>>& meta, + const saw::data<sch::FixedArray<sch::UInt64,Descriptor::D>>& index, + saw::data<sch::UInt64> time_step + ){ + bool is_even = ((time_step.get() % 2) == 0); + auto& cell = field[0u]; + + auto& dfs_old = (is_even) ? cell.template get<"dfs_old">() : cell.template get<"dfs">(); + + saw::data<T> rho; + saw::data<sch::FixedArray<T,Descriptor::D>> vel; + compute_rho_u<T,Descriptor>(dfs_old,rho,vel); + auto eq = equilibrium<T,Descriptor>(rho,vel); + + for(uint64_t i = 0u; i < Descriptor::Q; ++i){ + dfs_old({i}) = dfs_old({i}) + frequency_ * (eq.at(i) - dfs_old({i})); + } + } }; template<typename T, typename Descriptor, typename Encode> |
