From 4968da9a05df5c10fb1f10655189ae251b38f92b Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Wed, 30 Jul 2025 18:04:13 +0200 Subject: Way too many changes --- c++/environment.hpp | 19 +++++++++++++++++++ c++/lbm.hpp | 1 + c++/particle/geometry/circle.hpp | 2 +- c++/particle/particle.hpp | 16 ++++++++++++++-- c++/write_vtk.hpp | 6 +++--- 5 files changed, 38 insertions(+), 6 deletions(-) create mode 100644 c++/environment.hpp (limited to 'c++') diff --git a/c++/environment.hpp b/c++/environment.hpp new file mode 100644 index 0000000..6b63f16 --- /dev/null +++ b/c++/environment.hpp @@ -0,0 +1,19 @@ +#pragma once + +#include +#include +#include + +namespace kel { +namespace lbm { + +saw::error_or output_directory(){ + const char* home_dir = std::getenv("HOME"); + if(not home_dir){ + return saw::make_error("Couldn't find home dir"); + } + + return std::filesystem::path{home_dir} / ".lbm/"; +} +} +} diff --git a/c++/lbm.hpp b/c++/lbm.hpp index 6bcd1e7..a874e95 100644 --- a/c++/lbm.hpp +++ b/c++/lbm.hpp @@ -4,6 +4,7 @@ #include "converter.hpp" #include "config.hpp" #include "component.hpp" +#include "environment.hpp" #include "equilibrium.hpp" #include "macroscopic.hpp" #include "write_vtk.hpp" diff --git a/c++/particle/geometry/circle.hpp b/c++/particle/geometry/circle.hpp index e7b78f1..77fa9d8 100644 --- a/c++/particle/geometry/circle.hpp +++ b/c++/particle/geometry/circle.hpp @@ -12,7 +12,7 @@ public: particle_circle_geometry() {} - template + template saw::data> generate_mask(uint64_t resolution, uint64_t boundary_nodes = 0) const { saw::data> mask; diff --git a/c++/particle/particle.hpp b/c++/particle/particle.hpp index 35196ce..4aa6a0a 100644 --- a/c++/particle/particle.hpp +++ b/c++/particle/particle.hpp @@ -26,7 +26,8 @@ using ParticleMask = Struct< template using Particle = Struct< Member, "rigid_body">, - Member, "mask"> + Member, "mask">, + Member >; } @@ -69,9 +70,10 @@ public: return size; } + /* saw::data>& get_particle(saw::data id){ - } + */ void step(saw::data time_step_delta){ for(saw::data i{0u}; i < particles_.size(); ++i){ @@ -82,9 +84,19 @@ public: template void update_particle_border(saw::data& latt){ for(auto& iter : particles_){ + auto& par = iter; + + auto& body = par.template get<"rigid_body">(); + auto& size = par.template get<"size">(); + + } } + saw::data size() const { + return particles_.size(); + } + /** * Mostly meant for unforeseen use cases. */ diff --git a/c++/write_vtk.hpp b/c++/write_vtk.hpp index 40597fd..f81136a 100644 --- a/c++/write_vtk.hpp +++ b/c++/write_vtk.hpp @@ -7,6 +7,7 @@ #include "descriptor.hpp" #include +#include namespace kel { namespace lbm { @@ -162,10 +163,9 @@ struct lbm_vtk_writer...> , } template -saw::error_or write_vtk_file(const std::string_view file_name, const saw::data& field){ +saw::error_or write_vtk_file(const std::filesystem::path& file_name, const saw::data& field){ - std::string vtk_file_name{file_name}; - std::ofstream vtk_file{vtk_file_name}; + std::ofstream vtk_file{file_name}; if(!vtk_file.is_open()){ return saw::make_error("Could not open file."); -- cgit v1.2.3