Skip to content

Commit

Permalink
Add function update_collision_model
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbbeyer committed Aug 19, 2024
1 parent 15c8046 commit b812fc1
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
44 changes: 44 additions & 0 deletions src/core/lb/LBWalberla.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ void LBWalberla::sanity_checks(System::System const &system) const {
system.get_time_step());
}

/*
void LBWalberla::on_lees_edwards_change() {
auto &system = System::get_system();
auto const energy_conversion =
Expand All @@ -137,6 +138,49 @@ void LBWalberla::on_lees_edwards_change() {
lb_fluid->set_collision_model(std::move(lees_edwards_object));
lb_fluid->ghost_communication(); // synchronize ghost layers
}
*/


void LBWalberla::on_lees_edwards_change() {
update_collision_model();
}

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) {
lb_fluid->set_collision_model(kT, seed);
lb_fluid->ghost_communication(); // synchronize ghost layers
}

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 {
set_collision_model(lb_kT, 42);
}
}

} // namespace LB

Expand Down
5 changes: 5 additions & 0 deletions src/core/lb/LBWalberla.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

#ifdef WALBERLA

#include <walberla_bridge/lattice_boltzmann/LBWalberlaBase.hpp>

#include <utils/Vector.hpp>

#include <memory>
Expand Down Expand Up @@ -89,6 +91,9 @@ 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(double kT, unsigned int seed);
void update_collision_model();
};

} // namespace LB
Expand Down

0 comments on commit b812fc1

Please sign in to comment.