Skip to content

Commit

Permalink
Added on_lees_edwards_change
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbbeyer committed Aug 13, 2024
1 parent a676f54 commit 65896d6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 18 deletions.
29 changes: 13 additions & 16 deletions src/core/lb/LBWalberla.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,23 +119,20 @@ void LBWalberla::on_lees_edwards_change() {
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<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());
});
lb_fluid->set_collision_model(std::move(lees_edwards_object));
} else {
//lb_fluid->set_collision_model(lb_kT, m_seed);
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<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());
});
lb_fluid->set_collision_model(std::move(lees_edwards_object));
lb_fluid->ghost_communication(); // synchronize ghost layers
}

Expand Down
1 change: 1 addition & 0 deletions src/core/unit_tests/lb_particle_coupling_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,7 @@ BOOST_AUTO_TEST_CASE(lb_exceptions) {
BOOST_CHECK_THROW(lb.on_node_grid_change(), NoLBActive);
BOOST_CHECK_THROW(lb.on_timestep_change(), NoLBActive);
BOOST_CHECK_THROW(lb.on_temperature_change(), NoLBActive);
BOOST_CHECK_THROW(lb.on_lees_edwards_change(), NoLBActive);
BOOST_CHECK_THROW(lb_impl->get_density_at_pos(vec, true), NoLBActive);
BOOST_CHECK_THROW(lb_impl->get_velocity_at_pos(vec, true), NoLBActive);
BOOST_CHECK_THROW(lb_impl->add_force_at_pos(vec, vec), NoLBActive);
Expand Down
2 changes: 0 additions & 2 deletions testsuite/python/lb_lees_edwards.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,6 @@ def test_velocity_shift_from_particles(self):
for profile in self.sample_lb_velocities(lbf):
self.check_profile(profile, stencil, 'SN', 'WE', tol)



# TODO: re-enable this check once LB can be sheared in any direction
# # East and West are sheared vertically
# with LEContextManager('y', 'x', le_offset):
Expand Down

0 comments on commit 65896d6

Please sign in to comment.