*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015,2017, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2017,2019, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#include "gromacs/utility/arraysize.h"
#include "gromacs/utility/smalloc.h"
-int gmx_filter(int argc, char *argv[])
+int gmx_filter(int argc, char* argv[])
{
- const char *desc[] = {
+ const char* desc[] = {
"[THISMODULE] performs frequency filtering on a trajectory.",
"The filter shape is cos([GRK]pi[grk] t/A) + 1 from -A to +A, where A is given",
"by the option [TT]-nf[tt] times the time step in the input trajectory.",
"the coordinates in the structure file."
};
- static int nf = 10;
- static gmx_bool bNoJump = TRUE, bFit = FALSE, bLowAll = FALSE;
- t_pargs pa[] = {
- { "-nf", FALSE, etINT, {&nf},
+ static int nf = 10;
+ static gmx_bool bNoJump = TRUE, bFit = FALSE, bLowAll = FALSE;
+ t_pargs pa[] = {
+ { "-nf",
+ FALSE,
+ etINT,
+ { &nf },
"Sets the filter length as well as the output interval for low-pass filtering" },
- { "-all", FALSE, etBOOL, {&bLowAll},
- "Write all low-pass filtered frames" },
- { "-nojump", FALSE, etBOOL, {&bNoJump},
- "Remove jumps of atoms across the box" },
- { "-fit", FALSE, etBOOL, {&bFit},
- "Fit all frames to a reference structure" }
+ { "-all", FALSE, etBOOL, { &bLowAll }, "Write all low-pass filtered frames" },
+ { "-nojump", FALSE, etBOOL, { &bNoJump }, "Remove jumps of atoms across the box" },
+ { "-fit", FALSE, etBOOL, { &bFit }, "Fit all frames to a reference structure" }
};
- const char *topfile, *lowfile, *highfile;
+ const char * topfile, *lowfile, *highfile;
gmx_bool bTop = FALSE;
t_topology top;
int ePBC = -1;
- rvec *xtop;
+ rvec* xtop;
matrix topbox, *box, boxf;
- char *grpname;
+ char* grpname;
int isize;
- int *index;
- real *w_rls = nullptr;
- t_trxstatus *in;
- t_trxstatus *outl, *outh;
+ int* index;
+ real* w_rls = nullptr;
+ t_trxstatus* in;
+ t_trxstatus * outl, *outh;
int nffr, i, fr, nat, j, d, m;
- int *ind;
+ int* ind;
real flen, *filt, sum, *t;
rvec xcmtop, xcm, **x, *ptr, *xf, *xn, *xp, hbox;
- gmx_output_env_t *oenv;
+ gmx_output_env_t* oenv;
gmx_rmpbc_t gpbc = nullptr;
#define NLEG asize(leg)
- t_filenm fnm[] = {
- { efTRX, "-f", nullptr, ffREAD },
- { efTPS, nullptr, nullptr, ffOPTRD },
- { efNDX, nullptr, nullptr, ffOPTRD },
- { efTRO, "-ol", "lowpass", ffOPTWR },
- { efTRO, "-oh", "highpass", ffOPTWR }
- };
+ t_filenm fnm[] = { { efTRX, "-f", nullptr, ffREAD },
+ { efTPS, nullptr, nullptr, ffOPTRD },
+ { efNDX, nullptr, nullptr, ffOPTRD },
+ { efTRO, "-ol", "lowpass", ffOPTWR },
+ { efTRO, "-oh", "highpass", ffOPTWR } };
#define NFILE asize(fnm)
- if (!parse_common_args(&argc, argv, PCA_CAN_TIME | PCA_CAN_VIEW,
- NFILE, fnm, asize(pa), pa, asize(desc), desc, 0, nullptr, &oenv))
+ if (!parse_common_args(&argc, argv, PCA_CAN_TIME | PCA_CAN_VIEW, NFILE, fnm, asize(pa), pa,
+ asize(desc), desc, 0, nullptr, &oenv))
{
return 0;
}
}
if (topfile)
{
- bTop = read_tps_conf(ftp2fn(efTPS, NFILE, fnm), &top, &ePBC,
- &xtop, nullptr, topbox, TRUE);
+ bTop = read_tps_conf(ftp2fn(efTPS, NFILE, fnm), &top, &ePBC, &xtop, nullptr, topbox, TRUE);
if (bTop)
{
gpbc = gmx_rmpbc_init(&top.idef, ePBC, top.atoms.nr);
}
/* The actual filter length flen can actually be any real number */
- flen = 2*nf;
+ flen = 2 * nf;
/* nffr is the number of frames that we filter over */
- nffr = 2*nf - 1;
+ nffr = 2 * nf - 1;
snew(filt, nffr);
sum = 0;
for (i = 0; i < nffr; i++)
{
- filt[i] = std::cos(2*M_PI*(i - nf + 1)/static_cast<real>(flen)) + 1;
- sum += filt[i];
+ filt[i] = std::cos(2 * M_PI * (i - nf + 1) / static_cast<real>(flen)) + 1;
+ sum += filt[i];
}
fprintf(stdout, "filter weights:");
for (i = 0; i < nffr; i++)
snew(x, nffr);
snew(box, nffr);
- nat = read_first_x(oenv, &in, opt2fn("-f", NFILE, fnm),
- &(t[nffr - 1]), &(x[nffr - 1]), box[nffr - 1]);
+ nat = read_first_x(oenv, &in, opt2fn("-f", NFILE, fnm), &(t[nffr - 1]), &(x[nffr - 1]), box[nffr - 1]);
snew(ind, nat);
for (i = 0; i < nat; i++)
{
ind[i] = i;
}
/* x[nffr - 1] was already allocated by read_first_x */
- for (i = 0; i < nffr-1; i++)
+ for (i = 0; i < nffr - 1; i++)
{
snew(x[i], nat);
}
{
for (d = 0; d < DIM; d++)
{
- hbox[d] = 0.5*box[nffr - 1][d][d];
+ hbox[d] = 0.5 * box[nffr - 1][d][d];
}
}
for (i = 0; i < nat; i++)
{
- for (m = DIM-1; m >= 0; m--)
+ for (m = DIM - 1; m >= 0; m--)
{
if (hbox[m] > 0)
{
{
for (d = 0; d < DIM; d++)
{
- xf[j][d] += filt[i]*x[i][j][d];
+ xf[j][d] += filt[i] * x[i][j][d];
}
}
for (j = 0; j < DIM; j++)
{
for (d = 0; d < DIM; d++)
{
- boxf[j][d] += filt[i]*box[i][j][d];
+ boxf[j][d] += filt[i] * box[i][j][d];
}
}
}
if (outl && (bLowAll || fr % nf == nf - 1))
{
- write_trx(outl, nat, ind, topfile ? &(top.atoms) : nullptr,
- 0, t[nf - 1], bFit ? topbox : boxf, xf, nullptr, nullptr);
+ write_trx(outl, nat, ind, topfile ? &(top.atoms) : nullptr, 0, t[nf - 1],
+ bFit ? topbox : boxf, xf, nullptr, nullptr);
}
if (outh)
{
boxf[j][d] = topbox[j][d] + box[nf - 1][j][d] - boxf[j][d];
}
}
- write_trx(outh, nat, ind, topfile ? &(top.atoms) : nullptr,
- 0, t[nf - 1], bFit ? topbox : boxf, xf, nullptr, nullptr);
+ write_trx(outh, nat, ind, topfile ? &(top.atoms) : nullptr, 0, t[nf - 1],
+ bFit ? topbox : boxf, xf, nullptr, nullptr);
}
}
/* Cycle all the pointer and the box by one */
ptr = x[0];
- for (i = 0; i < nffr-1; i++)
+ for (i = 0; i < nffr - 1; i++)
{
- t[i] = t[i+1];
- x[i] = x[i+1];
- copy_mat(box[i+1], box[i]);
+ t[i] = t[i + 1];
+ x[i] = x[i + 1];
+ copy_mat(box[i + 1], box[i]);
}
x[nffr - 1] = ptr;
fr++;
- }
- while (read_next_x(oenv, in, &(t[nffr - 1]), x[nffr - 1], box[nffr - 1]));
+ } while (read_next_x(oenv, in, &(t[nffr - 1]), x[nffr - 1], box[nffr - 1]));
if (bTop)
{