Instead of returning a raw pointer, make_tables now returns a unique_ptr.
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013-2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2013-2019,2020,2021, 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/mdtypes/interaction_const.h"
#include "gromacs/mdtypes/md_enums.h"
#include "gromacs/mdtypes/multipletimestepping.h"
+#include "gromacs/mdtypes/nblist.h"
#include "gromacs/nbnxm/nbnxm.h"
#include "gromacs/pbcutil/ishift.h"
#include "gromacs/pbcutil/pbc.h"
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2008, The GROMACS development team.
* Copyright (c) 2013,2014,2015,2016,2017 by the GROMACS development team.
- * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,2020,2021, 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.
fprintf(fplog, "Reading user tables for %d energy groups with %d walls\n", negp_pp, ir->nwall);
}
- snew(fr->wall_tab, ir->nwall);
+ fr->wall_tab.resize(ir->nwall);
for (int w = 0; w < ir->nwall; w++)
{
- snew(fr->wall_tab[w], negp_pp);
+ fr->wall_tab[w].resize(negp_pp);
for (int egp = 0; egp < negp_pp; egp++)
{
/* If the energy group pair is excluded, we don't need a table */
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
* Copyright (c) 2013,2014,2015,2016,2017 by the GROMACS development team.
- * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,2020,2021, 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.
gmx_bool bcoultab = FALSE;
gmx_bool bvdwtab = FALSE;
- t_forcetable* pairsTable = nullptr; /* for 1-4 interactions, [pairs] and [pairs_nb] */
+ std::unique_ptr<t_forcetable> pairsTable; /* for 1-4 interactions, [pairs] and [pairs_nb] */
/* Free energy */
int efep = 0;
std::unique_ptr<nonbonded_verlet_t> nbv;
/* The wall tables (if used) */
- int nwall = 0;
- t_forcetable*** wall_tab = nullptr;
+ int nwall = 0;
+ std::vector<std::vector<std::unique_ptr<t_forcetable>>> wall_tab;
/* The number of atoms participating in do_force_lowlevel */
int natoms_force = 0;
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2012,2014,2015,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2012,2014,2015,2019,2020,2021, 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.
{
t_forcetable(enum gmx_table_interaction interaction, enum gmx_table_format format);
+ ~t_forcetable();
+
enum gmx_table_interaction interaction; /* Types of interactions stored in this table */
enum gmx_table_format format; /* Interpolation type and data format */
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
* Copyright (c) 2013,2014,2015,2016,2017 by the GROMACS development team.
- * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,2020,2021, 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.
}
}
-t_forcetable* make_tables(FILE* out, const interaction_const_t* ic, const char* fn, real rtab, int flags)
+std::unique_ptr<t_forcetable>
+make_tables(FILE* fp, const interaction_const_t* ic, const char* fn, real rtab, int flags)
{
t_tabledata* td;
gmx_bool b14only, useUserTable;
int nx0, tabsel[etiNR];
real scalefactor;
- t_forcetable* table = new t_forcetable(GMX_TABLE_INTERACTION_ELEC_VDWREP_VDWDISP,
- GMX_TABLE_FORMAT_CUBICSPLINE_YFGH);
+ auto table = std::make_unique<t_forcetable>(GMX_TABLE_INTERACTION_ELEC_VDWREP_VDWDISP,
+ GMX_TABLE_FORMAT_CUBICSPLINE_YFGH);
b14only = ((flags & GMX_MAKETABLES_14ONLY) != 0);
}
if (useUserTable)
{
- read_tables(out, fn, etiNR, 0, td);
+ read_tables(fp, fn, etiNR, 0, td);
if (rtab == 0 || (flags & GMX_MAKETABLES_14ONLY))
{
table->n = td[0].nx;
init_table(table->n, nx0, scale, &(td[k]), !useUserTable);
fill_table(&(td[k]), tabsel[k], ic, b14only);
- if (out)
+ if (fp)
{
- fprintf(out,
+ fprintf(fp,
"Generated table with %d data points for %s%s.\n"
"Tabscale = %g points/nm\n",
td[k].nx,
GMX_RELEASE_ASSERT(ic->vdwtype != evdwUSER || tabfn,
"With VdW user tables we need a table file name");
- t_forcetable* fullTable = make_tables(fp, ic, tabfn, rtab, 0);
+ std::unique_ptr<t_forcetable> fullTable = make_tables(fp, ic, tabfn, rtab, 0);
/* Copy the contents of the table to one that has just dispersion
* and repulsion, to improve cache performance. We want the table
* data to be aligned to 32-byte boundaries.
dispersionCorrectionTable->data[8 * i + j] = fullTable->data[12 * i + 4 + j];
}
}
- delete fullTable;
return dispersionCorrectionTable;
}
stride(0)
{
}
+
+t_forcetable::~t_forcetable() = default;
* This file is part of the GROMACS molecular simulation package.
*
* Copyright (c) 2012,2014,2015,2016,2017 by the GROMACS development team.
- * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,2020,2021, 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.
*
* \return Pointer to inner loop table structure
*/
-t_forcetable* make_tables(FILE* fp, const interaction_const_t* ic, const char* fn, real rtab, int flags);
+std::unique_ptr<t_forcetable>
+make_tables(FILE* fp, const interaction_const_t* ic, const char* fn, real rtab, int flags);
/*! \brief Return a table for bonded interactions,
*