summaryrefslogtreecommitdiff
path: root/c++
diff options
context:
space:
mode:
Diffstat (limited to 'c++')
-rw-r--r--c++/environment.hpp19
-rw-r--r--c++/lbm.hpp1
-rw-r--r--c++/particle/geometry/circle.hpp2
-rw-r--r--c++/particle/particle.hpp16
-rw-r--r--c++/write_vtk.hpp6
5 files changed, 38 insertions, 6 deletions
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 <forstio/error.hpp>
+#include <filesystem>
+#include <cstdlib>
+
+namespace kel {
+namespace lbm {
+
+saw::error_or<std::filesystem::path> output_directory(){
+ const char* home_dir = std::getenv("HOME");
+ if(not home_dir){
+ return saw::make_error<saw::err::not_found>("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<typename MT>
+ template<typename MT = T>
saw::data<sch::ParticleMask<MT,2>> generate_mask(uint64_t resolution, uint64_t boundary_nodes = 0) const {
saw::data<sch::ParticleMask<MT,2>> 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<typename T, uint64_t D>
using Particle = Struct<
Member<ParticleRigidBody<T,D>, "rigid_body">,
- Member<ParticleMask<Float32,D>, "mask">
+ Member<ParticleMask<Float32,D>, "mask">,
+ Member<T, "size">
>;
}
@@ -69,9 +70,10 @@ public:
return size;
}
+ /*
saw::data<sch::Particle<T,D>>& get_particle(saw::data<sch::UInt64> id){
-
}
+ */
void step(saw::data<T> time_step_delta){
for(saw::data<sch::UInt64> i{0u}; i < particles_.size(); ++i){
@@ -82,9 +84,19 @@ public:
template<typename LbmLattice>
void update_particle_border(saw::data<LbmLattice>& latt){
for(auto& iter : particles_){
+ auto& par = iter;
+
+ auto& body = par.template get<"rigid_body">();
+ auto& size = par.template get<"size">();
+
+
}
}
+ saw::data<sch::UInt64> 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 <fstream>
+#include <filesystem>
namespace kel {
namespace lbm {
@@ -162,10 +163,9 @@ struct lbm_vtk_writer<sch::Array<sch::Struct<sch::Member<StructT,StructN>...> ,
}
template<typename Struct>
-saw::error_or<void> write_vtk_file(const std::string_view file_name, const saw::data<Struct>& field){
+saw::error_or<void> write_vtk_file(const std::filesystem::path& file_name, const saw::data<Struct>& 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<saw::err::critical>("Could not open file.");