55 auto const dx = a - b;
68template <
typename T> T get_mi_coord(T a, T b, T
box_length,
bool periodic) {
92 return pos + image_shift(image_box, box);
120 for (
auto c = 0
u; c < 3u; ++c) {
121 auto const dx = detail::get_mi_coord_masked(a[c], b[c], m_length[c],
122 m_length_inv_masked[c]);
143 double const *
sy,
double const *
sz,
double *
dx0,
144 double *
dx1,
double *
dx2,
double *
dsq)
const {
145 auto const lx = m_length[0
u];
146 auto const ly = m_length[1u];
147 auto const lz = m_length[2u];
148 auto const ix = m_length_inv_masked[0
u];
149 auto const iy = m_length_inv_masked[1u];
150 auto const iz = m_length_inv_masked[2u];
151 for (
int t = 0; t < m; ++t) {
152 auto const a0 = detail::get_mi_coord_masked(
xi,
sx[t],
lx,
ix);
153 auto const a1 = detail::get_mi_coord_masked(
yi,
sy[t],
ly,
iy);
154 auto const a2 = detail::get_mi_coord_masked(
zi,
sz[t],
lz,
iz);
182 m_lees_edwards_bc =
rhs.m_lees_edwards_bc;
188 std::bitset<3> m_periodic = 0b111;
223 return m_periodic[
coord];
252 for (
auto c = 0
u; c < 3u; ++c) {
253 m_length_inv_masked[c] = m_periodic[c] ? m_length_inv[c] : 0.;
255 m_length_half = 0.5 *
box_l;
275 return detail::get_mi_coord_masked(
276 a, b,
static_cast<T
>(m_length[
coord]),
277 static_cast<T
>(m_length_inv_masked[
coord]));
295 template <
typename T>
303 a_tmp[shear_plane_normal], m_length[shear_plane_normal]);
305 b_tmp[shear_plane_normal], m_length[shear_plane_normal]);
307 m_length_inv, m_periodic);
327 template <
typename T>
354 template <
typename T>
363 a_tmp[shear_plane_normal], m_length[shear_plane_normal]);
365 b_tmp[shear_plane_normal], m_length[shear_plane_normal]);
367 m_length_inv, m_periodic);
397 auto const &
le = m_lees_edwards_bc;
399 auto const shear_direction =
le.shear_direction;
400 auto const dy = x[shear_plane_normal] - y[shear_plane_normal];
402 ret[shear_direction] -= std::copysign(1.0,
dy) *
le.shear_velocity;
414 for (
auto i = 0
u; i < 3u; i++) {
418 if (result.second == std::numeric_limits<int>::min()
or
419 result.second == std::numeric_limits<int>::max()) {
420 throw std::runtime_error(
421 "Overflow in the image box count while folding a particle "
422 "coordinate into the primary simulation box. Maybe a particle "
423 "experienced a huge force.");
425 std::tie(pos[i], image_box[i]) = result;
437 for (
auto i = 0
u; i < 3u; i++) {
455 for (
auto i = 0
u; i < 3u; i++) {
467 return detail::image_shift(image_box, m_length);
473 return detail::unfolded_position(pos, image_box, m_length);
static int coord(std::string const &s)
Vector implementation and trait types for boost qvm interoperability.
Compiler-attribute macros shared across ESPResSo headers.
#define ESPRESSO_ATTR_ALWAYS_INLINE
auto unfolded_position(Utils::Vector3d const &pos, Utils::Vector3i const &image_box) const
Unfold particle coordinates to image box.
T get_mi_coord(T a, T b, unsigned coord) const
Get the minimum-image distance between two coordinates.
ESPRESSO_ATTR_ALWAYS_INLINE Utils::Vector3< T > get_mi_vector(Utils::Vector3< T > const &a, Utils::Vector3< T > const &b) const
Get the minimum-image vector between two coordinates.
void lees_edwards_update(double pos_offset, double shear_velocity)
Update the Lees-Edwards parameters of the box geometry for the current simulation time.
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
BoxGeometry(BoxGeometry const &rhs)
constexpr bool periodic(unsigned coord) const
Check periodicity in direction.
ESPRESSO_ATTR_ALWAYS_INLINE T get_mi_dist2(Utils::Vector3< T > const &a, Utils::Vector3< T > const &b) const
Get the squared minimum-image distance between two coordinates.
auto cuboid_minimum_image() const
Cuboid minimum-image fold parameters for hoisting into kernels.
double volume() const
Box volume.
auto image_shift(Utils::Vector3i const &image_box) const
Calculate image box shift vector.
Utils::Vector3d const & length_half() const
Half box length.
Utils::Vector3d const & length_inv() const
Inverse box length.
void set_periodic(unsigned coord, bool val)
Set periodicity for direction.
void set_length(Utils::Vector3d const &box_l)
Set box side lengths.
auto folded_image_box(Utils::Vector3d const &pos, Utils::Vector3i const &image_box) const
Calculate image box of coordinates folded to primary simulation box.
void set_lees_edwards_bc(LeesEdwardsBC bc)
void fold_position(Utils::Vector3d &pos, Utils::Vector3i &image_box) const
Fold coordinates to primary simulation box in-place.
Utils::Vector3d velocity_difference(Utils::Vector3d const &x, Utils::Vector3d const &y, Utils::Vector3d const &u, Utils::Vector3d const &v) const
Calculate the velocity difference including the Lees-Edwards velocity.
void set_type(BoxType type)
ESPRESSO_ATTR_ALWAYS_INLINE Utils::Vector3< T > get_mi_vector(T const &a0, T const &a1, T const &a2, T const &b0, T const &b1, T const &b2) const
Get the minimum-image vector between two coordinates.
Cuboid minimum-image fold parameters for hot pair loops.
CuboidMinimumImage(Utils::Vector3d const &length, Utils::Vector3d const &length_inv_masked)
ESPRESSO_ATTR_ALWAYS_INLINE double dist2(Utils::Vector3d const &a, Utils::Vector3d const &b) const
Squared minimum-image distance between two coordinates.
ESPRESSO_ATTR_ALWAYS_INLINE void batch_vector_dist2(double xi, double yi, double zi, int m, double const *sx, double const *sy, double const *sz, double *dx0, double *dx1, double *dx2, double *dsq) const
Batched minimum-image vector and squared distance: one point (xi, yi, zi) against m others held in th...
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.
auto periodic_fold(std::floating_point auto x, std::integral auto i, std::floating_point auto l)
Fold value into primary interval.
T product(Vector< T, N > const &v)
auto hadamard_product(Vector< T, N > const &a, Vector< U, N > const &b)
unsigned int shear_plane_normal
Utils::Vector3d distance(Utils::Vector3d const &d, Utils::Vector3d const &l, Utils::Vector3d const &, Utils::Vector3d const &l_inv, std::bitset< 3 > const periodic) const