Skip to content

Commit

Permalink
Fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbbeyer committed Aug 22, 2024
1 parent 0236343 commit a2fc1f5
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 23 deletions.
32 changes: 15 additions & 17 deletions src/core/lb/LBWalberla.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<LeesEdwardsPack> &&lees_edwards_object) {
void LBWalberla::set_collision_model(
std::unique_ptr<LeesEdwardsPack> &&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) {
Expand All @@ -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<LeesEdwardsPack>(
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);
Expand Down
3 changes: 2 additions & 1 deletion src/core/lb/LBWalberla.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<LeesEdwardsPack> &&lees_edwards_pack);
void
set_collision_model(std::unique_ptr<LeesEdwardsPack> &&lees_edwards_pack);
void set_collision_model(double kT, unsigned int seed);
void update_collision_model();
};
Expand Down
3 changes: 2 additions & 1 deletion src/script_interface/walberla/LBFluid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>(v);
Expand Down
4 changes: 1 addition & 3 deletions src/walberla_bridge/src/lattice_boltzmann/LBWalberlaImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1367,9 +1367,7 @@ class LBWalberlaImpl : public LBWalberlaBase {
return numeric_cast<double>(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<uint64_t> get_rng_state() const override {
auto const cm = std::get_if<CollisionModelThermalized>(&*m_collision_model);
Expand Down
1 change: 0 additions & 1 deletion testsuite/python/lb_lees_edwards.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.):
Expand Down

0 comments on commit a2fc1f5

Please sign in to comment.