- Move t_block and t_blocka definitions to topology/.
- Move functions that operate only on these types from typedefs.[hc] to
the same place.
- Include the new block.h from all source files that reference the
functions.
- Clean up a few headers that were including types/block.h directly.
Most other code still depends on getting the type definitions
indirectly through typedefs.h, but that can be fixed during subsequent
changes.
Change-Id: I458e9cdc00a8d81665630f8123589b64d123790a
#include "mtop_util.h"
#include "gromacs/math/vec.h"
+#include "gromacs/topology/block.h"
#include "gromacs/topology/symtab.h"
#include "gromacs/utility/cstringutil.h"
#include "gromacs/utility/fatalerror.h"
#include "gromacs/utility/futil.h"
#include "macros.h"
-#include "gromacs/utility/cstringutil.h"
-#include "gromacs/commandline/pargs.h"
#include "gromacs/fileio/confio.h"
#include "typedefs.h"
#include "index.h"
-#include "gromacs/utility/smalloc.h"
#include "gromacs/math/vec.h"
#include "index.h"
+#include "gromacs/commandline/pargs.h"
+#include "gromacs/topology/block.h"
+#include "gromacs/utility/cstringutil.h"
#include "gromacs/utility/fatalerror.h"
+#include "gromacs/utility/smalloc.h"
#define MAXNAMES 30
#define NAME_LEN 30
}
}
-t_blocka *new_blocka(void)
-{
- t_blocka *block;
-
- snew(block, 1);
- snew(block->index, 1);
-
- return block;
-}
-
void write_index(const char *outf, t_blocka *b, char **gnames, gmx_bool bDuplicate, int natoms)
{
FILE *out;
#include "mtop_util.h"
#include "topsort.h"
+#include "gromacs/topology/block.h"
#include "gromacs/topology/symtab.h"
#include "gromacs/utility/fatalerror.h"
#include "gromacs/utility/smalloc.h"
#include "gromacs/math/vec.h"
#include "gromacs/pbcutil/pbc.h"
#include "gromacs/random/random.h"
+#include "gromacs/topology/block.h"
#include "gromacs/topology/symtab.h"
#include "gromacs/utility/smalloc.h"
return buf;
}
-void init_block(t_block *block)
-{
- int i;
-
- block->nr = 0;
- block->nalloc_index = 1;
- snew(block->index, block->nalloc_index);
- block->index[0] = 0;
-}
-
-void init_blocka(t_blocka *block)
-{
- int i;
-
- block->nr = 0;
- block->nra = 0;
- block->nalloc_index = 1;
- snew(block->index, block->nalloc_index);
- block->index[0] = 0;
- block->nalloc_a = 0;
- block->a = NULL;
-}
-
void init_atom(t_atoms *at)
{
int i;
snew(ir->simtempvals, 1);
}
-void stupid_fill_block(t_block *grp, int natom, gmx_bool bOneIndexGroup)
-{
- int i;
-
- if (bOneIndexGroup)
- {
- grp->nalloc_index = 2;
- snew(grp->index, grp->nalloc_index);
- grp->index[0] = 0;
- grp->index[1] = natom;
- grp->nr = 1;
- }
- else
- {
- grp->nalloc_index = natom+1;
- snew(grp->index, grp->nalloc_index);
- snew(grp->index, natom+1);
- for (i = 0; (i <= natom); i++)
- {
- grp->index[i] = i;
- }
- grp->nr = natom;
- }
-}
-
-void stupid_fill_blocka(t_blocka *grp, int natom)
-{
- int i;
-
- grp->nalloc_a = natom;
- snew(grp->a, grp->nalloc_a);
- for (i = 0; (i < natom); i++)
- {
- grp->a[i] = i;
- }
- grp->nra = natom;
-
- grp->nalloc_index = natom + 1;
- snew(grp->index, grp->nalloc_index);
- for (i = 0; (i <= natom); i++)
- {
- grp->index[i] = i;
- }
- grp->nr = natom;
-}
-
-void copy_blocka(const t_blocka *src, t_blocka *dest)
-{
- int i;
-
- dest->nr = src->nr;
- dest->nalloc_index = dest->nr + 1;
- snew(dest->index, dest->nalloc_index);
- for (i = 0; i < dest->nr+1; i++)
- {
- dest->index[i] = src->index[i];
- }
- dest->nra = src->nra;
- dest->nalloc_a = dest->nra + 1;
- snew(dest->a, dest->nalloc_a);
- for (i = 0; i < dest->nra+1; i++)
- {
- dest->a[i] = src->a[i];
- }
-}
-
-void done_block(t_block *block)
-{
- block->nr = 0;
- sfree(block->index);
- block->nalloc_index = 0;
-}
-
-void done_blocka(t_blocka *block)
-{
- block->nr = 0;
- block->nra = 0;
- sfree(block->index);
- sfree(block->a);
- block->index = NULL;
- block->a = NULL;
- block->nalloc_index = 0;
- block->nalloc_a = 0;
-}
-
void done_atom (t_atoms *at)
{
at->nr = 0;
#include "chargegroup.h"
#include "gromacs/pbcutil/pbc.h"
+#include "gromacs/topology/block.h"
#include "gromacs/utility/smalloc.h"
static real box_margin;
#include <string.h>
#include "typedefs.h"
#include "gromacs/fileio/pdbio.h"
-#include "gromacs/utility/smalloc.h"
#include "gromacs/math/vec.h"
#include "gromacs/math/units.h"
#include "toputil.h"
#include "gromacs/utility/cstringutil.h"
#include "macros.h"
+#include "gromacs/topology/block.h"
#include "gromacs/utility/fatalerror.h"
+#include "gromacs/utility/smalloc.h"
static int in_strings(char *key, int nstr, const char **str)
{
#include "gromacs/commandline/pargs.h"
#include "gromacs/fileio/strdb.h"
+#include "gromacs/topology/block.h"
#include "gromacs/topology/symtab.h"
#include "gromacs/utility/smalloc.h"
#include "gromacs/utility/fatalerror.h"
#include "inputrec.h"
#include "calc_verletbuf.h"
+#include "gromacs/topology/block.h"
#include "gromacs/topology/symtab.h"
#include "gromacs/utility/fatalerror.h"
#include "gromacs/utility/smalloc.h"
#include "macros.h"
#include "names.h"
#include "gromacs/utility/cstringutil.h"
+#include "gromacs/topology/block.h"
#include "gromacs/topology/symtab.h"
#include "gromacs/utility/fatalerror.h"
#include "warninp.h"
#include "toputil.h"
#include "gpp_atomtype.h"
+#include "gromacs/topology/block.h"
#include "gromacs/topology/symtab.h"
#include "gromacs/utility/fatalerror.h"
#include "gromacs/utility/smalloc.h"
#include <stdio.h>
#include "types/atoms.h"
-#include "types/block.h"
#ifdef __cplusplus
extern "C" {
#endif
+struct t_blocka;
+
void check_index(char *gname, int n, atom_id index[],
char *traj, int natoms);
/* Checks if any index is smaller than zero or larger than natoms,
* and traj (if traj=NULL, "the trajectory" is used).
*/
-t_blocka *init_index(const char *gfile, char ***grpname);
+struct t_blocka *init_index(const char *gfile, char ***grpname);
/* Lower level routine than the next */
void rd_index(const char *statfile, int ngrps, int isize[],
*/
typedef struct {
- int maxframe;
- char **grpname;
- t_blocka *clust;
- atom_id *inv_clust;
+ int maxframe;
+ char **grpname;
+ struct t_blocka *clust;
+ atom_id *inv_clust;
} t_cluster_ndx;
t_cluster_ndx *cluster_index(FILE *fplog, const char *ndx);
-t_blocka *new_blocka(void);
-/* allocate new block */
-
-void write_index(const char *outf, t_blocka *b, char **gnames, gmx_bool bDuplicate, int natoms);
+void write_index(const char *outf, struct t_blocka *b, char **gnames, gmx_bool bDuplicate, int natoms);
/* Writes index blocks to outf (writes an indexfile) */
-void add_grp(t_blocka *b, char ***gnames, int nra, atom_id a[], const char *name);
+void add_grp(struct t_blocka *b, char ***gnames, int nra, atom_id a[], const char *name);
/* Ads group a with name name to block b and namelist gnames */
-void analyse(t_atoms *atoms, t_blocka *gb, char ***gn,
+void analyse(t_atoms *atoms, struct t_blocka *gb, char ***gn,
gmx_bool bASK, gmx_bool bVerb);
/* Makes index groups gb with names gn for atoms in atoms.
* bASK=FALSE gives default groups.
#include "types/simple.h"
#include "types/enums.h"
-#include "types/block.h"
#include "types/idef.h"
#include "types/atoms.h"
#include "../fileio/trx.h"
/* Functions to initiate and delete structures *
* These functions are defined in gmxlib/typedefs.c
*/
-void init_block(t_block *block);
-void init_blocka(t_blocka *block);
void init_atom (t_atoms *at);
void init_mtop(gmx_mtop_t *mtop);
void init_top(t_topology *top);
void init_df_history(df_history_t *dfhist, int nlambda);
void done_df_history(df_history_t *dfhist);
void copy_df_history(df_history_t * df_dest, df_history_t *df_source);
-
-void copy_blocka(const t_blocka *src, t_blocka *dest);
-
-void done_block(t_block *block);
-void done_blocka(t_blocka *block);
void done_atom (t_atoms *at);
void done_moltype(gmx_moltype_t *molt);
void done_molblock(gmx_molblock_t *molb);
void preserve_box_shape(t_inputrec *ir, matrix box_rel, matrix b);
/* Preserve the box shape, b can be box or boxv */
-void stupid_fill_block(t_block *grp, int natom, gmx_bool bOneIndexGroup);
-/* Fill a block structure with numbers identical to the index
- * (0, 1, 2, .. natom-1)
- * If bOneIndexGroup, then all atoms are lumped in one index group,
- * otherwise there is one atom per index entry
- */
-
-void stupid_fill_blocka(t_blocka *grp, int natom);
-/* Fill a block structure with numbers identical to the index
- * (0, 1, 2, .. natom-1)
- * There is one atom per index entry
- */
-
void init_t_atoms(t_atoms *atoms, int natoms, gmx_bool bPdbinfo);
/* allocate memory for the arrays, set nr to natoms and nres to 0
* set pdbinfo to NULL or allocate memory for it */
#include "atoms.h"
#include "idef.h"
-#include "block.h"
#include "simple.h"
+#include "../../topology/block.h"
#include "../../topology/symtab.h"
#ifdef __cplusplus
#include "gmx_omp_nthreads.h"
#include "gromacs/fileio/gmxfio.h"
+#include "gromacs/topology/block.h"
#include "gromacs/utility/fatalerror.h"
#include "gromacs/utility/gmxomp.h"
#include "gromacs/utility/smalloc.h"
#include "gromacs/pulling/pull.h"
#include "gromacs/pbcutil/pbc.h"
+#include "gromacs/topology/block.h"
#include "gromacs/utility/fatalerror.h"
typedef struct gmx_constr {
#include <vector>
#include "gromacs/legacyheaders/index.h"
-#include "gromacs/legacyheaders/typedefs.h"
+#include "gromacs/topology/block.h"
#include "gromacs/utility/gmxassert.h"
#include "gromacs/utility/smalloc.h"
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2013, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014, 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 <gtest/gtest.h>
-#include "gromacs/legacyheaders/typedefs.h"
-
#include "gromacs/selection/indexutil.h"
+#include "gromacs/topology/block.h"
#include "testutils/refdata.h"
#include "gromacs/fileio/enxio.h"
#include "gromacs/fileio/tpxio.h"
#include "gromacs/fileio/trxio.h"
+#include "gromacs/topology/block.h"
#include "compare.h"
set(LIBGROMACS_SOURCES ${LIBGROMACS_SOURCES} ${TOPOLOGY_SOURCES} PARENT_SCOPE)
set(TOPOLOGY_PUBLIC_HEADERS
+ block.h
symtab.h)
gmx_install_headers(topology ${TOPOLOGY_PUBLIC_HEADERS})
--- /dev/null
+/*
+ * This file is part of the GROMACS molecular simulation package.
+ *
+ * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
+ * Copyright (c) 2001-2004, The GROMACS development team.
+ * Copyright (c) 2013,2014, 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.
+ *
+ * GROMACS is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1
+ * of the License, or (at your option) any later version.
+ *
+ * GROMACS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GROMACS; if not, see
+ * http://www.gnu.org/licenses, or write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * If you want to redistribute modifications to GROMACS, please
+ * consider that scientific software is very special. Version
+ * control is crucial - bugs must be traceable. We will be happy to
+ * consider code for inclusion in the official distribution, but
+ * derived work must not be called official GROMACS. Details are found
+ * in the README & COPYING files - if they are missing, get the
+ * official version at http://www.gromacs.org.
+ *
+ * To help us fund GROMACS development, we humbly ask that you cite
+ * the research papers on the package. Check out http://www.gromacs.org.
+ */
+#include "gromacs/topology/block.h"
+
+#include "gromacs/utility/smalloc.h"
+
+void init_block(t_block *block)
+{
+ block->nr = 0;
+ block->nalloc_index = 1;
+ snew(block->index, block->nalloc_index);
+ block->index[0] = 0;
+}
+
+void init_blocka(t_blocka *block)
+{
+ block->nr = 0;
+ block->nra = 0;
+ block->nalloc_index = 1;
+ snew(block->index, block->nalloc_index);
+ block->index[0] = 0;
+ block->nalloc_a = 0;
+ block->a = NULL;
+}
+
+t_blocka *new_blocka(void)
+{
+ t_blocka *block;
+
+ snew(block, 1);
+ snew(block->index, 1);
+
+ return block;
+}
+
+void done_block(t_block *block)
+{
+ block->nr = 0;
+ sfree(block->index);
+ block->nalloc_index = 0;
+}
+
+void done_blocka(t_blocka *block)
+{
+ block->nr = 0;
+ block->nra = 0;
+ sfree(block->index);
+ sfree(block->a);
+ block->index = NULL;
+ block->a = NULL;
+ block->nalloc_index = 0;
+ block->nalloc_a = 0;
+}
+
+void stupid_fill_block(t_block *grp, int natom, gmx_bool bOneIndexGroup)
+{
+ if (bOneIndexGroup)
+ {
+ grp->nalloc_index = 2;
+ snew(grp->index, grp->nalloc_index);
+ grp->index[0] = 0;
+ grp->index[1] = natom;
+ grp->nr = 1;
+ }
+ else
+ {
+ grp->nalloc_index = natom+1;
+ snew(grp->index, grp->nalloc_index);
+ snew(grp->index, natom+1);
+ for (int i = 0; i <= natom; ++i)
+ {
+ grp->index[i] = i;
+ }
+ grp->nr = natom;
+ }
+}
+
+void stupid_fill_blocka(t_blocka *grp, int natom)
+{
+ grp->nalloc_a = natom;
+ snew(grp->a, grp->nalloc_a);
+ for (int i = 0; i < natom; ++i)
+ {
+ grp->a[i] = i;
+ }
+ grp->nra = natom;
+
+ grp->nalloc_index = natom + 1;
+ snew(grp->index, grp->nalloc_index);
+ for (int i = 0; i <= natom; ++i)
+ {
+ grp->index[i] = i;
+ }
+ grp->nr = natom;
+}
+
+void copy_blocka(const t_blocka *src, t_blocka *dest)
+{
+ dest->nr = src->nr;
+ dest->nalloc_index = dest->nr + 1;
+ snew(dest->index, dest->nalloc_index);
+ for (int i = 0; i < dest->nr+1; ++i)
+ {
+ dest->index[i] = src->index[i];
+ }
+ dest->nra = src->nra;
+ dest->nalloc_a = dest->nra + 1;
+ snew(dest->a, dest->nalloc_a);
+ for (int i = 0; i < dest->nra+1; ++i)
+ {
+ dest->a[i] = src->a[i];
+ }
+}
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2010, by the GROMACS development team, led by
+ * Copyright (c) 2010,2014, 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.
* To help us fund GROMACS development, we humbly ask that you cite
* the research papers on the package. Check out http://www.gromacs.org.
*/
-#ifndef _block_h
-#define _block_h
+#ifndef GMX_TOPOLOGY_BLOCK_H
+#define GMX_TOPOLOGY_BLOCK_H
-
-#include "idef.h"
+#include "../legacyheaders/types/simple.h"
#ifdef __cplusplus
extern "C" {
This makes the mapping from atoms to molecules O(Nmolecules) instead
of O(Natoms) in size. */
-typedef struct {
- int nr; /* The number of blocks */
+typedef struct t_block
+{
+ int nr; /* The number of blocks */
atom_id *index; /* Array of indices (dim: nr+1) */
- int nalloc_index; /* The allocation size for index */
+ int nalloc_index; /* The allocation size for index */
} t_block;
-typedef struct {
- int nr; /* The number of blocks */
- atom_id *index; /* Array of indices in a (dim: nr+1) */
- int nra; /* The number of atoms */
+typedef struct t_blocka
+{
+ int nr; /* The number of blocks */
+ atom_id *index; /* Array of indices in a (dim: nr+1) */
+ int nra; /* The number of atoms */
atom_id *a; /* Array of atom numbers in each group */
- /* (dim: nra) */
- /* Block i (0<=i<nr) runs from */
+ /* (dim: nra) */
+ /* Block i (0<=i<nr) runs from */
/* index[i] to index[i+1]-1. There will */
- /* allways be an extra entry in index */
- /* to terminate the table */
+ /* allways be an extra entry in index */
+ /* to terminate the table */
int nalloc_index; /* The allocation size for index */
int nalloc_a; /* The allocation size for a */
} t_blocka;
+void init_block(t_block *block);
+void init_blocka(t_blocka *block);
+t_blocka *new_blocka(void);
+/* allocate new block */
+
+void done_block(t_block *block);
+void done_blocka(t_blocka *block);
+
+void copy_blocka(const t_blocka *src, t_blocka *dest);
+
+void stupid_fill_block(t_block *grp, int natom, gmx_bool bOneIndexGroup);
+/* Fill a block structure with numbers identical to the index
+ * (0, 1, 2, .. natom-1)
+ * If bOneIndexGroup, then all atoms are lumped in one index group,
+ * otherwise there is one atom per index entry
+ */
+
+void stupid_fill_blocka(t_blocka *grp, int natom);
+/* Fill a block structure with numbers identical to the index
+ * (0, 1, 2, .. natom-1)
+ * There is one atom per index entry
+ */
#ifdef __cplusplus
}