From dcee24278ed28d21cd3addffeeb8e5f9f7248602 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Tue, 17 Feb 2026 18:29:22 +0100 Subject: End of day --- lib/core/c++/descriptor.hpp | 10 ++++--- lib/core/c++/environment.hpp | 1 + lib/core/c++/equilibrium.hpp | 3 ++- lib/core/c++/lbm.hpp | 1 + lib/core/c++/memory.hpp | 62 ++++++++++++++++++++++++++++++++++++++++++++ lib/core/c++/write_vtk.hpp | 22 ++++++++++++++-- 6 files changed, 93 insertions(+), 6 deletions(-) create mode 100644 lib/core/c++/memory.hpp (limited to 'lib/core/c++') diff --git a/lib/core/c++/descriptor.hpp b/lib/core/c++/descriptor.hpp index 9cc2591..e38daee 100644 --- a/lib/core/c++/descriptor.hpp +++ b/lib/core/c++/descriptor.hpp @@ -180,6 +180,7 @@ public: static constexpr std::array, Q> directions = {{ { 0, 0, 0}, // 0 + // Into 1D {-1, 0, 0}, // 1 { 1, 0, 0}, // 2 // Expand into 2D @@ -212,14 +213,17 @@ public: static constexpr std::array::type,Q> weights = { 8./27., - 1./9., - 1./9., - 1./9., + // 1D + 2./27., + 2./27., + // 2D + 2./27., 1./9., 1./36., 1./36., 1./36., 1./36., + // 3D 8./27., 1./9., 1./9., diff --git a/lib/core/c++/environment.hpp b/lib/core/c++/environment.hpp index 4915e3a..9e587d0 100644 --- a/lib/core/c++/environment.hpp +++ b/lib/core/c++/environment.hpp @@ -20,5 +20,6 @@ saw::error_or output_directory(){ return std::filesystem::path{home_dir} / ".lbm"; } + } } diff --git a/lib/core/c++/equilibrium.hpp b/lib/core/c++/equilibrium.hpp index 7d1324e..eb2b043 100644 --- a/lib/core/c++/equilibrium.hpp +++ b/lib/core/c++/equilibrium.hpp @@ -9,6 +9,7 @@ saw::data> equilibrium(saw::data; saw::data> eq; + // Brain broken, here's an owl // ^ // 0.0 // / \ @@ -23,7 +24,7 @@ saw::data> equilibrium(saw::data(); ++i){ + for(uint64_t i = 0u; i < Descriptor::Q; ++i){ saw::data vel_c{}; for(uint64_t j = 0u; j < Descriptor::D; ++j){ // _2 diff --git a/lib/core/c++/lbm.hpp b/lib/core/c++/lbm.hpp index 24f93f1..df89a69 100644 --- a/lib/core/c++/lbm.hpp +++ b/lib/core/c++/lbm.hpp @@ -14,6 +14,7 @@ #include "iterator.hpp" #include "hlbm.hpp" #include "macroscopic.hpp" +#include "memory.hpp" #include "stream.hpp" #include "write_vtk.hpp" #include "util.hpp" diff --git a/lib/core/c++/memory.hpp b/lib/core/c++/memory.hpp new file mode 100644 index 0000000..b6a089e --- /dev/null +++ b/lib/core/c++/memory.hpp @@ -0,0 +1,62 @@ +#pragma once + +#include "common.hpp" +#include "chunk.hpp" + +namespace kel { +namespace lbm { + +namespace impl { + +template +struct memory_size_helper; + +template +struct memory_size_helper> { + static constexpr uint64_t bytes = N; +}; + +template +struct memory_size_helper> { + static constexpr uint64_t bytes = saw::ct_multiply::value * memory_size_helper::bytes; +}; + +template +struct memory_size_helper> { + static constexpr uint64_t bytes = memory_size_helper::InnerSchema>::bytes; +}; + +template +class memory_estimate_helper final { +private: + + template + static void apply_i(saw::data& bytes){ + + if constexpr ( i < sizeof...(T)){ + using T_I = typename saw::parameter_pack_type::type; + + bytes.set(bytes.get() + memory_size_helper::bytes); + + apply_i(bytes); + } + } + +public: + + static void apply(saw::data& bytes){ + apply_i<0u>(bytes); + } +}; +} + +template +saw::data memory_estimate(){ + saw::data bytes; + + impl::memory_estimate_helper::apply(bytes); + + return bytes; +} +} +} diff --git a/lib/core/c++/write_vtk.hpp b/lib/core/c++/write_vtk.hpp index f7b8f8f..f925361 100644 --- a/lib/core/c++/write_vtk.hpp +++ b/lib/core/c++/write_vtk.hpp @@ -222,9 +222,27 @@ struct lbm_vtk_writer, } template -saw::error_or write_vtk_file(const std::filesystem::path& file_name, const saw::data& field){ +saw::error_or write_vtk_file(const std::filesystem::path& out_dir, const std::string_view& file_name, uint64_t d_t, const saw::data& field){ + + auto vtk_dir = out_dir / "vtk"; + { + std::error_code ec; + std::filesystem::create_directories(vtk_dir,ec); + if(ec != std::errc{}){ + return saw::make_error("Could not create directory for write_vtk_file function"); + } + } + std::string ft_name{file_name}; + + std::stringstream sstr; + sstr + <("Could not open file."); -- cgit v1.2.3