summaryrefslogtreecommitdiff
path: root/lib/core/c++/macroscopic.hpp
diff options
context:
space:
mode:
authorClaudius "keldu" Holeksa <mail@keldu.de>2026-02-04 16:28:48 +0100
committerClaudius "keldu" Holeksa <mail@keldu.de>2026-02-04 16:28:48 +0100
commitba9c23e4177ab9309f69155601578b118b2fd782 (patch)
tree6b365d7a361eca6b15e7fd37c105724ed79f0639 /lib/core/c++/macroscopic.hpp
parent2ae8aaa474f888ed7a5a3810cd916977df6d0dcf (diff)
downloadlibs-lbm-ba9c23e4177ab9309f69155601578b118b2fd782.tar.gz
Weird missing vtk writes
Diffstat (limited to 'lib/core/c++/macroscopic.hpp')
-rw-r--r--lib/core/c++/macroscopic.hpp93
1 files changed, 6 insertions, 87 deletions
diff --git a/lib/core/c++/macroscopic.hpp b/lib/core/c++/macroscopic.hpp
index 1532873..19ab3e9 100644
--- a/lib/core/c++/macroscopic.hpp
+++ b/lib/core/c++/macroscopic.hpp
@@ -4,113 +4,32 @@
namespace kel {
namespace lbm {
-template<typename T, typename Desc>
-void compute_rho_u (
- const saw::data<sch::FixedArray<T,Desc::Q>>& dfs,
- saw::data<T>& rho,
- saw::data<sch::FixedArray<T,Desc::D>>& vel
- )
-{
- using dfi = df_info<T, Desc>;
-
- rho = 0;
- for(size_t j = 0; j < Desc::D; ++j){
- vel.at({{j}}).set(0);
- }
-
- for(size_t j = 0; j < Desc::Q; ++j){
- rho = rho + dfs.at({j});
- for(size_t i = 0; i < Desc::D; ++i){
- vel.at({{i}}) = vel.at({{i}}) + dfi::directions[j][i] * dfs.at({j}).get();
- }
- }
-
- for(size_t i = 0; i < Desc::D; ++i){
- vel.at({i}) = vel.at({i}) / rho;
- }
-}
-/**
- * Calculate the macroscopic variables rho and u in Lattice Units.
- */
-template<typename T, typename Desc>
-void compute_rho_u (
- const saw::data<sch::Cell<T, Desc, 0, 0, 1>>& dfs,
- typename saw::native_data_type<T>::type& rho,
- std::array<typename saw::native_data_type<T>::type, 2>& vel
- )
-{
- using dfi = df_info<T, Desc>;
-
- rho = 0;
- std::fill(vel.begin(), vel.end(), 0);
-
- for(size_t j = 0; j < Desc::Q; ++j){
- rho += dfs(j).get();
- for(size_t i = 0; i < Desc::D; ++i){
- vel[i] += dfi::directions[j][i] * dfs(j).get();
- }
- }
-
- for(size_t i = 0; i < Desc::D; ++i){
- vel[i] /= rho;
- }
-}
-
/**
* Calculate the macroscopic variables rho and u in Lattice Units.
*/
template<typename T, typename Desc>
void compute_rho_u (
- const saw::data<sch::Cell<T, Desc, 0, 0, 1>>& dfs,
- saw::ref<saw::data<T>> rho,
- saw::ref<saw::data<sch::FixedArray<T,Desc::D>>> vel
- )
-{
- using dfi = df_info<T, Desc>;
-
- rho().set(0);
- for(uint64_t i = 0; i < Desc::D; ++i){
- vel().at({i}).set(0);
- }
-
- for(size_t j = 0; j < Desc::Q; ++j){
- rho() = rho() + dfs(j);
- for(size_t i = 0; i < Desc::D; ++i){
- 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().at({i}) = vel().at({i}) / rho();
- }
-}
-
-/**
- * Calculate the macroscopic variables rho and u in Lattice Units.
- */
-template<typename T, typename Desc>
-void compute_rho_u (
- const saw::data<sch::Cell<T, Desc, 0, 0, 1>>& dfs,
- saw::ref<saw::data<T>> rho,
+ const saw::data<sch::FixedArray<T,Desc::Q>>& dfs,
+ saw::ref<saw::data<sch::Scalar<T>>> rho,
saw::ref<saw::data<sch::Vector<T,Desc::D>>> vel
)
{
using dfi = df_info<T, Desc>;
- rho().set(0);
+ rho().at({}).set(0);
for(uint64_t i = 0; i < Desc::D; ++i){
vel().at({{i}}).set(0);
}
for(size_t j = 0; j < Desc::Q; ++j){
- rho() = rho() + dfs(j);
+ rho().at({}) = rho().at({}) + dfs.at({j});
for(size_t i = 0; i < Desc::D; ++i){
- vel().at({{i}}) = vel().at({{i}}) + saw::data<T>{static_cast<typename saw::native_data_type<T>::type>(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.at({j});
}
}
for(size_t i = 0; i < Desc::D; ++i){
- vel().at({{i}}) = vel().at({{i}}) / rho();
+ vel().at({{i}}) = vel().at({{i}}) / rho().at({});
}
}
}