#include "gromacs/utility/gmxassert.h"
#include "gromacs/utility/smalloc.h"
-const char *epbc_names[epbcNR+1] =
-{
- "xyz", "no", "xy", "screw", nullptr
-};
+const char* epbc_names[epbcNR + 1] = { "xyz", "no", "xy", "screw", nullptr };
/* Skip 0 so we have more chance of detecting if we forgot to call set_pbc. */
-enum {
- epbcdxRECTANGULAR = 1, epbcdxTRICLINIC,
- epbcdx2D_RECT, epbcdx2D_TRIC,
- epbcdx1D_RECT, epbcdx1D_TRIC,
- epbcdxSCREW_RECT, epbcdxSCREW_TRIC,
- epbcdxNOPBC, epbcdxUNSUPPORTED
+enum
+{
+ epbcdxRECTANGULAR = 1,
+ epbcdxTRICLINIC,
+ epbcdx2D_RECT,
+ epbcdx2D_TRIC,
+ epbcdx1D_RECT,
+ epbcdx1D_TRIC,
+ epbcdxSCREW_RECT,
+ epbcdxSCREW_TRIC,
+ epbcdxNOPBC,
+ epbcdxUNSUPPORTED
};
//! Margin factor for error message
-#define BOX_MARGIN 1.0010
+#define BOX_MARGIN 1.0010
//! Margin correction if the box is too skewed
#define BOX_MARGIN_CORRECT 1.0005
switch (ePBC)
{
- case epbcXYZ: npbcdim = 3; break;
- case epbcXY: npbcdim = 2; break;
+ case epbcXYZ: npbcdim = 3; break;
+ case epbcXY: npbcdim = 2; break;
case epbcSCREW: npbcdim = 3; break;
- case epbcNONE: npbcdim = 0; break;
+ case epbcNONE: npbcdim = 0; break;
default: gmx_fatal(FARGS, "Unknown ePBC=%d in ePBC2npbcdim", ePBC);
}
return npbcdim;
}
-void dump_pbc(FILE *fp, t_pbc *pbc)
+void dump_pbc(FILE* fp, t_pbc* pbc)
{
rvec sum_box;
}
}
-const char *check_box(int ePBC, const matrix box)
+const char* check_box(int ePBC, const matrix box)
{
- const char *ptr;
+ const char* ptr;
if (ePBC == -1)
{
if ((box[XX][YY] != 0) || (box[XX][ZZ] != 0) || (box[YY][ZZ] != 0))
{
- ptr = "Only triclinic boxes with the first vector parallel to the x-axis and the second vector in the xy-plane are supported.";
+ ptr = "Only triclinic boxes with the first vector parallel to the x-axis and the second "
+ "vector in the xy-plane are supported.";
}
else if (ePBC == epbcSCREW && (box[YY][XX] != 0 || box[ZZ][XX] != 0))
{
ptr = "The unit cell can not have off-diagonal x-components with screw pbc";
}
- else if (std::fabs(box[YY][XX]) > BOX_MARGIN*0.5*box[XX][XX] ||
- (ePBC != epbcXY &&
- (std::fabs(box[ZZ][XX]) > BOX_MARGIN*0.5*box[XX][XX] ||
- std::fabs(box[ZZ][YY]) > BOX_MARGIN*0.5*box[YY][YY])))
+ else if (std::fabs(box[YY][XX]) > BOX_MARGIN * 0.5 * box[XX][XX]
+ || (ePBC != epbcXY
+ && (std::fabs(box[ZZ][XX]) > BOX_MARGIN * 0.5 * box[XX][XX]
+ || std::fabs(box[ZZ][YY]) > BOX_MARGIN * 0.5 * box[YY][YY])))
{
ptr = "Triclinic box is too skewed.";
}
rvec angle;
svmul(DEG2RAD, angleInDegrees, angle);
box[XX][XX] = vec[XX];
- box[YY][XX] = vec[YY]*cos(angle[ZZ]);
- box[YY][YY] = vec[YY]*sin(angle[ZZ]);
- box[ZZ][XX] = vec[ZZ]*cos(angle[YY]);
- box[ZZ][YY] = vec[ZZ]
- *(cos(angle[XX])-cos(angle[YY])*cos(angle[ZZ]))/sin(angle[ZZ]);
- box[ZZ][ZZ] = std::sqrt(gmx::square(vec[ZZ])
- -box[ZZ][XX]*box[ZZ][XX]-box[ZZ][YY]*box[ZZ][YY]);
+ box[YY][XX] = vec[YY] * cos(angle[ZZ]);
+ box[YY][YY] = vec[YY] * sin(angle[ZZ]);
+ box[ZZ][XX] = vec[ZZ] * cos(angle[YY]);
+ box[ZZ][YY] = vec[ZZ] * (cos(angle[XX]) - cos(angle[YY]) * cos(angle[ZZ])) / sin(angle[ZZ]);
+ box[ZZ][ZZ] =
+ std::sqrt(gmx::square(vec[ZZ]) - box[ZZ][XX] * box[ZZ][XX] - box[ZZ][YY] * box[ZZ][YY]);
}
real max_cutoff2(int ePBC, const matrix box)
min_ss = std::min(box[XX][XX], std::min(box[YY][YY] - std::fabs(box[ZZ][YY]), box[ZZ][ZZ]));
}
- return std::min(min_hv2, min_ss*min_ss);
+ return std::min(min_hv2, min_ss * min_ss);
}
//! Set to true if warning has been printed
{
if (!bWarnedGuess)
{
- fprintf(stderr, "WARNING: Unsupported box diagonal %f %f %f, "
+ fprintf(stderr,
+ "WARNING: Unsupported box diagonal %f %f %f, "
"will not use periodic boundary conditions\n\n",
box[XX][XX], box[YY][YY], box[ZZ][ZZ]);
bWarnedGuess = TRUE;
}
//! Check if the box still obeys the restrictions, if not, correct it
-static int correct_box_elem(FILE *fplog, int step, tensor box, int v, int d)
+static int correct_box_elem(FILE* fplog, int step, tensor box, int v, int d)
{
int shift, maxshift = 10;
shift = 0;
/* correct elem d of vector v with vector d */
- while (box[v][d] > BOX_MARGIN_CORRECT*0.5*box[d][d])
+ while (box[v][d] > BOX_MARGIN_CORRECT * 0.5 * box[d][d])
{
if (fplog)
{
}
if (shift <= -maxshift)
{
- gmx_fatal(FARGS,
- "Box was shifted at least %d times. Please see log-file.",
- maxshift);
+ gmx_fatal(FARGS, "Box was shifted at least %d times. Please see log-file.", maxshift);
}
}
- while (box[v][d] < -BOX_MARGIN_CORRECT*0.5*box[d][d])
+ while (box[v][d] < -BOX_MARGIN_CORRECT * 0.5 * box[d][d])
{
if (fplog)
{
}
if (shift >= maxshift)
{
- gmx_fatal(FARGS,
- "Box was shifted at least %d times. Please see log-file.",
- maxshift);
+ gmx_fatal(FARGS, "Box was shifted at least %d times. Please see log-file.", maxshift);
}
}
return shift;
}
-gmx_bool correct_box(FILE *fplog, int step, tensor box, t_graph *graph)
+gmx_bool correct_box(FILE* fplog, int step, tensor box, t_graph* graph)
{
int zy, zx, yx, i;
gmx_bool bCorrected;
/* correct the graph */
for (i = graph->at_start; i < graph->at_end; i++)
{
- graph->ishift[i][YY] -= graph->ishift[i][ZZ]*zy;
- graph->ishift[i][XX] -= graph->ishift[i][ZZ]*zx;
- graph->ishift[i][XX] -= graph->ishift[i][YY]*yx;
+ graph->ishift[i][YY] -= graph->ishift[i][ZZ] * zy;
+ graph->ishift[i][XX] -= graph->ishift[i][ZZ] * zx;
+ graph->ishift[i][XX] -= graph->ishift[i][YY] * yx;
}
}
}
//! Do the real arithmetic for filling the pbc struct
-static void low_set_pbc(t_pbc *pbc, int ePBC,
- const ivec dd_pbc, const matrix box)
+static void low_set_pbc(t_pbc* pbc, int ePBC, const ivec dd_pbc, const matrix box)
{
int order[3] = { 0, -1, 1 };
ivec bPBC;
- const char *ptr;
+ const char* ptr;
pbc->ePBC = ePBC;
pbc->ndim_ePBC = ePBC2npbcdim(ePBC);
}
copy_mat(box, pbc->box);
- pbc->max_cutoff2 = 0;
- pbc->dim = -1;
- pbc->ntric_vec = 0;
+ pbc->max_cutoff2 = 0;
+ pbc->dim = -1;
+ pbc->ntric_vec = 0;
for (int i = 0; (i < DIM); i++)
{
- pbc->fbox_diag[i] = box[i][i];
- pbc->hbox_diag[i] = pbc->fbox_diag[i]*0.5;
+ pbc->fbox_diag[i] = box[i][i];
+ pbc->hbox_diag[i] = pbc->fbox_diag[i] * 0.5;
pbc->mhbox_diag[i] = -pbc->hbox_diag[i];
}
ptr = check_box(ePBC, box);
if (ptr)
{
- fprintf(stderr, "Warning: %s\n", ptr);
+ fprintf(stderr, "Warning: %s\n", ptr);
pr_rvecs(stderr, 0, " Box", box, DIM);
- fprintf(stderr, " Can not fix pbc.\n\n");
+ fprintf(stderr, " Can not fix pbc.\n\n");
pbc->ePBCDX = epbcdxUNSUPPORTED;
}
else
}
}
break;
- default:
- gmx_fatal(FARGS, "Incorrect number of pbc dimensions with DD: %d",
- npbcdim);
+ default: gmx_fatal(FARGS, "Incorrect number of pbc dimensions with DD: %d", npbcdim);
}
pbc->max_cutoff2 = max_cutoff2(ePBC, box);
- if (pbc->ePBCDX == epbcdxTRICLINIC ||
- pbc->ePBCDX == epbcdx2D_TRIC ||
- pbc->ePBCDX == epbcdxSCREW_TRIC)
+ if (pbc->ePBCDX == epbcdxTRICLINIC || pbc->ePBCDX == epbcdx2D_TRIC || pbc->ePBCDX == epbcdxSCREW_TRIC)
{
if (debug)
{
for (int d = 0; d < DIM; d++)
{
- trial[d] = i*box[XX][d] + j*box[YY][d] + k*box[ZZ][d];
+ trial[d] = i * box[XX][d] + j * box[YY][d] + k * box[ZZ][d];
/* Choose the vector within the brick around 0,0,0 that
* will become the shortest due to shift try.
*/
{
if (trial[d] < 0)
{
- pos[d] = std::min( pbc->hbox_diag[d], -trial[d]);
+ pos[d] = std::min(pbc->hbox_diag[d], -trial[d]);
}
else
{
d2old += gmx::square(pos[d]);
d2new += gmx::square(pos[d] + trial[d]);
}
- if (BOX_MARGIN*d2new < d2old)
+ if (BOX_MARGIN * d2new < d2old)
{
/* Check if shifts with one box vector less do better */
gmx_bool bUse = TRUE;
real d2new_c = 0;
for (int d = 0; d < DIM; d++)
{
- d2new_c += gmx::square(pos[d] + trial[d] - shift*box[dd][d]);
+ d2new_c += gmx::square(pos[d] + trial[d] - shift * box[dd][d]);
}
- if (d2new_c <= BOX_MARGIN*d2new)
+ if (d2new_c <= BOX_MARGIN * d2new)
{
bUse = FALSE;
}
/* Accept this shift vector. */
if (pbc->ntric_vec >= MAX_NTRICVEC)
{
- fprintf(stderr, "\nWARNING: Found more than %d triclinic correction vectors, ignoring some.\n"
- " There is probably something wrong with your box.\n", MAX_NTRICVEC);
+ fprintf(stderr,
+ "\nWARNING: Found more than %d triclinic "
+ "correction vectors, ignoring some.\n"
+ " There is probably something wrong with your "
+ "box.\n",
+ MAX_NTRICVEC);
pr_rvecs(stderr, 0, " Box", box, DIM);
}
else
if (debug)
{
- fprintf(debug, " tricvec %2d = %2d %2d %2d %5.2f %5.2f %5.2f %5.2f %5.2f %5.2f %5.2f %5.2f\n",
- pbc->ntric_vec, i, j, k,
- sqrt(d2old), sqrt(d2new),
- trial[XX], trial[YY], trial[ZZ],
+ fprintf(debug,
+ " tricvec %2d = %2d %2d %2d %5.2f %5.2f "
+ "%5.2f %5.2f %5.2f %5.2f %5.2f %5.2f\n",
+ pbc->ntric_vec, i, j, k, sqrt(d2old),
+ sqrt(d2new), trial[XX], trial[YY], trial[ZZ],
pos[XX], pos[YY], pos[ZZ]);
}
}
}
}
-void set_pbc(t_pbc *pbc, int ePBC, const matrix box)
+void set_pbc(t_pbc* pbc, int ePBC, const matrix box)
{
if (ePBC == -1)
{
low_set_pbc(pbc, ePBC, nullptr, box);
}
-t_pbc *set_pbc_dd(t_pbc *pbc, int ePBC,
- const ivec domdecCells,
- gmx_bool bSingleDir, const matrix box)
+t_pbc* set_pbc_dd(t_pbc* pbc, int ePBC, const ivec domdecCells, gmx_bool bSingleDir, const matrix box)
{
if (ePBC == epbcNONE)
{
for (int i = 0; i < DIM; i++)
{
usePBC[i] = 0;
- if (domdecCells[i] <= (bSingleDir ? 1 : 2) &&
- !(ePBC == epbcXY && i == ZZ))
+ if (domdecCells[i] <= (bSingleDir ? 1 : 2) && !(ePBC == epbcXY && i == ZZ))
{
usePBC[i] = 1;
npbcdim++;
return (pbc->ePBC != epbcNONE ? pbc : nullptr);
}
-void pbc_dx(const t_pbc *pbc, const rvec x1, const rvec x2, rvec dx)
+void pbc_dx(const t_pbc* pbc, const rvec x1, const rvec x2, rvec dx)
{
int i, j;
rvec dx_start, trial;
}
break;
case epbcdxTRICLINIC:
- for (i = DIM-1; i >= 0; i--)
+ for (i = DIM - 1; i >= 0; i--)
{
while (dx[i] > pbc->hbox_diag[i])
{
break;
case epbcdx2D_TRIC:
d2min = 0;
- for (i = DIM-1; i >= 0; i--)
+ for (i = DIM - 1; i >= 0; i--)
{
if (i != pbc->dim)
{
dx[j] += pbc->box[i][j];
}
}
- d2min += dx[i]*dx[i];
+ d2min += dx[i] * dx[i];
}
}
if (d2min > pbc->max_cutoff2)
{
if (j != pbc->dim)
{
- d2trial += trial[j]*trial[j];
+ d2trial += trial[j] * trial[j];
}
}
if (d2trial < d2min)
while (dx[XX] > pbc->hbox_diag[XX])
{
dx[XX] -= pbc->fbox_diag[XX];
- bRot = !bRot;
+ bRot = !bRot;
}
while (dx[XX] <= pbc->mhbox_diag[XX])
{
dx[XX] += pbc->fbox_diag[YY];
- bRot = !bRot;
+ bRot = !bRot;
}
if (bRot)
{
}
break;
case epbcdxNOPBC:
- case epbcdxUNSUPPORTED:
- break;
- default:
- gmx_fatal(FARGS, "Internal error in pbc_dx, set_pbc has not been called");
+ case epbcdxUNSUPPORTED: break;
+ default: gmx_fatal(FARGS, "Internal error in pbc_dx, set_pbc has not been called");
}
}
-int pbc_dx_aiuc(const t_pbc *pbc, const rvec x1, const rvec x2, rvec dx)
+int pbc_dx_aiuc(const t_pbc* pbc, const rvec x1, const rvec x2, rvec dx)
{
int i, j, is;
rvec dx_start, trial;
{
if (dx[i] > pbc->hbox_diag[i])
{
- dx[i] -= pbc->fbox_diag[i];
+ dx[i] -= pbc->fbox_diag[i];
ishift[i]--;
}
else if (dx[i] <= pbc->mhbox_diag[i])
{
- dx[i] += pbc->fbox_diag[i];
+ dx[i] += pbc->fbox_diag[i];
ishift[i]++;
}
}
* can cause unlimited displacements.
* Also allowing multiple shifts would index fshift beyond bounds.
*/
- for (i = DIM-1; i >= 1; i--)
+ for (i = DIM - 1; i >= 1; i--)
{
if (dx[i] > pbc->hbox_diag[i])
{
break;
case epbcdx2D_TRIC:
d2min = 0;
- for (i = DIM-1; i >= 1; i--)
+ for (i = DIM - 1; i >= 1; i--)
{
if (i != pbc->dim)
{
}
ishift[i]++;
}
- d2min += dx[i]*dx[i];
+ d2min += dx[i] * dx[i];
}
}
if (pbc->dim != XX)
ishift[XX]++;
}
}
- d2min += dx[XX]*dx[XX];
+ d2min += dx[XX] * dx[XX];
}
if (d2min > pbc->max_cutoff2)
{
{
if (j != pbc->dim)
{
- d2trial += trial[j]*trial[j];
+ d2trial += trial[j] * trial[j];
}
}
if (d2trial < d2min)
}
break;
case epbcdxNOPBC:
- case epbcdxUNSUPPORTED:
- break;
+ case epbcdxUNSUPPORTED: break;
default:
- gmx_fatal(FARGS, "Internal error in pbc_dx_aiuc, set_pbc_dd or set_pbc has not been called");
+ gmx_fatal(FARGS,
+ "Internal error in pbc_dx_aiuc, set_pbc_dd or set_pbc has not been called");
}
is = IVEC2IS(ishift);
}
//! Compute distance vector in double precision
-void pbc_dx_d(const t_pbc *pbc, const dvec x1, const dvec x2, dvec dx)
+void pbc_dx_d(const t_pbc* pbc, const dvec x1, const dvec x2, dvec dx)
{
int i, j;
dvec dx_start, trial;
case epbcdxTRICLINIC:
case epbcdx2D_TRIC:
d2min = 0;
- for (i = DIM-1; i >= 0; i--)
+ for (i = DIM - 1; i >= 0; i--)
{
if (i != pbc->dim)
{
dx[j] += pbc->box[i][j];
}
}
- d2min += dx[i]*dx[i];
+ d2min += dx[i] * dx[i];
}
}
if (d2min > pbc->max_cutoff2)
{
if (j != pbc->dim)
{
- d2trial += trial[j]*trial[j];
+ d2trial += trial[j] * trial[j];
}
}
if (d2trial < d2min)
while (dx[XX] > pbc->hbox_diag[XX])
{
dx[XX] -= pbc->fbox_diag[XX];
- bRot = !bRot;
+ bRot = !bRot;
}
while (dx[XX] <= pbc->mhbox_diag[XX])
{
dx[XX] += pbc->fbox_diag[YY];
- bRot = !bRot;
+ bRot = !bRot;
}
if (bRot)
{
}
break;
case epbcdxNOPBC:
- case epbcdxUNSUPPORTED:
- break;
- default:
- gmx_fatal(FARGS, "Internal error in pbc_dx, set_pbc has not been called");
+ case epbcdxUNSUPPORTED: break;
+ default: gmx_fatal(FARGS, "Internal error in pbc_dx, set_pbc has not been called");
}
}
{
for (int d = 0; d < DIM; d++)
{
- shift_vec[n][d] = k*box[XX][d] + l*box[YY][d] + m*box[ZZ][d];
+ shift_vec[n][d] = k * box[XX][d] + l * box[YY][d] + m * box[ZZ][d];
}
}
}
{
for (d = 0; d < DIM; d++)
{
- box_center[d] += 0.5*box[m][d];
+ box_center[d] += 0.5 * box[m][d];
}
}
break;
case ecenterRECT:
for (d = 0; d < DIM; d++)
{
- box_center[d] = 0.5*box[d][d];
+ box_center[d] = 0.5 * box[d][d];
}
break;
- case ecenterZERO:
- break;
- default:
- gmx_fatal(FARGS, "Unsupported value %d for ecenter", ecenter);
+ case ecenterZERO: break;
+ default: gmx_fatal(FARGS, "Unsupported value %d for ecenter", ecenter);
}
}
/* Get the next 3 in the xy-plane as mirror images */
for (i = 0; i < 3; i++)
{
- svmul(-1, img[i], img[3+i]);
+ svmul(-1, img[i], img[3 + i]);
}
/* Calculate the first 4 out of xy-plane images */
}
for (i = 0; i < 3; i++)
{
- rvec_add(img[6], img[i+1], img[7+i]);
+ rvec_add(img[6], img[i + 1], img[7 + i]);
}
/* Mirror the last 4 from the previous in opposite rotation */
for (i = 0; i < 4; i++)
{
- svmul(-1, img[6 + (2+i) % 4], img[10+i]);
+ svmul(-1, img[6 + (2 + i) % 4], img[10 + i]);
}
}
n = 0;
for (i = 2; i <= 5; i += 3)
{
- tmp[0] = i-1;
+ tmp[0] = i - 1;
if (i == 2)
{
tmp[1] = 8;
{
tmp[1] = 6;
}
- tmp[2] = (i+1) % 6;
- tmp[3] = tmp[1]+4;
+ tmp[2] = (i + 1) % 6;
+ tmp[3] = tmp[1] + 4;
for (j = 0; j < 4; j++)
{
for (d = 0; d < DIM; d++)
{
- vert[n][d] = img[i][d]+img[tmp[j]][d]+img[tmp[(j+1)%4]][d];
+ vert[n][d] = img[i][d] + img[tmp[j]][d] + img[tmp[(j + 1) % 4]][d];
}
n++;
}
}
for (i = 7; i <= 13; i += 6)
{
- tmp[0] = (i-7)/2;
- tmp[1] = tmp[0]+1;
+ tmp[0] = (i - 7) / 2;
+ tmp[1] = tmp[0] + 1;
if (i == 7)
{
tmp[2] = 8;
{
tmp[2] = 10;
}
- tmp[3] = i-1;
+ tmp[3] = i - 1;
for (j = 0; j < 4; j++)
{
for (d = 0; d < DIM; d++)
{
- vert[n][d] = img[i][d]+img[tmp[j]][d]+img[tmp[(j+1)%4]][d];
+ vert[n][d] = img[i][d] + img[tmp[j]][d] + img[tmp[(j + 1) % 4]][d];
}
n++;
}
{
tmp[0] = 0;
}
- tmp[1] = tmp[0]+1;
+ tmp[1] = tmp[0] + 1;
if (i == 9)
{
tmp[2] = 6;
{
tmp[2] = 12;
}
- tmp[3] = i-1;
+ tmp[3] = i - 1;
for (j = 0; j < 4; j++)
{
for (d = 0; d < DIM; d++)
{
- vert[n][d] = img[i][d]+img[tmp[j]][d]+img[tmp[(j+1)%4]][d];
+ vert[n][d] = img[i][d] + img[tmp[j]][d] + img[tmp[(j + 1) % 4]][d];
}
n++;
}
{
for (d = 0; d < DIM; d++)
{
- vert[i][d] = vert[i][d]*oneFourth+box_center[d];
+ vert[i][d] = vert[i][d] * oneFourth + box_center[d];
}
}
}
-int *compact_unitcell_edges()
+int* compact_unitcell_edges()
{
/* this is an index in vert[] (see calc_box_vertices) */
/*static int edge[NCUCEDGE*2];*/
- int *edge;
- static const int hexcon[24] = {
- 0, 9, 1, 19, 2, 15, 3, 21,
- 4, 17, 5, 11, 6, 23, 7, 13,
- 8, 20, 10, 18, 12, 16, 14, 22
- };
+ int* edge;
+ static const int hexcon[24] = { 0, 9, 1, 19, 2, 15, 3, 21, 4, 17, 5, 11,
+ 6, 23, 7, 13, 8, 20, 10, 18, 12, 16, 14, 22 };
int e, i, j;
- snew(edge, NCUCEDGE*2);
+ snew(edge, NCUCEDGE * 2);
e = 0;
for (i = 0; i < 6; i++)
{
for (j = 0; j < 4; j++)
{
- edge[e++] = 4*i + j;
- edge[e++] = 4*i + (j+1) % 4;
+ edge[e++] = 4 * i + j;
+ edge[e++] = 4 * i + (j + 1) % 4;
}
}
- for (i = 0; i < 12*2; i++)
+ for (i = 0; i < 12 * 2; i++)
{
edge[e++] = hexcon[i];
}
{
for (gmx::index i = 0; (i < x.ssize()); ++i)
{
- for (m = npbcdim-1; m >= 0; m--)
+ for (m = npbcdim - 1; m >= 0; m--)
{
while (x[i][m] < 0)
{
try
{
size_t natoms = x.size();
- size_t offset = (natoms*t )/nth;
- size_t len = (natoms*(t + 1))/nth - offset;
+ size_t offset = (natoms * t) / nth;
+ size_t len = (natoms * (t + 1)) / nth - offset;
put_atoms_in_box(ePBC, box, x.subArray(offset, len));
}
- GMX_CATCH_ALL_AND_EXIT_WITH_FATAL_ERROR;
+ GMX_CATCH_ALL_AND_EXIT_WITH_FATAL_ERROR
}
}
-void put_atoms_in_triclinic_unitcell(int ecenter, const matrix box,
- gmx::ArrayRef<gmx::RVec> x)
+void put_atoms_in_triclinic_unitcell(int ecenter, const matrix box, gmx::ArrayRef<gmx::RVec> x)
{
- rvec box_center, shift_center;
- real shm01, shm02, shm12, shift;
- int m, d;
+ rvec box_center, shift_center;
+ real shm01, shm02, shm12, shift;
+ int m, d;
calc_box_center(ecenter, box, box_center);
/* The product of matrix shm with a coordinate gives the shift vector
which is required determine the periodic cell position */
- shm01 = box[1][0]/box[1][1];
- shm02 = (box[1][1]*box[2][0] - box[2][1]*box[1][0])/(box[1][1]*box[2][2]);
- shm12 = box[2][1]/box[2][2];
+ shm01 = box[1][0] / box[1][1];
+ shm02 = (box[1][1] * box[2][0] - box[2][1] * box[1][0]) / (box[1][1] * box[2][2]);
+ shm12 = box[2][1] / box[2][2];
clear_rvec(shift_center);
for (d = 0; d < DIM; d++)
svmul(0.5, shift_center, shift_center);
rvec_sub(box_center, shift_center, shift_center);
- shift_center[0] = shm01*shift_center[1] + shm02*shift_center[2];
- shift_center[1] = shm12*shift_center[2];
+ shift_center[0] = shm01 * shift_center[1] + shm02 * shift_center[2];
+ shift_center[1] = shm12 * shift_center[2];
shift_center[2] = 0;
for (gmx::index i = 0; (i < x.ssize()); ++i)
{
- for (m = DIM-1; m >= 0; m--)
+ for (m = DIM - 1; m >= 0; m--)
{
shift = shift_center[m];
if (m == 0)
{
- shift += shm01*x[i][1] + shm02*x[i][2];
+ shift += shm01 * x[i][1] + shm02 * x[i][2];
}
else if (m == 1)
{
- shift += shm12*x[i][2];
+ shift += shm12 * x[i][2];
}
- while (x[i][m]-shift < 0)
+ while (x[i][m] - shift < 0)
{
for (d = 0; d <= m; d++)
{
x[i][d] += box[m][d];
}
}
- while (x[i][m]-shift >= box[m][m])
+ while (x[i][m] - shift >= box[m][m])
{
for (d = 0; d <= m; d++)
{
}
}
-void put_atoms_in_compact_unitcell(int ePBC, int ecenter, const matrix box,
- gmx::ArrayRef<gmx::RVec> x)
+void put_atoms_in_compact_unitcell(int ePBC, int ecenter, const matrix box, gmx::ArrayRef<gmx::RVec> x)
{
t_pbc pbc;
rvec box_center, dx;
* \param[in,out] x The coordinates of the atoms
* \param[in] bFirst Specifier for first-time PBC removal
*/
-static void low_do_pbc_mtop(FILE *fplog, int ePBC, const matrix box,
- const gmx_mtop_t *mtop, rvec x[],
- gmx_bool bFirst)
+static void low_do_pbc_mtop(FILE* fplog, int ePBC, const matrix box, const gmx_mtop_t* mtop, rvec x[], gmx_bool bFirst)
{
- t_graph *graph;
- int as, mol;
+ t_graph* graph;
+ int as, mol;
if (bFirst && fplog)
{
snew(graph, 1);
as = 0;
- for (const gmx_molblock_t &molb : mtop->molblock)
+ for (const gmx_molblock_t& molb : mtop->molblock)
{
- const gmx_moltype_t &moltype = mtop->moltype[molb.type];
- if (moltype.atoms.nr == 1 ||
- (!bFirst && moltype.atoms.nr == 1))
+ const gmx_moltype_t& moltype = mtop->moltype[molb.type];
+ if (moltype.atoms.nr == 1 || (!bFirst && moltype.atoms.nr == 1))
{
/* Just one atom or charge group in the molecule, no PBC required */
- as += molb.nmol*moltype.atoms.nr;
+ as += molb.nmol * moltype.atoms.nr;
}
else
{
for (mol = 0; mol < molb.nmol; mol++)
{
- mk_mshift(fplog, graph, ePBC, box, x+as);
+ mk_mshift(fplog, graph, ePBC, box, x + as);
- shift_self(graph, box, x+as);
+ shift_self(graph, box, x + as);
/* The molecule is whole now.
* We don't need the second mk_mshift call as in do_pbc_first,
* since we no longer need this graph.
sfree(graph);
}
-void do_pbc_first_mtop(FILE *fplog, int ePBC, const matrix box,
- const gmx_mtop_t *mtop, rvec x[])
+void do_pbc_first_mtop(FILE* fplog, int ePBC, const matrix box, const gmx_mtop_t* mtop, rvec x[])
{
low_do_pbc_mtop(fplog, ePBC, box, mtop, x, TRUE);
}
-void do_pbc_mtop(int ePBC, const matrix box,
- const gmx_mtop_t *mtop, rvec x[])
+void do_pbc_mtop(int ePBC, const matrix box, const gmx_mtop_t* mtop, rvec x[])
{
low_do_pbc_mtop(nullptr, ePBC, box, mtop, x, FALSE);
}