From bc9e45ca5abc026cfb6c45a00e848f4cf538d6ea Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 27 Feb 2022 11:57:40 -0500 Subject: [PATCH] use consistent names, avoid memory leaks, fix off-by-1 error in fourier dihedral --- src/INTEL/angle_charmm_intel.cpp | 5 +-- src/INTEL/angle_charmm_intel.h | 2 +- src/INTEL/angle_harmonic_intel.cpp | 6 +-- src/INTEL/angle_harmonic_intel.h | 2 +- src/INTEL/bond_fene_intel.cpp | 5 +-- src/INTEL/bond_fene_intel.h | 2 +- src/INTEL/bond_harmonic_intel.cpp | 5 +-- src/INTEL/bond_harmonic_intel.h | 2 +- src/INTEL/dihedral_charmm_intel.cpp | 55 +++++++++++++-------------- src/INTEL/dihedral_charmm_intel.h | 8 ++-- src/INTEL/dihedral_fourier_intel.cpp | 40 +++++++++---------- src/INTEL/dihedral_fourier_intel.h | 8 ++-- src/INTEL/dihedral_harmonic_intel.cpp | 37 +++++++++--------- src/INTEL/dihedral_harmonic_intel.h | 8 ++-- src/INTEL/dihedral_opls_intel.cpp | 45 +++++++++++----------- src/INTEL/dihedral_opls_intel.h | 8 ++-- src/INTEL/improper_cvff_intel.cpp | 21 +++++----- src/INTEL/improper_cvff_intel.h | 2 +- src/INTEL/improper_harmonic_intel.cpp | 21 +++++----- src/INTEL/improper_harmonic_intel.h | 2 +- 20 files changed, 135 insertions(+), 149 deletions(-) diff --git a/src/INTEL/angle_charmm_intel.cpp b/src/INTEL/angle_charmm_intel.cpp index 154e343135..d072b5dd17 100644 --- a/src/INTEL/angle_charmm_intel.cpp +++ b/src/INTEL/angle_charmm_intel.cpp @@ -363,13 +363,12 @@ void AngleCharmmIntel::pack_force_const(ForceConst &fc, template void AngleCharmmIntel::ForceConst::set_ntypes(const int nangletypes, Memory *memory) { + if (memory != nullptr) _memory = memory; if (nangletypes != _nangletypes) { - if (_nangletypes > 0) - _memory->destroy(fc); + _memory->destroy(fc); if (nangletypes > 0) _memory->create(fc,nangletypes,"anglecharmmintel.fc"); } _nangletypes = nangletypes; - _memory = memory; } diff --git a/src/INTEL/angle_charmm_intel.h b/src/INTEL/angle_charmm_intel.h index 6758602843..2a9400964d 100644 --- a/src/INTEL/angle_charmm_intel.h +++ b/src/INTEL/angle_charmm_intel.h @@ -60,7 +60,7 @@ class AngleCharmmIntel : public AngleCharmm { } fc_packed1; fc_packed1 *fc; - ForceConst() : _nangletypes(0) {} + ForceConst() : fc(nullptr), _nangletypes(0) {} ~ForceConst() { set_ntypes(0, nullptr); } void set_ntypes(const int nangletypes, Memory *memory); diff --git a/src/INTEL/angle_harmonic_intel.cpp b/src/INTEL/angle_harmonic_intel.cpp index a4aedb7ddd..5eaac898ff 100644 --- a/src/INTEL/angle_harmonic_intel.cpp +++ b/src/INTEL/angle_harmonic_intel.cpp @@ -343,13 +343,11 @@ void AngleHarmonicIntel::pack_force_const(ForceConst &fc, template void AngleHarmonicIntel::ForceConst::set_ntypes(const int nangletypes, Memory *memory) { + if (memory != nullptr) _memory = memory; if (nangletypes != _nangletypes) { - if (_nangletypes > 0) - _memory->destroy(fc); - + _memory->destroy(fc); if (nangletypes > 0) _memory->create(fc,nangletypes,"anglecharmmintel.fc"); } _nangletypes = nangletypes; - _memory = memory; } diff --git a/src/INTEL/angle_harmonic_intel.h b/src/INTEL/angle_harmonic_intel.h index 650e5363a3..6d22f1af28 100644 --- a/src/INTEL/angle_harmonic_intel.h +++ b/src/INTEL/angle_harmonic_intel.h @@ -60,7 +60,7 @@ class AngleHarmonicIntel : public AngleHarmonic { } fc_packed1; fc_packed1 *fc; - ForceConst() : _nangletypes(0) {} + ForceConst() : fc(nullptr), _nangletypes(0) {} ~ForceConst() { set_ntypes(0, nullptr); } void set_ntypes(const int nangletypes, Memory *memory); diff --git a/src/INTEL/bond_fene_intel.cpp b/src/INTEL/bond_fene_intel.cpp index 4c92b3109f..b1e63df42f 100644 --- a/src/INTEL/bond_fene_intel.cpp +++ b/src/INTEL/bond_fene_intel.cpp @@ -323,13 +323,12 @@ void BondFENEIntel::pack_force_const(ForceConst &fc, template void BondFENEIntel::ForceConst::set_ntypes(const int nbondtypes, Memory *memory) { + if (memory != nullptr) _memory = memory; if (nbondtypes != _nbondtypes) { - if (_nbondtypes > 0) - _memory->destroy(fc); + _memory->destroy(fc); if (nbondtypes > 0) _memory->create(fc,nbondtypes,"bondfeneintel.fc"); } _nbondtypes = nbondtypes; - _memory = memory; } diff --git a/src/INTEL/bond_fene_intel.h b/src/INTEL/bond_fene_intel.h index 0bb5479ede..9c22cecb11 100644 --- a/src/INTEL/bond_fene_intel.h +++ b/src/INTEL/bond_fene_intel.h @@ -60,7 +60,7 @@ class BondFENEIntel : public BondFENE { } fc_packed1; fc_packed1 *fc; - ForceConst() : _nbondtypes(0) {} + ForceConst() : fc(nullptr), _nbondtypes(0) {} ~ForceConst() { set_ntypes(0, nullptr); } void set_ntypes(const int nbondtypes, Memory *memory); diff --git a/src/INTEL/bond_harmonic_intel.cpp b/src/INTEL/bond_harmonic_intel.cpp index 4df95305d6..912d2b4474 100644 --- a/src/INTEL/bond_harmonic_intel.cpp +++ b/src/INTEL/bond_harmonic_intel.cpp @@ -291,13 +291,12 @@ void BondHarmonicIntel::pack_force_const(ForceConst &fc, template void BondHarmonicIntel::ForceConst::set_ntypes(const int nbondtypes, Memory *memory) { + if (memory != nullptr) _memory = memory; if (nbondtypes != _nbondtypes) { - if (_nbondtypes > 0) - _memory->destroy(fc); + _memory->destroy(fc); if (nbondtypes > 0) _memory->create(fc,nbondtypes,"bondharmonicintel.fc"); } _nbondtypes = nbondtypes; - _memory = memory; } diff --git a/src/INTEL/bond_harmonic_intel.h b/src/INTEL/bond_harmonic_intel.h index 7568dbe6e7..cfed9d715c 100644 --- a/src/INTEL/bond_harmonic_intel.h +++ b/src/INTEL/bond_harmonic_intel.h @@ -60,7 +60,7 @@ class BondHarmonicIntel : public BondHarmonic { } fc_packed1; fc_packed1 *fc; - ForceConst() : _nbondtypes(0) {} + ForceConst() : fc(nullptr), _nbondtypes(0) {} ~ForceConst() { set_ntypes(0, nullptr); } void set_ntypes(const int nbondtypes, Memory *memory); diff --git a/src/INTEL/dihedral_charmm_intel.cpp b/src/INTEL/dihedral_charmm_intel.cpp index 5d013121b9..349a7c5445 100644 --- a/src/INTEL/dihedral_charmm_intel.cpp +++ b/src/INTEL/dihedral_charmm_intel.cpp @@ -261,10 +261,10 @@ void DihedralCharmmIntel::eval(const int vflag, if (c > (flt_t)1.0) c = (flt_t)1.0; if (c < (flt_t)-1.0) c = (flt_t)-1.0; - const flt_t tcos_shift = fc.bp[type].cos_shift; - const flt_t tsin_shift = fc.bp[type].sin_shift; - const flt_t tk = fc.bp[type].k; - const int m = fc.bp[type].multiplicity; + const flt_t tcos_shift = fc.fc[type].cos_shift; + const flt_t tsin_shift = fc.fc[type].sin_shift; + const flt_t tk = fc.fc[type].k; + const int m = fc.fc[type].multiplicity; flt_t p = (flt_t)1.0; flt_t ddf1, df1; @@ -539,10 +539,10 @@ void DihedralCharmmIntel::eval(const int vflag, (int *) neighbor->dihedrallist[0]; const flt_t * _noalias const weight = &(fc.weight[0]); const flt_t * _noalias const x_f = &(x[0].x); - const flt_t * _noalias const cos_shift = &(fc.bp[0].cos_shift); - const flt_t * _noalias const sin_shift = &(fc.bp[0].sin_shift); - const flt_t * _noalias const k = &(fc.bp[0].k); - const int * _noalias const multiplicity = &(fc.bp[0].multiplicity); + const flt_t * _noalias const cos_shift = &(fc.fc[0].cos_shift); + const flt_t * _noalias const sin_shift = &(fc.fc[0].sin_shift); + const flt_t * _noalias const k = &(fc.fc[0].k); + const int * _noalias const multiplicity = &(fc.fc[0].multiplicity); const flt_t * _noalias const plj1 = &(fc.ljp[0][0].lj1); const flt_t * _noalias const plj2 = &(fc.ljp[0][0].lj2); const flt_t * _noalias const plj3 = &(fc.ljp[0][0].lj3); @@ -937,8 +937,8 @@ void DihedralCharmmIntel::pack_force_const(ForceConst &fc, { const int tp1 = atom->ntypes + 1; - const int bp1 = atom->ndihedraltypes + 1; - fc.set_ntypes(tp1,bp1,memory); + const int dp1 = atom->ndihedraltypes + 1; + fc.set_ntypes(tp1,dp1,memory); buffers->set_ntypes(tp1); if (weightflag) { @@ -952,11 +952,11 @@ void DihedralCharmmIntel::pack_force_const(ForceConst &fc, } } - for (int i = 1; i < bp1; i++) { - fc.bp[i].multiplicity = multiplicity[i]; - fc.bp[i].cos_shift = cos_shift[i]; - fc.bp[i].sin_shift = sin_shift[i]; - fc.bp[i].k = k[i]; + for (int i = 1; i < dp1; i++) { + fc.fc[i].multiplicity = multiplicity[i]; + fc.fc[i].cos_shift = cos_shift[i]; + fc.fc[i].sin_shift = sin_shift[i]; + fc.fc[i].k = k[i]; fc.weight[i] = weight[i]; } } @@ -965,27 +965,24 @@ void DihedralCharmmIntel::pack_force_const(ForceConst &fc, template void DihedralCharmmIntel::ForceConst::set_ntypes(const int npairtypes, - const int nbondtypes, + const int ndihderaltypes, Memory *memory) { + if (memory != nullptr) _memory = memory; if (npairtypes != _npairtypes) { - if (_npairtypes > 0) - _memory->destroy(ljp); + _memory->destroy(ljp); if (npairtypes > 0) - memory->create(ljp,npairtypes,npairtypes,"fc.ljp"); + _memory->create(ljp,npairtypes,npairtypes,"fc.ljp"); } - if (nbondtypes != _nbondtypes) { - if (_nbondtypes > 0) { - _memory->destroy(bp); - _memory->destroy(weight); - } + if (ndihderaltypes != _ndihderaltypes) { + _memory->destroy(fc); + _memory->destroy(weight); - if (nbondtypes > 0) { - _memory->create(bp,nbondtypes,"dihedralcharmmintel.bp"); - _memory->create(weight,nbondtypes,"dihedralcharmmintel.weight"); + if (ndihderaltypes > 0) { + _memory->create(fc,ndihderaltypes,"dihedralcharmmintel.fc"); + _memory->create(weight,ndihderaltypes,"dihedralcharmmintel.weight"); } } _npairtypes = npairtypes; - _nbondtypes = nbondtypes; - _memory = memory; + _ndihderaltypes = ndihderaltypes; } diff --git a/src/INTEL/dihedral_charmm_intel.h b/src/INTEL/dihedral_charmm_intel.h index 9de87826f7..a4f9109aa1 100644 --- a/src/INTEL/dihedral_charmm_intel.h +++ b/src/INTEL/dihedral_charmm_intel.h @@ -64,16 +64,16 @@ class DihedralCharmmIntel : public DihedralCharmm { } fc_packed3; fc_packed1 **ljp; - fc_packed3 *bp; + fc_packed3 *fc; flt_t *weight; - ForceConst() : _npairtypes(0), _nbondtypes(0) {} + ForceConst() : ljp(nullptr), fc(nullptr), _npairtypes(0), _ndihderaltypes(0) {} ~ForceConst() { set_ntypes(0, 0, nullptr); } - void set_ntypes(const int npairtypes, const int nbondtypes, Memory *memory); + void set_ntypes(const int npairtypes, const int ndihderaltypes, Memory *memory); private: - int _npairtypes, _nbondtypes; + int _npairtypes, _ndihderaltypes; Memory *_memory; }; ForceConst force_const_single; diff --git a/src/INTEL/dihedral_fourier_intel.cpp b/src/INTEL/dihedral_fourier_intel.cpp index e2b0098410..e916fb4612 100644 --- a/src/INTEL/dihedral_fourier_intel.cpp +++ b/src/INTEL/dihedral_fourier_intel.cpp @@ -225,10 +225,10 @@ void DihedralFourierIntel::eval(const int vflag, if (EFLAG) deng = (flt_t)0.0; for (int j = 0; j < nterms[type]; j++) { - const flt_t tcos_shift = fc.bp[j][type].cos_shift; - const flt_t tsin_shift = fc.bp[j][type].sin_shift; - const flt_t tk = fc.bp[j][type].k; - const int m = fc.bp[j][type].multiplicity; + const flt_t tcos_shift = fc.fc[j][type].cos_shift; + const flt_t tsin_shift = fc.fc[j][type].sin_shift; + const flt_t tk = fc.fc[j][type].k; + const int m = fc.fc[j][type].multiplicity; flt_t p = (flt_t)1.0; flt_t ddf1, df1; @@ -394,16 +394,16 @@ template void DihedralFourierIntel::pack_force_const(ForceConst &fc, IntelBuffers * /*buffers*/) { - const int bp1 = atom->ndihedraltypes + 1; - fc.set_ntypes(bp1, setflag, nterms, memory); + const int dp1 = atom->ndihedraltypes + 1; + fc.set_ntypes(dp1, setflag, nterms, memory); - for (int i = 1; i < bp1; i++) { + for (int i = 1; i < dp1; i++) { if (setflag[i]) { for (int j = 0; j < nterms[i]; j++) { - fc.bp[j][i].cos_shift = cos_shift[i][j]; - fc.bp[j][i].sin_shift = sin_shift[i][j]; - fc.bp[j][i].k = k[i][j]; - fc.bp[j][i].multiplicity = multiplicity[i][j]; + fc.fc[j][i].cos_shift = cos_shift[i][j]; + fc.fc[j][i].sin_shift = sin_shift[i][j]; + fc.fc[j][i].k = k[i][j]; + fc.fc[j][i].multiplicity = multiplicity[i][j]; } } } @@ -412,22 +412,20 @@ void DihedralFourierIntel::pack_force_const(ForceConst &fc, /* ---------------------------------------------------------------------- */ template -void DihedralFourierIntel::ForceConst::set_ntypes(const int nbondtypes, +void DihedralFourierIntel::ForceConst::set_ntypes(const int ndihedraltypes, int *setflag, int *nterms, Memory *memory) { - if (nbondtypes != _nbondtypes) { - if (_nbondtypes > 0) - _memory->destroy(bp); + if (memory != nullptr) _memory = memory; + if (ndihedraltypes != _ndihedraltypes) { + _memory->destroy(fc); - if (nbondtypes > 0) { + if (ndihedraltypes > 0) { _maxnterms = 1; - for (int i = 1; i <= nbondtypes; i++) + for (int i = 1; i < ndihedraltypes; i++) if (setflag[i]) _maxnterms = MAX(_maxnterms, nterms[i]); - - _memory->create(bp, _maxnterms, nbondtypes, "dihedralfourierintel.bp"); + _memory->create(fc, _maxnterms, ndihedraltypes, "dihedralfourierintel.fc"); } } - _nbondtypes = nbondtypes; - _memory = memory; + _ndihedraltypes = ndihedraltypes; } diff --git a/src/INTEL/dihedral_fourier_intel.h b/src/INTEL/dihedral_fourier_intel.h index 57412c65a8..36ad7dcd31 100644 --- a/src/INTEL/dihedral_fourier_intel.h +++ b/src/INTEL/dihedral_fourier_intel.h @@ -60,15 +60,15 @@ class DihedralFourierIntel : public DihedralFourier { int multiplicity; } fc_packed1; - fc_packed1 **bp; + fc_packed1 **fc; - ForceConst() : _nbondtypes(0) {} + ForceConst() : fc(nullptr), _ndihedraltypes(0) {} ~ForceConst() { set_ntypes(0, nullptr, nullptr, nullptr); } - void set_ntypes(const int nbondtypes, int *setflag, int *nterms, Memory *memory); + void set_ntypes(const int ndihedraltypes, int *setflag, int *nterms, Memory *memory); private: - int _nbondtypes, _maxnterms; + int _ndihedraltypes, _maxnterms; Memory *_memory; }; ForceConst force_const_single; diff --git a/src/INTEL/dihedral_harmonic_intel.cpp b/src/INTEL/dihedral_harmonic_intel.cpp index 0f55f72560..c4cb94ea83 100644 --- a/src/INTEL/dihedral_harmonic_intel.cpp +++ b/src/INTEL/dihedral_harmonic_intel.cpp @@ -220,10 +220,10 @@ void DihedralHarmonicIntel::eval(const int vflag, if (c > (flt_t)1.0) c = (flt_t)1.0; if (c < (flt_t)-1.0) c = (flt_t)-1.0; - const flt_t tcos_shift = fc.bp[type].cos_shift; - const flt_t tsin_shift = fc.bp[type].sin_shift; - const flt_t tk = fc.bp[type].k; - const int m = fc.bp[type].multiplicity; + const flt_t tcos_shift = fc.fc[type].cos_shift; + const flt_t tsin_shift = fc.fc[type].sin_shift; + const flt_t tk = fc.fc[type].k; + const int m = fc.fc[type].multiplicity; flt_t p = (flt_t)1.0; flt_t ddf1, df1; @@ -389,29 +389,28 @@ template void DihedralHarmonicIntel::pack_force_const(ForceConst &fc, IntelBuffers * /*buffers*/) { - const int bp1 = atom->ndihedraltypes + 1; - fc.set_ntypes(bp1,memory); + const int dp1 = atom->ndihedraltypes + 1; + fc.set_ntypes(dp1,memory); - for (int i = 1; i < bp1; i++) { - fc.bp[i].multiplicity = multiplicity[i]; - fc.bp[i].cos_shift = cos_shift[i]; - fc.bp[i].sin_shift = sin_shift[i]; - fc.bp[i].k = k[i]; + for (int i = 1; i < dp1; i++) { + fc.fc[i].multiplicity = multiplicity[i]; + fc.fc[i].cos_shift = cos_shift[i]; + fc.fc[i].sin_shift = sin_shift[i]; + fc.fc[i].k = k[i]; } } /* ---------------------------------------------------------------------- */ template -void DihedralHarmonicIntel::ForceConst::set_ntypes(const int nbondtypes, +void DihedralHarmonicIntel::ForceConst::set_ntypes(const int ndihderaltypes, Memory *memory) { - if (nbondtypes != _nbondtypes) { - if (_nbondtypes > 0) - _memory->destroy(bp); + if (memory != nullptr) _memory = memory; + if (ndihderaltypes != _ndihderaltypes) { + _memory->destroy(fc); - if (nbondtypes > 0) - _memory->create(bp,nbondtypes,"dihedralcharmmintel.bp"); + if (ndihderaltypes > 0) + _memory->create(fc,ndihderaltypes,"dihedralcharmmintel.fc"); } - _nbondtypes = nbondtypes; - _memory = memory; + _ndihderaltypes = ndihderaltypes; } diff --git a/src/INTEL/dihedral_harmonic_intel.h b/src/INTEL/dihedral_harmonic_intel.h index bd98ec6b61..406116f5a7 100644 --- a/src/INTEL/dihedral_harmonic_intel.h +++ b/src/INTEL/dihedral_harmonic_intel.h @@ -60,15 +60,15 @@ class DihedralHarmonicIntel : public DihedralHarmonic { int multiplicity; } fc_packed1; - fc_packed1 *bp; + fc_packed1 *fc; - ForceConst() : _nbondtypes(0) {} + ForceConst() : fc(nullptr), _ndihderaltypes(0) {} ~ForceConst() { set_ntypes(0, nullptr); } - void set_ntypes(const int nbondtypes, Memory *memory); + void set_ntypes(const int ndihderaltypes, Memory *memory); private: - int _nbondtypes; + int _ndihderaltypes; Memory *_memory; }; ForceConst force_const_single; diff --git a/src/INTEL/dihedral_opls_intel.cpp b/src/INTEL/dihedral_opls_intel.cpp index 46ae91ae5c..f8736d9c6b 100644 --- a/src/INTEL/dihedral_opls_intel.cpp +++ b/src/INTEL/dihedral_opls_intel.cpp @@ -264,14 +264,14 @@ void DihedralOPLSIntel::eval(const int vflag, const flt_t sin_4phim = (flt_t)2.0 * cos_2phi * sin_2phim; flt_t p, pd; - p = fc.bp[type].k1*((flt_t)1.0 + c) + - fc.bp[type].k2*((flt_t)1.0 - cos_2phi) + - fc.bp[type].k3*((flt_t)1.0 + cos_3phi) + - fc.bp[type].k4*((flt_t)1.0 - cos_4phi) ; - pd = fc.bp[type].k1 - - (flt_t)2.0 * fc.bp[type].k2 * sin_2phim + - (flt_t)3.0 * fc.bp[type].k3 * sin_3phim - - (flt_t)4.0 * fc.bp[type].k4 * sin_4phim; + p = fc.fc[type].k1*((flt_t)1.0 + c) + + fc.fc[type].k2*((flt_t)1.0 - cos_2phi) + + fc.fc[type].k3*((flt_t)1.0 + cos_3phi) + + fc.fc[type].k4*((flt_t)1.0 - cos_4phi) ; + pd = fc.fc[type].k1 - + (flt_t)2.0 * fc.fc[type].k2 * sin_2phim + + (flt_t)3.0 * fc.fc[type].k3 * sin_3phim - + (flt_t)4.0 * fc.fc[type].k4 * sin_4phim; flt_t edihed; if (EFLAG) edihed = p; @@ -409,29 +409,28 @@ template void DihedralOPLSIntel::pack_force_const(ForceConst &fc, IntelBuffers * /*buffers*/) { - const int bp1 = atom->ndihedraltypes + 1; - fc.set_ntypes(bp1,memory); + const int dp1 = atom->ndihedraltypes + 1; + fc.set_ntypes(dp1,memory); - for (int i = 1; i < bp1; i++) { - fc.bp[i].k1 = k1[i]; - fc.bp[i].k2 = k2[i]; - fc.bp[i].k3 = k3[i]; - fc.bp[i].k4 = k4[i]; + for (int i = 1; i < dp1; i++) { + fc.fc[i].k1 = k1[i]; + fc.fc[i].k2 = k2[i]; + fc.fc[i].k3 = k3[i]; + fc.fc[i].k4 = k4[i]; } } /* ---------------------------------------------------------------------- */ template -void DihedralOPLSIntel::ForceConst::set_ntypes(const int nbondtypes, +void DihedralOPLSIntel::ForceConst::set_ntypes(const int ndihderaltypes, Memory *memory) { - if (nbondtypes != _nbondtypes) { - if (_nbondtypes > 0) - _memory->destroy(bp); + if (memory != nullptr) _memory = memory; + if (ndihderaltypes != _ndihderaltypes) { + _memory->destroy(fc); - if (nbondtypes > 0) - _memory->create(bp,nbondtypes,"dihedralcharmmintel.bp"); + if (ndihderaltypes > 0) + _memory->create(fc,ndihderaltypes,"dihedralcharmmintel.fc"); } - _nbondtypes = nbondtypes; - _memory = memory; + _ndihderaltypes = ndihderaltypes; } diff --git a/src/INTEL/dihedral_opls_intel.h b/src/INTEL/dihedral_opls_intel.h index e11aae76f6..1be502739e 100644 --- a/src/INTEL/dihedral_opls_intel.h +++ b/src/INTEL/dihedral_opls_intel.h @@ -59,15 +59,15 @@ class DihedralOPLSIntel : public DihedralOPLS { flt_t k1, k2, k3, k4; } fc_packed1; - fc_packed1 *bp; + fc_packed1 *fc; - ForceConst() : _nbondtypes(0) {} + ForceConst() : fc(nullptr), _ndihderaltypes(0) {} ~ForceConst() { set_ntypes(0, nullptr); } - void set_ntypes(const int nbondtypes, Memory *memory); + void set_ntypes(const int ndihderaltypes, Memory *memory); private: - int _nbondtypes; + int _ndihderaltypes; Memory *_memory; }; ForceConst force_const_single; diff --git a/src/INTEL/improper_cvff_intel.cpp b/src/INTEL/improper_cvff_intel.cpp index 04eede6517..10cb4b72b5 100644 --- a/src/INTEL/improper_cvff_intel.cpp +++ b/src/INTEL/improper_cvff_intel.cpp @@ -426,10 +426,10 @@ template void ImproperCvffIntel::pack_force_const(ForceConst &fc, IntelBuffers * /*buffers*/) { - const int bp1 = atom->nimpropertypes + 1; - fc.set_ntypes(bp1,memory); + const int ip1 = atom->nimpropertypes + 1; + fc.set_ntypes(ip1,memory); - for (int i = 1; i < bp1; i++) { + for (int i = 1; i < ip1; i++) { fc.fc[i].k = k[i]; fc.fc[i].sign = sign[i]; fc.fc[i].multiplicity = multiplicity[i]; @@ -439,15 +439,14 @@ void ImproperCvffIntel::pack_force_const(ForceConst &fc, /* ---------------------------------------------------------------------- */ template -void ImproperCvffIntel::ForceConst::set_ntypes(const int nimproper, +void ImproperCvffIntel::ForceConst::set_ntypes(const int nimpropertypes, Memory *memory) { - if (nimproper != _nimpropertypes) { - if (_nimpropertypes > 0) - _memory->destroy(fc); + if (memory != nullptr) _memory = memory; + if (nimpropertypes != _nimpropertypes) { + _memory->destroy(fc); - if (nimproper > 0) - _memory->create(fc,nimproper,"improperharmonicintel.fc"); + if (nimpropertypes > 0) + _memory->create(fc,nimpropertypes,"improperharmonicintel.fc"); } - _nimpropertypes = nimproper; - _memory = memory; + _nimpropertypes = nimpropertypes; } diff --git a/src/INTEL/improper_cvff_intel.h b/src/INTEL/improper_cvff_intel.h index f09cc06a0d..dc09fdeb9b 100644 --- a/src/INTEL/improper_cvff_intel.h +++ b/src/INTEL/improper_cvff_intel.h @@ -62,7 +62,7 @@ class ImproperCvffIntel : public ImproperCvff { fc_packed1 *fc; - ForceConst() : _nimpropertypes(0) {} + ForceConst() : fc(nullptr), _nimpropertypes(0) {} ~ForceConst() { set_ntypes(0, nullptr); } void set_ntypes(const int nimpropertypes, Memory *memory); diff --git a/src/INTEL/improper_harmonic_intel.cpp b/src/INTEL/improper_harmonic_intel.cpp index beda76bc09..2173a4b351 100644 --- a/src/INTEL/improper_harmonic_intel.cpp +++ b/src/INTEL/improper_harmonic_intel.cpp @@ -379,10 +379,10 @@ template void ImproperHarmonicIntel::pack_force_const(ForceConst &fc, IntelBuffers * /*buffers*/) { - const int bp1 = atom->nimpropertypes + 1; - fc.set_ntypes(bp1,memory); + const int ip1 = atom->nimpropertypes + 1; + fc.set_ntypes(ip1,memory); - for (int i = 1; i < bp1; i++) { + for (int i = 1; i < ip1; i++) { fc.fc[i].k = k[i]; fc.fc[i].chi = chi[i]; } @@ -391,15 +391,14 @@ void ImproperHarmonicIntel::pack_force_const(ForceConst &fc, /* ---------------------------------------------------------------------- */ template -void ImproperHarmonicIntel::ForceConst::set_ntypes(const int nimproper, +void ImproperHarmonicIntel::ForceConst::set_ntypes(const int nimpropertypes, Memory *memory) { - if (nimproper != _nimpropertypes) { - if (_nimpropertypes > 0) - _memory->destroy(fc); + if (memory != nullptr) _memory = memory; + if (nimpropertypes != _nimpropertypes) { + _memory->destroy(fc); - if (nimproper > 0) - _memory->create(fc,nimproper,"improperharmonicintel.fc"); + if (nimpropertypes > 0) + _memory->create(fc,nimpropertypes,"improperharmonicintel.fc"); } - _nimpropertypes = nimproper; - _memory = memory; + _nimpropertypes = nimpropertypes; } diff --git a/src/INTEL/improper_harmonic_intel.h b/src/INTEL/improper_harmonic_intel.h index b8218614e1..07a38a5770 100644 --- a/src/INTEL/improper_harmonic_intel.h +++ b/src/INTEL/improper_harmonic_intel.h @@ -61,7 +61,7 @@ class ImproperHarmonicIntel : public ImproperHarmonic { fc_packed1 *fc; - ForceConst() : _nimpropertypes(0) {} + ForceConst() : fc(nullptr), _nimpropertypes(0) {} ~ForceConst() { set_ntypes(0, nullptr); } void set_ntypes(const int nimpropertypes, Memory *memory);