Skip to content

Commit

Permalink
core: lb_interface: removed unused callbacks and removed Walberla nam…
Browse files Browse the repository at this point in the history
…espace
  • Loading branch information
reinaual committed Jun 28, 2023
1 parent 9433c5b commit 412e5a6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 71 deletions.
65 changes: 10 additions & 55 deletions src/core/grid_based_algorithms/lb_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,37 +127,11 @@ double get_kT() {

double get_lattice_speed() { return get_agrid() / get_tau(); }

#ifdef WALBERLA
namespace Walberla {

static Utils::Vector3d get_momentum() { return lb_walberla()->get_momentum(); }

static boost::optional<Utils::Vector3d>
get_velocity_at_pos(Utils::Vector3d pos) {
return lb_walberla()->get_velocity_at_pos(pos);
}

REGISTER_CALLBACK_ONE_RANK(get_velocity_at_pos)

static boost::optional<double>
get_interpolated_density_at_pos(Utils::Vector3d pos) {
return lb_walberla()->get_interpolated_density_at_pos(pos);
}

REGISTER_CALLBACK_ONE_RANK(get_interpolated_density_at_pos)

static Utils::VectorXd<9> get_pressure_tensor() {
return lb_walberla()->get_pressure_tensor();
}

} // namespace Walberla
#endif // WALBERLA

Utils::VectorXd<9> const
get_pressure_tensor(boost::mpi::communicator const &comm) {
if (lattice_switch == ActiveLB::WALBERLA_LB) {
#ifdef WALBERLA
auto const local_pressure_tensor = Walberla::get_pressure_tensor();
auto const local_pressure_tensor = lb_walberla()->get_pressure_tensor();
std::remove_const_t<decltype(local_pressure_tensor)> pressure_tensor;
boost::mpi::reduce(comm, local_pressure_tensor, pressure_tensor,
std::plus<>(), 0);
Expand All @@ -170,51 +144,32 @@ get_pressure_tensor(boost::mpi::communicator const &comm) {
Utils::Vector3d calc_fluid_momentum() {
if (lattice_switch == ActiveLB::WALBERLA_LB) {
#ifdef WALBERLA
return Walberla::get_momentum();
#endif
}
throw NoLBActive();
}

Utils::Vector3d const get_interpolated_velocity(Utils::Vector3d const &pos) {
if (lattice_switch == ActiveLB::WALBERLA_LB) {
#ifdef WALBERLA
auto const folded_pos = folded_position(pos, box_geo);
return mpi_call(::Communication::Result::one_rank,
Walberla::get_velocity_at_pos, folded_pos / get_agrid());
return lb_walberla()->get_momentum();
#endif
}
throw NoLBActive();
}

Utils::Vector3d const get_interpolated_velocity(boost::mpi::communicator const &comm, Utils::Vector3d const &pos) {
Utils::Vector3d const
get_interpolated_velocity(boost::mpi::communicator const &comm,
Utils::Vector3d const &pos) {
if (lattice_switch == ActiveLB::WALBERLA_LB) {
#ifdef WALBERLA
auto const folded_pos = folded_position(pos, box_geo) / get_agrid();
auto const local_velocity = Walberla::get_velocity_at_pos(folded_pos);
auto const local_velocity = lb_walberla()->get_velocity_at_pos(folded_pos);
return Utils::Mpi::reduce_optional(comm, local_velocity);
#endif
}
throw NoLBActive();
}

double get_interpolated_density(Utils::Vector3d const &pos) {
if (lattice_switch == ActiveLB::WALBERLA_LB) {
#ifdef WALBERLA
auto const folded_pos = folded_position(pos, box_geo);
return mpi_call(::Communication::Result::one_rank,
Walberla::get_interpolated_density_at_pos,
folded_pos / get_agrid());
#endif
}
throw NoLBActive();
}

double get_interpolated_density(boost::mpi::communicator const &comm, Utils::Vector3d const &pos) {
double get_interpolated_density(boost::mpi::communicator const &comm,
Utils::Vector3d const &pos) {
if (lattice_switch == ActiveLB::WALBERLA_LB) {
#ifdef WALBERLA
auto const folded_pos = folded_position(pos, box_geo) / get_agrid();
auto const local_density = Walberla::get_interpolated_density_at_pos(folded_pos);
auto const local_density =
lb_walberla()->get_interpolated_density_at_pos(folded_pos);
return Utils::Mpi::reduce_optional(comm, local_density);
#endif
}
Expand Down
21 changes: 5 additions & 16 deletions src/core/grid_based_algorithms/lb_interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,28 +119,17 @@ Utils::Vector3d calc_fluid_momentum();
* @param pos Position at which the velocity is to be calculated.
* @retval interpolated fluid velocity.
*/
Utils::Vector3d const get_interpolated_velocity(Utils::Vector3d const &pos);

/**
* @brief Calculates the interpolated fluid velocity on the head node process.
* @param pos Position at which the velocity is to be calculated.
* @retval interpolated fluid velocity.
*/
Utils::Vector3d const get_interpolated_velocity(boost::mpi::communicator const &comm, Utils::Vector3d const &pos);

/**
* @brief Calculates the interpolated fluid density on the head node process.
* @param pos Position at which the density is to be calculated.
* @retval interpolated fluid density.
*/
double get_interpolated_density(Utils::Vector3d const &pos);
Utils::Vector3d const
get_interpolated_velocity(boost::mpi::communicator const &comm,
Utils::Vector3d const &pos);

/**
* @brief Calculates the interpolated fluid density on the head node process.
* @param pos Position at which the density is to be calculated.
* @retval interpolated fluid density.
*/
double get_interpolated_density(boost::mpi::communicator const &comm, Utils::Vector3d const &pos);
double get_interpolated_density(boost::mpi::communicator const &comm,
Utils::Vector3d const &pos);

} // namespace LB

Expand Down

0 comments on commit 412e5a6

Please sign in to comment.