26#include "communication.hpp"
30#include "system/System.hpp"
31#include "thermostat.hpp"
36#include <boost/mpi.hpp>
38#ifdef ESPRESSO_CALIPER
39#include <caliper/cali.h>
45#include <initializer_list>
52#ifdef ESPRESSO_PARTICLE_ANISOTROPY
57#ifdef ESPRESSO_THERMOSTAT_PER_PARTICLE
66#ifdef ESPRESSO_LB_ELECTROHYDRODYNAMICS
118 std::vector<Utils::Vector3d> &
res) {
125 le.pos_offset, box_geo.
length()[
le.shear_direction]);
128 for (
int i : {-1, 0, 1}) {
129 for (
int j : {-1, 0, 1}) {
130 for (
int k : {-1, 0, 1}) {
141 box_geo.
length()[
le.shear_direction]);
171 std::vector<Utils::Vector3d>
res;
186 if (
normal_shift > std::numeric_limits<double>::epsilon()) {
189 if (
normal_shift < -std::numeric_limits<double>::epsilon()) {
199 if (
not m_thermalized) {
205 auto const noise = Random::noise_uniform<RNGSalt::PARTICLES>(
211 if (particles.empty()) {
226 for (
auto ptr : particles) {
240#ifdef ESPRESSO_ENGINE
241 if (p.swimming().is_engine_force_on_fluid) {
280#ifdef ESPRESSO_ENGINE
281 if (p.swimming().is_engine_force_on_fluid) {
287#ifndef ESPRESSO_THERMOSTAT_PER_PARTICLE
288 if (m_thermostat.
gamma > 0.)
309#ifdef ESPRESSO_ENGINE
331#if defined(ESPRESSO_THERMOSTAT_PER_PARTICLE) and \
332 defined(ESPRESSO_PARTICLE_ANISOTROPY)
341 <<
") coupled to LB.";
349#ifdef ESPRESSO_CALIPER
352 assert(thermostat->lb !=
nullptr);
353 if (thermostat->lb->couple_to_md) {
354 if (
not lb.is_solver_set()) {
359 auto const ghost_particles = cell_structure->ghost_particles();
362 lb.ghost_communication_vel();
363 std::vector<Particle *> particles{};
367#if defined(ESPRESSO_THERMOSTAT_PER_PARTICLE) and \
368 defined(ESPRESSO_PARTICLE_ANISOTROPY)
371 particles.emplace_back(&p);
375 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