26#include "communication.hpp"
31#include "system/System.hpp"
32#include "thermostat.hpp"
37#include <boost/mpi.hpp>
39#ifdef ESPRESSO_CALIPER
40#include <caliper/cali.h>
46#include <initializer_list>
53#ifdef ESPRESSO_THERMOSTAT_PER_PARTICLE
55#ifdef ESPRESSO_PARTICLE_ANISOTROPY
68#ifdef ESPRESSO_LB_ELECTROHYDRODYNAMICS
120 std::vector<Utils::Vector3d> &
res) {
127 le.pos_offset, box_geo.
length()[
le.shear_direction]);
130 for (
int i : {-1, 0, 1}) {
131 for (
int j : {-1, 0, 1}) {
132 for (
int k : {-1, 0, 1}) {
143 box_geo.
length()[
le.shear_direction]);
173 std::vector<Utils::Vector3d>
res;
188 if (
normal_shift > std::numeric_limits<double>::epsilon()) {
191 if (
normal_shift < -std::numeric_limits<double>::epsilon()) {
201 if (
not m_thermalized) {
207 auto const noise = Random::noise_uniform<RNGSalt::PARTICLES>(
213 if (particles.empty()) {
228 for (
auto ptr : particles) {
242#ifdef ESPRESSO_ENGINE
243 if (p.swimming().is_engine_force_on_fluid) {
282#ifdef ESPRESSO_ENGINE
283 if (p.swimming().is_engine_force_on_fluid) {
289#ifndef ESPRESSO_THERMOSTAT_PER_PARTICLE
290 if (m_thermostat.
gamma > 0.)
311#ifdef ESPRESSO_ENGINE
333#if defined(ESPRESSO_THERMOSTAT_PER_PARTICLE) and \
334 defined(ESPRESSO_PARTICLE_ANISOTROPY)
343 <<
") coupled to LB.";
351#ifdef ESPRESSO_CALIPER
354 assert(thermostat->lb !=
nullptr);
355 if (thermostat->lb->couple_to_md) {
356 if (
not lb.is_solver_set()) {
361 auto const ghost_particles = cell_structure->ghost_particles();
364 lb.ghost_communication_vel();
365 std::vector<Particle *> particles{};
369#if defined(ESPRESSO_THERMOSTAT_PER_PARTICLE) and \
370 defined(ESPRESSO_PARTICLE_ANISOTROPY)
373 particles.emplace_back(&p);
377 coupling.kernel(particles);
Vector implementation and trait types for boost qvm interoperability.
auto folded_position(Utils::Vector3d const &pos) const
Calculate coordinates folded to primary simulation box.
Utils::Vector3d const & length() const
Box length.
LeesEdwardsBC const & lees_edwards_bc() const
Keep track of ghost particles that have already been coupled once.
void kernel(std::vector< Particle * > const &particles)
Utils::Vector3d get_noise_term(Particle const &p) const
auto const & my_right() const
Right (top, back) corner of this nodes local box.
auto const & my_left() const
Left (bottom, front) corner of this nodes local box.
void lb_couple_particles()
Calculate particle-lattice interactions.
static DEVICE_QUALIFIER constexpr Vector< T, N > broadcast(typename Base::value_type const &value) noexcept
Create a vector that has all entries set to the same value.
cudaStream_t stream[1]
CUDA streams for parallel computing on CPU and GPU.
This file contains the errorhandling code for severe errors, like a broken bond or illegal parameter ...
#define runtimeErrorMsg()
auto periodic_fold(std::floating_point auto x, std::integral auto i, std::floating_point auto l)
Fold value into primary interval.
static void lb_coupling_sanity_checks(Particle const &p)
bool is_tracer(Particle const &p)
auto const & handle_particle_gamma(GammaType const &particle_gamma, GammaType const &default_gamma)
auto hadamard_product(Vector< T, N > const &a, Vector< U, N > const &b)
auto sqrt(Vector< T, N > const &a)
bool in_local_halo(LocalBox const &local_box, Utils::Vector3d const &pos, double agrid)
Check if a position is within the local LB domain plus halo.
static auto lees_edwards_vel_shift(Utils::Vector3d const &pos_shifted_by_box_l, Utils::Vector3d const &orig_pos, BoxGeometry const &box_geo)
static bool in_box(Utils::Vector3d const &pos, Utils::Vector3d const &lower_corner, Utils::Vector3d const &upper_corner)
static bool in_local_domain(LocalBox const &local_box, Utils::Vector3d const &pos, double halo=0.)
Check if a position is within the local box + halo.
static void positions_in_halo_impl(Utils::Vector3d const &pos_folded, Utils::Vector3d const &halo_lower_corner, Utils::Vector3d const &halo_upper_corner, BoxGeometry const &box_geo, std::vector< Utils::Vector3d > &res)
std::vector< Utils::Vector3d > positions_in_halo(Utils::Vector3d const &pos, BoxGeometry const &box_geo, LocalBox const &local_box, double agrid)
Return a vector of positions shifted by +,- box length in each coordinate.
static Utils::Vector3d lb_drag_force(Particle const &p, double lb_gamma, Utils::Vector3d const &v_fluid)
static Thermostat::GammaType lb_handle_particle_anisotropy(Particle const &p, double lb_gamma)
Random number generation using Philox.
uint64_t rng_counter() const
Get current value of the RNG.
uint32_t rng_seed() const
double gamma
Friction coefficient.
Utils::Vector3d get_coupling_interpolated_velocity(Utils::Vector3d const &pos) const
Calculate the interpolated fluid velocity in MD units.
void add_forces_at_pos(std::vector< Utils::Vector3d > const &pos, std::vector< Utils::Vector3d > const &forces)
double get_agrid() const
Get the LB grid spacing.
std::vector< Utils::Vector3d > get_coupling_interpolated_velocities(std::vector< Utils::Vector3d > const &pos) const
Calculate the interpolated fluid velocities in MD units.
Struct holding all information for one particle.
auto const & gamma() const
auto const & mu_E() const