Skip to content

Commit

Permalink
Static overload for update_collision_model
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbbeyer committed Sep 3, 2024
1 parent 3cad5ac commit 64392b7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 52 deletions.
30 changes: 6 additions & 24 deletions src/core/lb/LBWalberla.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<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());
});
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<LBWalberlaBase> m_instance, int seed, double lb_kT, std::shared_ptr<LB::LBWalberlaParams> m_lb_params) {
void LBWalberla::update_collision_model(
std::shared_ptr<LBWalberlaBase> m_instance, int seed, double lb_kT,
std::shared_ptr<LB::LBWalberlaParams> m_lb_params) {
auto const &system = ::System::get_system();
if (auto le_protocol = system.lees_edwards->get_protocol()) {
if (lb_kT != 0.) {
Expand All @@ -199,7 +181,7 @@ void LBWalberla::update_collision_model_static(std::shared_ptr<LBWalberlaBase> 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);
}
Expand Down
5 changes: 4 additions & 1 deletion src/core/lb/LBWalberla.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@ struct LBWalberla {
set_collision_model(std::unique_ptr<LeesEdwardsPack> &&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<LBWalberlaBase> m_instance, int seed, double lb_kT, std::shared_ptr<LB::LBWalberlaParams> m_lb_params);
static void
update_collision_model(std::shared_ptr<LBWalberlaBase> m_instance, int seed,
double lb_kT,
std::shared_ptr<LB::LBWalberlaParams> m_lb_params);
};

} // namespace LB
Expand Down
29 changes: 2 additions & 27 deletions src/script_interface/walberla/LBFluid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,33 +188,8 @@ void LBFluid::do_construct(VariantMap const &params) {
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<LeesEdwardsPack>(
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());
Expand Down

0 comments on commit 64392b7

Please sign in to comment.