34#if defined(__GNUG__) or defined(__clang__)
35#define ESPRESSO_ATTR_ALWAYS_INLINE [[gnu::always_inline]]
37#define ESPRESSO_ATTR_ALWAYS_INLINE
55 auto const dx = a - b;
73template <
typename T> T get_mi_coord(T a, T b, T
box_length,
bool periodic) {
85 return hadamard_product(image_box, box);
97 return pos + image_shift(image_box, box);
118 m_lees_edwards_bc =
rhs.m_lees_edwards_bc;
124 std::bitset<3> m_periodic = 0b111;
152 return m_periodic[
coord];
181 m_length_half = 0.5 *
box_l;
201 return detail::get_mi_coord(a, b, m_length[
coord], m_length_inv[
coord],
215 template <
typename T>
223 a_tmp[shear_plane_normal], m_length[shear_plane_normal]);
225 b_tmp[shear_plane_normal], m_length[shear_plane_normal]);
227 m_length_inv, m_periodic);
248 template <
typename T>
257 a_tmp[shear_plane_normal], m_length[shear_plane_normal]);
259 b_tmp[shear_plane_normal], m_length[shear_plane_normal]);
261 m_length_inv, m_periodic);
291 auto const &
le = m_lees_edwards_bc;
293 auto const shear_direction =
le.shear_direction;
294 auto const dy = x[shear_plane_normal] - y[shear_plane_normal];
296 ret[shear_direction] -= std::copysign(
le.shear_velocity,
dy);
308 for (
auto i = 0
u; i < 3u; i++) {
312 if (result.second == std::numeric_limits<int>::min()
or
313 result.second == std::numeric_limits<int>::max()) {
314 throw std::runtime_error(
315 "Overflow in the image box count while folding a particle "
316 "coordinate into the primary simulation box. Maybe a particle "
317 "experienced a huge force.");
319 std::tie(pos[i], image_box[i]) = result;
331 for (
auto i = 0
u; i < 3u; i++) {
349 for (
auto i = 0
u; i < 3u; i++) {
361 return detail::image_shift(image_box, m_length);
367 return detail::unfolded_position(pos, image_box, m_length);
#define ESPRESSO_ATTR_ALWAYS_INLINE
static int coord(std::string const &s)
Vector implementation and trait types for boost qvm interoperability.
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.
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.
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)
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