From a2fc1f585f420b00c194fcdfdaab3e718df40110 Mon Sep 17 00:00:00 2001 From: David Beyer Date: Thu, 22 Aug 2024 11:39:15 +0200 Subject: [PATCH] Fix formatting --- src/core/lb/LBWalberla.cpp | 32 +++++++++---------- src/core/lb/LBWalberla.hpp | 3 +- src/script_interface/walberla/LBFluid.hpp | 3 +- .../src/lattice_boltzmann/LBWalberlaImpl.hpp | 4 +-- testsuite/python/lb_lees_edwards.py | 1 - 5 files changed, 20 insertions(+), 23 deletions(-) diff --git a/src/core/lb/LBWalberla.cpp b/src/core/lb/LBWalberla.cpp index 1de06f11ec..d2099c76a7 100644 --- a/src/core/lb/LBWalberla.cpp +++ b/src/core/lb/LBWalberla.cpp @@ -140,15 +140,12 @@ void LBWalberla::on_lees_edwards_change() { } */ +void LBWalberla::on_lees_edwards_change() { update_collision_model(); } -void LBWalberla::on_lees_edwards_change() { - update_collision_model(); -} - -void LBWalberla::set_collision_model(std::unique_ptr &&lees_edwards_object) { +void LBWalberla::set_collision_model( + std::unique_ptr &&lees_edwards_object) { lb_fluid->set_collision_model(std::move(lees_edwards_object)); lb_fluid->ghost_communication(); // synchronize ghost layers - } void LBWalberla::set_collision_model(double kT, unsigned int seed) { @@ -159,23 +156,24 @@ 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()); + 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"); + 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()); - }); + 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 { set_collision_model(lb_kT, 42); diff --git a/src/core/lb/LBWalberla.hpp b/src/core/lb/LBWalberla.hpp index 2173c55549..058427ade6 100644 --- a/src/core/lb/LBWalberla.hpp +++ b/src/core/lb/LBWalberla.hpp @@ -91,7 +91,8 @@ struct LBWalberla { void on_timestep_change() const {} void on_temperature_change() const {} void on_lees_edwards_change(); - void set_collision_model(std::unique_ptr &&lees_edwards_pack); + void + set_collision_model(std::unique_ptr &&lees_edwards_pack); void set_collision_model(double kT, unsigned int seed); void update_collision_model(); }; diff --git a/src/script_interface/walberla/LBFluid.hpp b/src/script_interface/walberla/LBFluid.hpp index b2d733decb..b006aa526b 100644 --- a/src/script_interface/walberla/LBFluid.hpp +++ b/src/script_interface/walberla/LBFluid.hpp @@ -77,7 +77,8 @@ class LBFluid : public LatticeModel<::LBWalberlaBase, LBVTKHandle> { [this]() { return m_instance->get_lattice().get_grid_dimensions(); }}, {"kT", AutoParameter::read_only, [this]() { return m_instance->get_kT() / m_conv_energy; }}, - {"seed", AutoParameter::read_only, [this]() { return m_instance->get_seed(); }}, + {"seed", AutoParameter::read_only, + [this]() { return m_instance->get_seed(); }}, {"rng_state", [this](Variant const &v) { auto const rng_state = get_value(v); diff --git a/src/walberla_bridge/src/lattice_boltzmann/LBWalberlaImpl.hpp b/src/walberla_bridge/src/lattice_boltzmann/LBWalberlaImpl.hpp index 93ea2f0186..3b1e05b3db 100644 --- a/src/walberla_bridge/src/lattice_boltzmann/LBWalberlaImpl.hpp +++ b/src/walberla_bridge/src/lattice_boltzmann/LBWalberlaImpl.hpp @@ -1367,9 +1367,7 @@ class LBWalberlaImpl : public LBWalberlaBase { return numeric_cast(m_kT); } - [[nodiscard]] int get_seed() const noexcept override { - return m_seed; - } + [[nodiscard]] int get_seed() const noexcept override { return m_seed; } [[nodiscard]] std::optional get_rng_state() const override { auto const cm = std::get_if(&*m_collision_model); diff --git a/testsuite/python/lb_lees_edwards.py b/testsuite/python/lb_lees_edwards.py index c0e3759d05..29dd689956 100644 --- a/testsuite/python/lb_lees_edwards.py +++ b/testsuite/python/lb_lees_edwards.py @@ -351,7 +351,6 @@ def test_lebc_mismatch(self): LEContextManager('x', 'y', 1.) self.assertIsNone(system.lb) - with self.assertRaisesRegex(ValueError, "Lees-Edwards sweep is implemented for a ghost layer of thickness 1"): lattice = espressomd.lb.LatticeWalberla(agrid=1., n_ghost_layers=2) with LEContextManager('x', 'y', 1.):