summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples/heterogeneous_computing/README.md7
-rw-r--r--examples/heterogeneous_computing/heterogeneous_computing.cpp7
-rw-r--r--examples/particles_gpu/particles_gpu.cpp32
-rw-r--r--flake.nix13
4 files changed, 52 insertions, 7 deletions
diff --git a/examples/heterogeneous_computing/README.md b/examples/heterogeneous_computing/README.md
new file mode 100644
index 0000000..16463e6
--- /dev/null
+++ b/examples/heterogeneous_computing/README.md
@@ -0,0 +1,7 @@
+# Heterogeneous
+
+This is more intended as a thinking ground for a solution to LBM integrations for distributed computing.
+In the end MPI does it correctly in a sense I would almost ask to separate in blocks.
+But I want to learn, so no MPI.
+Or rather MPI abstracted away.
+MPI also has some discovery issues in edge cases where the network is a bit more complex.
diff --git a/examples/heterogeneous_computing/heterogeneous_computing.cpp b/examples/heterogeneous_computing/heterogeneous_computing.cpp
index 990652a..8a79354 100644
--- a/examples/heterogeneous_computing/heterogeneous_computing.cpp
+++ b/examples/heterogeneous_computing/heterogeneous_computing.cpp
@@ -1,21 +1,24 @@
#include <forstio/error.hpp>
#include <iostream>
+
namespace kel {
+namespace lbm {
namespace sch {
using namespace saw::schema;
using KelConfig = Struct<
Member<String,"resolution">
>;
}
+}
-saw::error_or<void> real_main(int argc, char** argv){
+saw::error_or<void> lbm_main(int argc, char** argv){
return saw::make_void();
}
}
int main(int argc, char** argv){
- auto eov = kel::kel_main(argc, argv);
+ auto eov = kel::lbm_main(argc, argv);
if(eov.is_error()){
auto& err = eov.get_error();
auto err_msg = err.get_message();
diff --git a/examples/particles_gpu/particles_gpu.cpp b/examples/particles_gpu/particles_gpu.cpp
index 2f2d691..2fa44c1 100644
--- a/examples/particles_gpu/particles_gpu.cpp
+++ b/examples/particles_gpu/particles_gpu.cpp
@@ -31,25 +31,32 @@ saw::error_or<void> lbm_main(int argc, char** argv){
auto& old_pos = body.template get<"position_old">();
auto& acceleration = body.template get<"acceleration">();
auto& p_size = part.template get<"size">();
- p_size = {0.5f};
+ auto& p_rad = part.template get<"collision">().template get<"radius">();
+ p_size = {0.4f};
+ p_rad = {0.4f};
- if(j.get() % 2u == 0) acceleration.at({{1u}}) = {9.81};
+ if(j.get() % 2u == 0) acceleration.at({{1u}}) = {-9.81};
- pos.at({{0u}}) = {i.template cast_to<sch::Float32>()};
- pos.at({{1u}}) = {j.template cast_to<sch::Float32>()};
+ pos.at({{0u}}) = {i.template cast_to<sch::Float32>()+0.5f};
+ pos.at({{1u}}) = {j.template cast_to<sch::Float32>()+64.0f};
old_pos = pos;
}
}
for(saw::data<sch::UInt64> dt{0u}; dt < saw::data<sch::UInt64>{32ul}; ++dt){
+ // Do Verlet Step
for(saw::data<sch::UInt64> i{0u}; i < particles.size(); ++i){
auto& part_i = particles.at(i);
verlet_step_lambda<sch::Float32,2u>(part_i,{0.05f});
}
+ //
for(saw::data<sch::UInt64> i{0u}; i < particles.size(); ++i){
auto& part_i = particles.at(i);
+ /**
+ * Test against other particles
+ */
for(saw::data<sch::UInt64> j{i+1ul}; j < particles.size(); ++j){
auto& part_j = particles.at(j);
@@ -58,9 +65,24 @@ saw::error_or<void> lbm_main(int argc, char** argv){
std::cout<<"Collision"<<std::endl;
}
}
+ /**
+ * Test against walls
+ */
+ auto& body_i = part_i.template get<"rigid_body">();
+ auto& pos_i = body_i.template get<"position">();
+ auto& pos_old_i = body_i.template get<"position_old">();
+ if(pos_i.at({{0u}}).get() <= 0 or pos_i.at({{0u}}).get() >= 40 ){
+ auto pos_i_0 = pos_i.at({{0u}});
+ pos_i.at({{0u}}) = pos_old_i.at({{0u}});
+ pos_old_i.at({{0u}}) = pos_i_0;
+ }
+ if(pos_i.at({{1u}}).get() <= 0 or pos_i.at({{1u}}).get() >= 40 ){
+ auto pos_i_1 = pos_i.at({{1u}});
+ pos_i.at({{1u}}) = pos_old_i.at({{1u}});
+ pos_old_i.at({{1u}}) = pos_i_1;
+ }
}
auto& pos = particles.at({0u}).template get<"rigid_body">().template get<"position">();
- std::cout<<pos.at({{0u}}).get()<<" "<<pos.at({{1u}}).get()<<std::endl;
saw::codec<sch::Array<sch::Particle<sch::Float32,2u>>, saw::encode::Json> j_codec;
}
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 0000000..cc743b3
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,13 @@
+{
+ description = "Flake wrapper for project";
+
+ inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
+
+ outputs = { self, nixpkgs }:
+ let
+ pkgs = nixpkgs.legacyPackages.x86_64-linux;
+ packagesSet = import ./default.nix { inherit pkgs; };
+ in {
+ packages.x86_64-linux = packagesSet;
+ };
+}