From 185f05e88bc27613a1723a36f6c94c3a3eb6e968 Mon Sep 17 00:00:00 2001 From: David Beyer Date: Mon, 12 Aug 2024 12:44:13 +0200 Subject: [PATCH] WIP on_lees_edwards_change --- src/core/lb/LBNone.hpp | 1 + src/core/lb/LBWalberla.cpp | 9 +++++++++ src/core/lb/LBWalberla.hpp | 1 + src/core/lb/Solver.cpp | 6 ++++++ src/core/lb/Solver.hpp | 1 + src/core/system/System.cpp | 4 ++++ src/core/system/System.hpp | 1 + src/script_interface/lees_edwards/LeesEdwards.hpp | 3 ++- 8 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/core/lb/LBNone.hpp b/src/core/lb/LBNone.hpp index 61248c5fe5..6772e9b120 100644 --- a/src/core/lb/LBNone.hpp +++ b/src/core/lb/LBNone.hpp @@ -67,6 +67,7 @@ struct LBNone { void on_node_grid_change() const { throw NoLBActive{}; } void on_timestep_change() const { throw NoLBActive{}; } void on_temperature_change() const { throw NoLBActive{}; } + void on_lees_edwards_change() const { throw NoLBActive{}; } }; } // namespace LB diff --git a/src/core/lb/LBWalberla.cpp b/src/core/lb/LBWalberla.cpp index d1dec13160..bc4474af33 100644 --- a/src/core/lb/LBWalberla.cpp +++ b/src/core/lb/LBWalberla.cpp @@ -30,6 +30,8 @@ #include "system/System.hpp" #include "thermostat.hpp" +#include "lees_edwards/lees_edwards.hpp" + #include #include @@ -112,6 +114,13 @@ void LBWalberla::sanity_checks(System::System const &system) const { system.get_time_step()); } +void LBWalberla::on_lees_edwards_change() { + std::cout << "Changed LEBC." << std::endl; + auto &system = System::get_system(); + auto le_protocol = system.lees_edwards->get_protocol(); + auto const &le_bc = system.box_geo->lees_edwards_bc(); +} + } // namespace LB #endif // WALBERLA diff --git a/src/core/lb/LBWalberla.hpp b/src/core/lb/LBWalberla.hpp index 14cf5d02f2..83a2c952a8 100644 --- a/src/core/lb/LBWalberla.hpp +++ b/src/core/lb/LBWalberla.hpp @@ -88,6 +88,7 @@ struct LBWalberla { } void on_timestep_change() const {} void on_temperature_change() const {} + void on_lees_edwards_change(); }; } // namespace LB diff --git a/src/core/lb/Solver.cpp b/src/core/lb/Solver.cpp index 009f953c57..ecbcfd40c3 100644 --- a/src/core/lb/Solver.cpp +++ b/src/core/lb/Solver.cpp @@ -140,6 +140,12 @@ void Solver::on_temperature_change() { } } +void Solver::on_lees_edwards_change() { + if (impl->solver) { + std::visit([](auto &ptr) { ptr->on_lees_edwards_change(); }, *impl->solver); + } +} + bool Solver::is_gpu() const { check_solver(impl); return std::visit([](auto &ptr) { return ptr->is_gpu(); }, *impl->solver); diff --git a/src/core/lb/Solver.hpp b/src/core/lb/Solver.hpp index 6eefdc27cf..43aece5c33 100644 --- a/src/core/lb/Solver.hpp +++ b/src/core/lb/Solver.hpp @@ -168,6 +168,7 @@ struct Solver : public System::Leaf { void on_cell_structure_change(); void on_timestep_change(); void on_temperature_change(); + void on_lees_edwards_change(); void veto_boxl_change() const; private: diff --git a/src/core/system/System.cpp b/src/core/system/System.cpp index 676b824155..c49a5ce232 100644 --- a/src/core/system/System.cpp +++ b/src/core/system/System.cpp @@ -377,6 +377,10 @@ void System::on_observable_calc() { clear_particle_node(); } +void System::on_lees_edwards_change() { + lb.on_lees_edwards_change(); +} + void System::update_local_geo() { *local_geo = LocalBox::make_regular_decomposition( box_geo->length(), ::communicator.calc_node_index(), diff --git a/src/core/system/System.hpp b/src/core/system/System.hpp index bc576045c5..ea9d719672 100644 --- a/src/core/system/System.hpp +++ b/src/core/system/System.hpp @@ -251,6 +251,7 @@ class System : public std::enable_shared_from_this { * initialized immediately (P3M etc.). */ void on_observable_calc(); + void on_lees_edwards_change(); void veto_boxl_change(bool skip_particle_checks = false) const; /**@}*/ diff --git a/src/script_interface/lees_edwards/LeesEdwards.hpp b/src/script_interface/lees_edwards/LeesEdwards.hpp index d4ddd81fb9..7e7846b41d 100644 --- a/src/script_interface/lees_edwards/LeesEdwards.hpp +++ b/src/script_interface/lees_edwards/LeesEdwards.hpp @@ -103,12 +103,13 @@ class LeesEdwards : public AutoParameters { throw std::invalid_argument("Parameters 'shear_direction' and " "'shear_plane_normal' must differ"); } - auto const &system = get_system(); + auto &system = get_system(); system.lb.lebc_sanity_checks(shear_direction, shear_plane_normal); // update box geometry and cell structure system.box_geo->set_lees_edwards_bc( LeesEdwardsBC{0., 0., shear_direction, shear_plane_normal}); m_lees_edwards->set_protocol(m_protocol->protocol()); + system.on_lees_edwards_change(); }); } return {};