48T get_mi_coord(T a, T b, T box_length, T box_length_inv, T box_length_half,
50 auto const dx = a - b;
52 if (periodic && (std::abs(dx) > box_length_half)) {
53 return dx - std::round(dx * box_length_inv) * box_length;
68template <
typename T> T get_mi_coord(T a, T b, T box_length,
bool periodic) {
69 return get_mi_coord(a, b, box_length, 1. / box_length, 0.5 * box_length,
92 return pos + image_shift(image_box, box);
113 m_lees_edwards_bc = rhs.m_lees_edwards_bc;
119 std::bitset<3> m_periodic = 0b111;
137 void set_periodic(
unsigned coord,
bool val) { m_periodic.set(coord, val); }
147 return m_periodic[coord];
174 m_length_inv = {1. / box_l[0], 1. / box_l[1], 1. / box_l[2]};
175 m_length_half = 0.5 * box_l;
192 template <
typename T> T
inline get_mi_coord(T a, T b,
unsigned coord)
const {
195 return detail::get_mi_coord(a, b, m_length[coord], m_length_inv[coord],
196 m_length_half[coord], m_periodic[coord]);
209 template <
typename T>
213 auto const shear_plane_normal =
218 a_tmp[shear_plane_normal], m_length[shear_plane_normal]);
220 b_tmp[shear_plane_normal], m_length[shear_plane_normal]);
222 m_length_inv, m_periodic);
252 auto const &le = m_lees_edwards_bc;
253 auto const shear_plane_normal =
254 static_cast<unsigned int>(le.shear_plane_normal);
255 auto const shear_direction =
256 static_cast<unsigned int>(le.shear_direction);
257 auto const dy = x[shear_plane_normal] - y[shear_plane_normal];
258 if (fabs(dy) > 0.5 *
length_half()[shear_plane_normal]) {
259 ret[shear_direction] -=
Utils::sgn(dy) * le.shear_velocity;
271 for (
unsigned int i = 0
u; i < 3u; i++) {
275 if (result.second == std::numeric_limits<int>::min() or
276 result.second == std::numeric_limits<int>::max()) {
277 throw std::runtime_error(
278 "Overflow in the image box count while folding a particle "
279 "coordinate into the primary simulation box. Maybe a particle "
280 "experienced a huge force.");
282 std::tie(
pos[i], image_box[i]) = result;
293 for (
unsigned int i = 0
u; i < 3u; i++) {
306 return detail::image_shift(image_box, m_length);
312 return detail::unfolded_position(
pos, image_box, m_length);
Vector implementation and trait types for boost qvm interoperability.
__shared__ int pos[MAXDEPTH *THREADS5/WARPSIZE]
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.
void lees_edwards_update(double pos_offset, double shear_velocity)
Update the Lees-Edwards parameters of the box geometry for the current simulation time.
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 folded_position(Utils::Vector3d const &p) const
Calculate coordinates folded to primary simulation box.
auto image_shift(Utils::Vector3i const &image_box) const
Calculate image box shift vector.
Utils::Vector< T, 3 > get_mi_vector(const Utils::Vector< T, 3 > &a, const Utils::Vector< T, 3 > &b) const
Get the minimum-image vector between two coordinates.
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.
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)
std::pair< T, I > periodic_fold(T x, I i, T const l)
Fold value into primary interval.
T product(Vector< T, N > const &v)
constexpr int sgn(T val)
Calculate signum of val.
auto hadamard_product(Vector< T, N > const &a, Vector< U, N > const &b)
Utils::Vector3d distance(Utils::Vector3d const &d, Utils::Vector3d const &l, Utils::Vector3d const &hal_l, Utils::Vector3d const &l_inv, std::bitset< 3 > const periodic) const
unsigned int shear_plane_normal