Commit 54f998bd authored by lucienPan's avatar lucienPan
Browse files

Patch of Dihedral class2 KOKKOS

Since the costh12, costh13, costh23 and c0 are declared as const,
a hack using const_cast is used to work around this.
parent c14ac533
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -253,10 +253,16 @@ void DihedralClass2Kokkos<DeviceType>::operator()(TagDihedralClass2Compute<NEWTO
  const F_FLOAT costh13 = c0;
  const F_FLOAT costh23 = (vb2xm*vb3x + vb2ym*vb3y + vb2zm*vb3z) * r12c2;

  costh12 = MAX(MIN(costh12, 1.0), -1.0);
  costh13 = MAX(MIN(costh13, 1.0), -1.0);
  costh23 = MAX(MIN(costh23, 1.0), -1.0);
  c0 = costh13;
  {
    F_FLOAT& ctmp12 = const_cast<F_FLOAT&>(costh12);
    F_FLOAT& ctmp13 = const_cast<F_FLOAT&>(costh13);
    F_FLOAT& ctmp23 = const_cast<F_FLOAT&>(costh23);
    F_FLOAT& ctmp0  = const_cast<F_FLOAT&>(c0);
    ctmp12 = MAX(MIN(costh12, 1.0), -1.0);
    ctmp13 = MAX(MIN(costh13, 1.0), -1.0);
    ctmp23 = MAX(MIN(costh23, 1.0), -1.0);
    ctmp0  = costh13;
  }

  // cos and sin of 2 angles and final c