diff --git a/src/core/lb/LBWalberla.cpp b/src/core/lb/LBWalberla.cpp index 20b51e74f9..5d0fe22872 100644 --- a/src/core/lb/LBWalberla.cpp +++ b/src/core/lb/LBWalberla.cpp @@ -154,34 +154,16 @@ void LBWalberla::set_collision_model(double kT, unsigned int seed) { } void LBWalberla::update_collision_model() { - auto &system = System::get_system(); auto const energy_conversion = Utils::int_pow<2>(lb_params->get_agrid() / lb_params->get_tau()); auto const lb_kT = lb_fluid->get_kT() * energy_conversion; - if (auto le_protocol = system.lees_edwards->get_protocol()) { - if (lb_kT != 0.) { - throw std::runtime_error( - "Lees-Edwards LB doesn't support thermalization"); - } - auto const &le_bc = system.box_geo->lees_edwards_bc(); - auto lees_edwards_object = std::make_unique( - le_bc.shear_direction, le_bc.shear_plane_normal, - [this, le_protocol, &system]() { - return get_pos_offset(system.get_sim_time(), *le_protocol) / - get_agrid(); - }, - [this, le_protocol, &system]() { - return get_shear_velocity(system.get_sim_time(), *le_protocol) * - (get_tau() / get_agrid()); - }); - set_collision_model(std::move(lees_edwards_object)); - } else { - auto const seed = lb_fluid->get_seed(); - set_collision_model(lb_kT, seed); - } + auto const seed = lb_fluid->get_seed(); + update_collision_model(lb_fluid, seed, lb_kT, lb_params); } -void LBWalberla::update_collision_model_static(std::shared_ptr m_instance, int seed, double lb_kT, std::shared_ptr m_lb_params) { +void LBWalberla::update_collision_model( + std::shared_ptr m_instance, int seed, double lb_kT, + std::shared_ptr m_lb_params) { auto const &system = ::System::get_system(); if (auto le_protocol = system.lees_edwards->get_protocol()) { if (lb_kT != 0.) { @@ -199,7 +181,7 @@ void LBWalberla::update_collision_model_static(std::shared_ptr m return get_shear_velocity(system.get_sim_time(), *le_protocol) * (m_lb_params->get_tau() / m_lb_params->get_agrid()); }); - m_instance->set_collision_model(std::move(lees_edwards_object)); + m_instance->set_collision_model(std::move(lees_edwards_object)); } else { m_instance->set_collision_model(lb_kT, seed); } diff --git a/src/core/lb/LBWalberla.hpp b/src/core/lb/LBWalberla.hpp index 62d87ff07a..2df3f90c28 100644 --- a/src/core/lb/LBWalberla.hpp +++ b/src/core/lb/LBWalberla.hpp @@ -95,7 +95,10 @@ struct LBWalberla { set_collision_model(std::unique_ptr &&lees_edwards_pack); void set_collision_model(double kT, unsigned int seed); void update_collision_model(); - static void update_collision_model_static(std::shared_ptr m_instance, int seed, double lb_kT, std::shared_ptr m_lb_params); + static void + update_collision_model(std::shared_ptr m_instance, int seed, + double lb_kT, + std::shared_ptr m_lb_params); }; } // namespace LB diff --git a/src/script_interface/walberla/LBFluid.cpp b/src/script_interface/walberla/LBFluid.cpp index 7225ea592f..9f912f0158 100644 --- a/src/script_interface/walberla/LBFluid.cpp +++ b/src/script_interface/walberla/LBFluid.cpp @@ -188,33 +188,8 @@ void LBFluid::do_construct(VariantMap const ¶ms) { throw std::domain_error("Parameter 'kinematic_viscosity' must be >= 0"); } make_instance(params); - ::System::get_system().lb.update_collision_model(); - /* - auto const &system = ::System::get_system(); - if (auto le_protocol = system.lees_edwards->get_protocol()) { - if (lb_kT != 0.) { - throw std::runtime_error( - "Lees-Edwards LB doesn't support thermalization"); - } - auto const &le_bc = system.box_geo->lees_edwards_bc(); - auto lees_edwards_object = std::make_unique( - le_bc.shear_direction, le_bc.shear_plane_normal, - [this, le_protocol, &system]() { - return get_pos_offset(system.get_sim_time(), *le_protocol) / - m_lb_params->get_agrid(); - }, - [this, le_protocol, &system]() { - return get_shear_velocity(system.get_sim_time(), *le_protocol) * - (m_lb_params->get_tau() / m_lb_params->get_agrid()); - }); - //m_instance->set_collision_model(std::move(lees_edwards_object)); - //m_instance->set_collision_model(std::move(lees_edwards_object)); - ::System::get_system().lb.set_collision_model(std::move(lees_edwards_object)) - } else { - m_instance->set_collision_model(lb_kT, m_seed); - } - m_instance->ghost_communication(); // synchronize ghost layers - */ + LB::LBWalberla::update_collision_model(m_instance, m_seed, lb_kT, + m_lb_params); m_instance->set_external_force(lb_ext_f); for (auto &vtk : m_vtk_writers) { vtk->attach_to_lattice(m_instance, get_latice_to_md_units_conversion());