/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2013, by the GROMACS development team, led by
- * David van der Spoel, Berk Hess, Erik Lindahl, and including many
- * others, as listed in the AUTHORS file in the top-level source
- * directory and at http://www.gromacs.org.
+ * 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
* \author Teemu Murtola <teemu.murtola@gmail.com>
* \ingroup module_selection
*/
+#include "gmxpre.h"
+
#include "toputils.h"
#include <cstring>
-#include "gromacs/legacyheaders/smalloc.h"
-#include "gromacs/legacyheaders/statutil.h"
-#include "gromacs/legacyheaders/tpxio.h"
-#include "gromacs/legacyheaders/vec.h"
-
+#include "gromacs/fileio/tpxio.h"
+#include "gromacs/fileio/trx.h"
+#include "gromacs/fileio/trxio.h"
+#include "gromacs/math/vec.h"
+#include "gromacs/topology/atoms.h"
+#include "gromacs/topology/topology.h"
#include "gromacs/utility/gmxassert.h"
+#include "gromacs/utility/smalloc.h"
#include "testutils/testfilemanager.h"
if (frame_ != NULL)
{
sfree(frame_->x);
+ sfree(frame_->v);
+ sfree(frame_->f);
sfree(frame_);
}
}
}
}
+void TopologyManager::requestVelocities()
+{
+ GMX_RELEASE_ASSERT(frame_ != NULL,
+ "Velocities requested before requesting a frame");
+ frame_->bV = TRUE;
+ if (frame_->natoms > 0)
+ {
+ snew(frame_->v, frame_->natoms);
+ }
+}
+
+void TopologyManager::requestForces()
+{
+ GMX_RELEASE_ASSERT(frame_ != NULL,
+ "Forces requested before requesting a frame");
+ frame_->bF = TRUE;
+ if (frame_->natoms > 0)
+ {
+ snew(frame_->f, frame_->natoms);
+ }
+}
+
void TopologyManager::loadTopology(const char *filename)
{
char title[STRLEN];
sfree(xtop);
}
+void TopologyManager::initAtoms(int count)
+{
+ GMX_RELEASE_ASSERT(top_ == NULL, "Topology initialized more than once");
+ snew(top_, 1);
+ init_t_atoms(&top_->atoms, count, FALSE);
+ for (int i = 0; i < count; ++i)
+ {
+ top_->atoms.atom[i].m = (i % 3 == 0 ? 2.0 : 1.0);
+ }
+ if (frame_ != NULL)
+ {
+ frame_->flags = TRX_NEED_X;
+ frame_->natoms = count;
+ frame_->bX = TRUE;
+ snew(frame_->x, count);
+ if (frame_->bV)
+ {
+ snew(frame_->v, count);
+ }
+ if (frame_->bF)
+ {
+ snew(frame_->f, count);
+ }
+ }
+}
+
+void TopologyManager::initAtomTypes(int count, const char *const types[])
+{
+ GMX_RELEASE_ASSERT(top_ != NULL, "Topology not initialized");
+ atomtypes_.reserve(count);
+ for (int i = 0; i < count; ++i)
+ {
+ atomtypes_.push_back(gmx_strdup(types[i]));
+ }
+ snew(top_->atoms.atomtype, top_->atoms.nr);
+ for (int i = 0, j = 0; i < top_->atoms.nr; ++i, ++j)
+ {
+ if (j == count)
+ {
+ j = 0;
+ }
+ top_->atoms.atomtype[i] = &atomtypes_[j];
+ }
+}
+
+void TopologyManager::initUniformResidues(int residueSize)
+{
+ GMX_RELEASE_ASSERT(top_ != NULL, "Topology not initialized");
+ int residueIndex = -1;
+ for (int i = 0; i < top_->atoms.nr; ++i)
+ {
+ if (i % residueSize == 0)
+ {
+ ++residueIndex;
+ }
+ top_->atoms.atom[i].resind = residueIndex;
+ }
+}
+
+void TopologyManager::initUniformMolecules(int moleculeSize)
+{
+ GMX_RELEASE_ASSERT(top_ != NULL, "Topology not initialized");
+ int index = 0;
+ top_->mols.nalloc_index = (top_->atoms.nr + moleculeSize - 1) / moleculeSize + 1;
+ snew(top_->mols.index, top_->mols.nalloc_index);
+ top_->mols.nr = 0;
+ while (index < top_->atoms.nr)
+ {
+ top_->mols.index[top_->mols.nr] = index;
+ ++top_->mols.nr;
+ index += moleculeSize;
+ }
+ top_->mols.index[top_->mols.nr] = top_->atoms.nr;
+}
+
} // namespace test
} // namespace gmx