2323#include " lees_edwards/LeesEdwardsBC.hpp"
2424
2525#include < utils/Vector.hpp>
26- #include < utils/math/sgn.hpp>
2726
2827#include < bitset>
2928#include < cassert>
@@ -176,6 +175,7 @@ class BoxGeometry {
176175 * @param box_l Length that should be set.
177176 */
178177 void set_length (Utils::Vector3d const &box_l) {
178+ assert (box_l > Utils::Vector3d::broadcast (0 .));
179179 m_length = box_l;
180180 m_length_inv = {1 . / box_l[0 ], 1 . / box_l[1 ], 1 . / box_l[2 ]};
181181 m_length_half = 0.5 * box_l;
@@ -213,9 +213,8 @@ class BoxGeometry {
213213 * periodic images, i.e. <tt>a - b</tt>.
214214 */
215215 template <typename T>
216- ESPRESSO_ATTR_ALWAYS_INLINE inline Utils::Vector<T, 3 >
217- get_mi_vector (const Utils::Vector<T, 3 > &a,
218- const Utils::Vector<T, 3 > &b) const {
216+ ESPRESSO_ATTR_ALWAYS_INLINE inline Utils::Vector3<T>
217+ get_mi_vector (Utils::Vector3<T> const &a, Utils::Vector3<T> const &b) const {
219218 if (type () == BoxType::LEES_EDWARDS) {
220219 auto const shear_plane_normal = lees_edwards_bc ().shear_plane_normal ;
221220 auto a_tmp = a;
@@ -228,8 +227,8 @@ class BoxGeometry {
228227 m_length_inv, m_periodic);
229228 }
230229 assert (type () == BoxType::CUBOID);
231- return {get_mi_coord (a[0 ], b[0 ], 0 ), get_mi_coord (a[1 ], b[1 ], 1 ),
232- get_mi_coord (a[2 ], b[2 ], 2 )};
230+ return {get_mi_coord (a[0 ], b[0 ], 0u ), get_mi_coord (a[1 ], b[1 ], 1u ),
231+ get_mi_coord (a[2 ], b[2 ], 2u )};
233232 }
234233
235234 /* *
@@ -247,13 +246,13 @@ class BoxGeometry {
247246 * periodic images, i.e. <tt>a - b</tt>.
248247 */
249248 template <typename T>
250- ESPRESSO_ATTR_ALWAYS_INLINE inline Utils::Vector<T, 3 >
249+ ESPRESSO_ATTR_ALWAYS_INLINE inline Utils::Vector3<T >
251250 get_mi_vector (T const &a0, T const &a1, T const &a2, T const &b0, T const &b1,
252251 T const &b2) const {
253252 if (type () == BoxType::LEES_EDWARDS) {
254253 auto const shear_plane_normal = lees_edwards_bc ().shear_plane_normal ;
255- auto a_tmp = Utils::Vector<T, 3 >{a0, a1, a2};
256- auto b_tmp = Utils::Vector<T, 3 >{b0, b1, b2};
254+ auto a_tmp = Utils::Vector3<T >{a0, a1, a2};
255+ auto b_tmp = Utils::Vector3<T >{b0, b1, b2};
257256 a_tmp[shear_plane_normal] = Algorithm::periodic_fold (
258257 a_tmp[shear_plane_normal], m_length[shear_plane_normal]);
259258 b_tmp[shear_plane_normal] = Algorithm::periodic_fold (
@@ -262,8 +261,8 @@ class BoxGeometry {
262261 m_length_inv, m_periodic);
263262 }
264263 assert (type () == BoxType::CUBOID);
265- return {get_mi_coord (a0, b0, 0 ), get_mi_coord (a1, b1, 1 ),
266- get_mi_coord (a2, b2, 2 )};
264+ return {get_mi_coord (a0, b0, 0u ), get_mi_coord (a1, b1, 1u ),
265+ get_mi_coord (a2, b2, 2u )};
267266 }
268267
269268 BoxType type () const { return m_type; }
@@ -293,8 +292,8 @@ class BoxGeometry {
293292 auto const shear_plane_normal = le.shear_plane_normal ;
294293 auto const shear_direction = le.shear_direction ;
295294 auto const dy = x[shear_plane_normal] - y[shear_plane_normal];
296- if (fabs (dy) > length_half ()[shear_plane_normal]) {
297- ret[shear_direction] -= Utils::sgn (dy) * le.shear_velocity ;
295+ if (std:: fabs (dy) > length_half ()[shear_plane_normal]) {
296+ ret[shear_direction] -= std::copysign ( le.shear_velocity , dy) ;
298297 }
299298 }
300299 return ret;
@@ -329,7 +328,7 @@ class BoxGeometry {
329328 */
330329 auto folded_position (Utils::Vector3d const &pos) const {
331330 auto pos_folded = pos;
332- for (unsigned int i = 0u ; i < 3u ; i++) {
331+ for (auto i = 0u ; i < 3u ; i++) {
333332 if (m_periodic[i]) {
334333 pos_folded[i] = Algorithm::periodic_fold (pos[i], m_length[i]);
335334 }
0 commit comments