/* UTILITIES */
-void add_param_to_list(InteractionsOfType *list, const InteractionOfType &b)
+void add_param_to_list(InteractionsOfType* list, const InteractionOfType& b)
{
list->interactionTypes.emplace_back(b);
}
/* PRINTING STRUCTURES */
-static void print_bt(FILE *out, Directive d, PreprocessingAtomTypes *at,
- int ftype, int fsubtype, gmx::ArrayRef<const InteractionsOfType> plist,
- bool bFullDih)
+static void print_bt(FILE* out,
+ Directive d,
+ PreprocessingAtomTypes* at,
+ int ftype,
+ int fsubtype,
+ gmx::ArrayRef<const InteractionsOfType> plist,
+ bool bFullDih)
{
/* This dihp is a DIRTY patch because the dih-types do not use
* all four atoms to determine the type.
*/
- const int dihp[2][2] = { { 1, 2 }, { 0, 3 } };
- int nral, nrfp;
- bool bDih = false, bSwapParity;
+ const int dihp[2][2] = { { 1, 2 }, { 0, 3 } };
+ int nral, nrfp;
+ bool bDih = false, bSwapParity;
- const InteractionsOfType *bt = &(plist[ftype]);
+ const InteractionsOfType* bt = &(plist[ftype]);
if (bt->size() == 0)
{
int f = 0;
switch (ftype)
{
- case F_G96ANGLES:
- f = 1;
- break;
- case F_G96BONDS:
- f = 1;
- break;
- case F_MORSE:
- f = 2;
- break;
- case F_CUBICBONDS:
- f = 3;
- break;
- case F_CONNBONDS:
- f = 4;
- break;
- case F_HARMONIC:
- f = 5;
- break;
- case F_CROSS_BOND_ANGLES:
- f = 2;
- break;
- case F_CROSS_BOND_BONDS:
- f = 3;
- break;
- case F_UREY_BRADLEY:
- f = 4;
- break;
+ case F_G96ANGLES: f = 1; break;
+ case F_G96BONDS: f = 1; break;
+ case F_MORSE: f = 2; break;
+ case F_CUBICBONDS: f = 3; break;
+ case F_CONNBONDS: f = 4; break;
+ case F_HARMONIC: f = 5; break;
+ case F_CROSS_BOND_ANGLES: f = 2; break;
+ case F_CROSS_BOND_BONDS: f = 3; break;
+ case F_UREY_BRADLEY: f = 4; break;
case F_PDIHS:
case F_RBDIHS:
- case F_FOURDIHS:
- bDih = TRUE;
- break;
+ case F_FOURDIHS: bDih = TRUE; break;
case F_IDIHS:
f = 1;
bDih = TRUE;
break;
- case F_CONSTRNC:
- f = 1;
- break;
- case F_VSITE3FD:
- f = 1;
- break;
- case F_VSITE3FAD:
- f = 2;
- break;
- case F_VSITE3OUT:
- f = 3;
- break;
- case F_VSITE4FDN:
- f = 1;
- break;
- case F_CMAP:
- f = 1;
- break;
-
- default:
- bDih = FALSE;
+ case F_CONSTRNC: f = 1; break;
+ case F_VSITE3FD: f = 1; break;
+ case F_VSITE3FAD: f = 2; break;
+ case F_VSITE3OUT: f = 3; break;
+ case F_VSITE4FDN: f = 1; break;
+ case F_CMAP: f = 1; break;
+
+ default: bDih = FALSE;
}
if (bFullDih)
{
}
if (fsubtype)
{
- f = fsubtype-1;
+ f = fsubtype - 1;
}
nral = NRAL(ftype);
fprintf(out, "; ");
if (!bDih)
{
- fprintf (out, "%3s %4s", "ai", "aj");
+ fprintf(out, "%3s %4s", "ai", "aj");
for (int j = 2; (j < nral); j++)
{
- fprintf (out, " %3c%c", 'a', 'i'+j);
+ fprintf(out, " %3c%c", 'a', 'i' + j);
}
}
else
{
for (int j = 0; (j < 2); j++)
{
- fprintf (out, "%3c%c", 'a', 'i'+dihp[f][j]);
+ fprintf(out, "%3c%c", 'a', 'i' + dihp[f][j]);
}
}
- fprintf (out, " funct");
+ fprintf(out, " funct");
for (int j = 0; (j < nrfp); j++)
{
- fprintf (out, " %12c%1d", 'c', j);
+ fprintf(out, " %12c%1d", 'c', j);
}
- fprintf (out, "\n");
+ fprintf(out, "\n");
/* print bondtypes */
- for (const auto &parm : bt->interactionTypes)
+ for (const auto& parm : bt->interactionTypes)
{
- bSwapParity = (parm.c0() == NOTSET) && (parm.c1() == -1);
+ bSwapParity = (parm.c0() == NOTSET) && (parm.c1() == -1);
gmx::ArrayRef<const int> atoms = parm.atoms();
if (!bDih)
{
for (int j = 0; (j < nral); j++)
{
- fprintf (out, "%5s ", at->atomNameFromAtomType(atoms[j]));
+ fprintf(out, "%5s ", at->atomNameFromAtomType(atoms[j]));
}
}
else
{
for (int j = 0; (j < 2); j++)
{
- fprintf (out, "%5s ", at->atomNameFromAtomType(atoms[dihp[f][j]]));
+ fprintf(out, "%5s ", at->atomNameFromAtomType(atoms[dihp[f][j]]));
}
}
- fprintf (out, "%5d ", bSwapParity ? -f-1 : f+1);
+ fprintf(out, "%5d ", bSwapParity ? -f - 1 : f + 1);
if (!parm.interactionTypeName().empty())
{
gmx::ArrayRef<const real> forceParam = parm.forceParam();
for (int j = 0; (j < nrfp) && (forceParam[j] != NOTSET); j++)
{
- fprintf (out, "%13.6e ", forceParam[j]);
+ fprintf(out, "%13.6e ", forceParam[j]);
}
}
- fprintf (out, "\n");
+ fprintf(out, "\n");
}
- fprintf (out, "\n");
- fflush (out);
+ fprintf(out, "\n");
+ fflush(out);
}
-void print_excl(FILE *out, int natoms, t_excls excls[])
+void print_excl(FILE* out, int natoms, t_excls excls[])
{
- int i;
- bool have_excl;
- int j;
+ int i;
+ bool have_excl;
+ int j;
have_excl = FALSE;
for (i = 0; i < natoms && !have_excl; i++)
if (have_excl)
{
- fprintf (out, "[ %s ]\n", dir2str(Directive::d_exclusions));
- fprintf (out, "; %4s %s\n", "i", "excluded from i");
+ fprintf(out, "[ %s ]\n", dir2str(Directive::d_exclusions));
+ fprintf(out, "; %4s %s\n", "i", "excluded from i");
for (i = 0; i < natoms; i++)
{
if (excls[i].nr > 0)
{
- fprintf (out, "%6d ", i+1);
+ fprintf(out, "%6d ", i + 1);
for (j = 0; j < excls[i].nr; j++)
{
- fprintf (out, " %5d", excls[i].e[j]+1);
+ fprintf(out, " %5d", excls[i].e[j] + 1);
}
- fprintf (out, "\n");
+ fprintf(out, "\n");
}
}
- fprintf (out, "\n");
+ fprintf(out, "\n");
fflush(out);
}
}
-static double get_residue_charge(const t_atoms *atoms, int at)
+static double get_residue_charge(const t_atoms* atoms, int at)
{
int ri;
double q;
return q;
}
-void print_atoms(FILE *out, PreprocessingAtomTypes *atype, t_atoms *at, int *cgnr,
- bool bRTPresname)
+void print_atoms(FILE* out, PreprocessingAtomTypes* atype, t_atoms* at, int* cgnr, bool bRTPresname)
{
- int i, ri;
- int tpA, tpB;
- const char *as;
- const char *tpnmA, *tpnmB;
- double qres, qtot;
+ int i, ri;
+ int tpA, tpB;
+ const char* as;
+ const char *tpnmA, *tpnmB;
+ double qres, qtot;
as = dir2str(Directive::d_atoms);
fprintf(out, "[ %s ]\n", as);
- fprintf(out, "; %4s %10s %6s %7s%6s %6s %10s %10s %6s %10s %10s\n",
- "nr", "type", "resnr", "residue", "atom", "cgnr", "charge", "mass", "typeB", "chargeB", "massB");
+ fprintf(out, "; %4s %10s %6s %7s%6s %6s %10s %10s %6s %10s %10s\n", "nr", "type", "resnr",
+ "residue", "atom", "cgnr", "charge", "mass", "typeB", "chargeB", "massB");
- qtot = 0;
+ qtot = 0;
if (at->nres)
{
for (i = 0; (i < at->nr); i++)
{
ri = at->atom[i].resind;
- if ((i == 0 || ri != at->atom[i-1].resind) &&
- at->resinfo[ri].rtp != nullptr)
+ if ((i == 0 || ri != at->atom[i - 1].resind) && at->resinfo[ri].rtp != nullptr)
{
qres = get_residue_charge(at, i);
- fprintf(out, "; residue %3d %-3s rtp %-4s q ",
- at->resinfo[ri].nr,
- *at->resinfo[ri].name,
- *at->resinfo[ri].rtp);
+ fprintf(out, "; residue %3d %-3s rtp %-4s q ", at->resinfo[ri].nr,
+ *at->resinfo[ri].name, *at->resinfo[ri].rtp);
if (fabs(qres) < 0.001)
{
fprintf(out, " %s", "0.0");
}
/* This is true by construction, but static analysers don't know */
- GMX_ASSERT(!bRTPresname || at->resinfo[at->atom[i].resind].rtp, "-rtpres did not have residue name available");
- fprintf(out, "%6d %10s %6d%c %5s %6s %6d %10g %10g",
- i+1, tpnmA,
- at->resinfo[ri].nr,
+ GMX_ASSERT(!bRTPresname || at->resinfo[at->atom[i].resind].rtp,
+ "-rtpres did not have residue name available");
+ fprintf(out, "%6d %10s %6d%c %5s %6s %6d %10g %10g", i + 1, tpnmA, at->resinfo[ri].nr,
at->resinfo[ri].ic,
- bRTPresname ?
- *(at->resinfo[at->atom[i].resind].rtp) :
- *(at->resinfo[at->atom[i].resind].name),
- *(at->atomname[i]), cgnr[i],
- at->atom[i].q, at->atom[i].m);
+ bRTPresname ? *(at->resinfo[at->atom[i].resind].rtp)
+ : *(at->resinfo[at->atom[i].resind].name),
+ *(at->atomname[i]), cgnr[i], at->atom[i].q, at->atom[i].m);
if (PERTURBED(at->atom[i]))
{
tpB = at->atom[i].typeB;
{
gmx_fatal(FARGS, "tpB = %d, i= %d in print_atoms", tpB, i);
}
- fprintf(out, " %6s %10g %10g",
- tpnmB, at->atom[i].qB, at->atom[i].mB);
+ fprintf(out, " %6s %10g %10g", tpnmB, at->atom[i].qB, at->atom[i].mB);
}
// Accumulate the total charge to help troubleshoot issues.
qtot += static_cast<double>(at->atom[i].q);
// Write the total charge for the last atom of the system
// and/or residue, because generally that's where it is
// expected to be an integer.
- if (i == at->nr-1 || ri != at->atom[i+1].resind)
+ if (i == at->nr - 1 || ri != at->atom[i + 1].resind)
{
fprintf(out, " ; qtot %.4g\n", qtot);
}
fflush(out);
}
-void print_bondeds(FILE *out, int natoms, Directive d,
- int ftype, int fsubtype, gmx::ArrayRef<const InteractionsOfType> plist)
+void print_bondeds(FILE* out, int natoms, Directive d, int ftype, int fsubtype, gmx::ArrayRef<const InteractionsOfType> plist)
{
- t_symtab stab;
- t_atom *a;
+ t_symtab stab;
+ t_atom* a;
PreprocessingAtomTypes atype;
snew(a, 1);
for (int i = 0; (i < natoms); i++)
{
char buf[12];
- sprintf(buf, "%4d", (i+1));
+ sprintf(buf, "%4d", (i + 1));
atype.addType(&stab, *a, buf, InteractionOfType({}, {}), 0, 0);
}
print_bt(out, d, &atype, ftype, fsubtype, plist, TRUE);