Commit 78715216 authored by Jens Wehner's avatar Jens Wehner

clean up conversion and includes

parent d38ca8a7
Pipeline #94698341 failed with stages
in 10 minutes and 50 seconds
......@@ -35,12 +35,10 @@
// by gmx
#undef bool
using namespace std;
namespace votca {
namespace csg {
bool GMXTopologyReader::ReadTopology(string file, Topology &top) {
bool GMXTopologyReader::ReadTopology(std::string file, Topology &top) {
gmx_mtop_t mtop;
int natoms;
......@@ -64,7 +62,7 @@ bool GMXTopologyReader::ReadTopology(string file, Topology &top) {
for (size_t iblock = 0; iblock < nmolblock; ++iblock) {
gmx_moltype_t *mol = &(mtop.moltype[mtop.molblock[iblock].type]);
string molname = *(mol->name);
std::string molname = *(mol->name);
Index res_offset = top.ResidueCount();
......@@ -86,7 +84,7 @@ bool GMXTopologyReader::ReadTopology(string file, Topology &top) {
for (size_t iatom = 0; iatom < natoms_mol; iatom++) {
t_atom *a = &(atoms->atom[iatom]);
string bead_type = *(atoms->atomtype[iatom]);
std::string bead_type = *(atoms->atomtype[iatom]);
if (!top.BeadTypeExist(bead_type)) {
top.RegisterBeadType(bead_type);
}
......@@ -94,7 +92,7 @@ bool GMXTopologyReader::ReadTopology(string file, Topology &top) {
top.CreateBead(Bead::spherical, *(atoms->atomname[iatom]),
bead_type, a->resind + res_offset, a->m, a->q);
stringstream nm;
std::stringstream nm;
nm << bead->getResnr() + 1 - res_offset << ":"
<< top.getResidue(bead->getResnr())->getName() << ":"
<< bead->getName();
......@@ -106,7 +104,7 @@ bool GMXTopologyReader::ReadTopology(string file, Topology &top) {
// read exclusions
t_blocka *excl = &(mol->excls);
// insert exclusions
list<Bead *> excl_list;
std::list<Bead *> excl_list;
for (Index k = excl->index[iatom]; k < excl->index[iatom + 1]; k++) {
excl_list.push_back(top.getBead(excl->a[k] + ifirstatom));
}
......
......@@ -15,8 +15,8 @@
*
*/
#ifndef _gmxtopologyreader_H
#define _gmxtopologyreader_H
#ifndef _VOTCA_CSG_GMXTOPOLOGYREADER_H
#define _VOTCA_CSG_GMXTOPOLOGYREADER_H
#include <string>
#include <votca/csg/topologyreader.h>
......@@ -44,4 +44,4 @@ class GMXTopologyReader : public TopologyReader {
} // namespace csg
} // namespace votca
#endif /* _gmxtopologyreader_H */
#endif /* _VOTCA_CSG_GMXTOPOLOGYREADER_H */
......@@ -24,9 +24,7 @@
namespace votca {
namespace csg {
using namespace std;
bool GMXTrajectoryReader::Open(const string &file) {
bool GMXTrajectoryReader::Open(const std::string &file) {
_filename = file;
return true;
}
......@@ -38,7 +36,7 @@ bool GMXTrajectoryReader::FirstFrame(Topology &conf) {
output_env_init(&oenv, gmx::getProgramContext(), time_ps, FALSE, exvgNONE, 0);
if (!read_first_frame(oenv, &_gmx_status, (char *)_filename.c_str(),
&_gmx_frame, TRX_READ_X | TRX_READ_V | TRX_READ_F)) {
throw std::runtime_error(string("cannot open ") + _filename);
throw std::runtime_error(std::string("cannot open ") + _filename);
}
output_env_done(oenv);
......@@ -51,7 +49,7 @@ bool GMXTrajectoryReader::FirstFrame(Topology &conf) {
conf.setBox(m);
conf.setTime(_gmx_frame.time);
conf.setStep(_gmx_frame.step);
cout << endl;
std::cout << std::endl;
if (_gmx_frame.natoms != (Index)conf.Beads().size()) {
throw std::runtime_error(
......
......@@ -15,8 +15,8 @@
*
*/
#ifndef _gmxtrajectoryreader_H
#define _gmxtrajectoryreader_H
#ifndef _VOTCA_CSG_GMXTRAJECTORYREADER_H
#define _VOTCA_CSG_GMXTRAJECTORYREADER_H
#ifndef HAVE_NO_CONFIG
#include <votca_config.h>
......@@ -35,7 +35,6 @@
namespace votca {
namespace csg {
namespace TOOLS = votca::tools;
/**
\brief class for reading gromacs trajectory files
......@@ -43,6 +42,7 @@ namespace TOOLS = votca::tools;
trajectory reading function of gromacs
*/
class GMXTrajectoryReader : public TrajectoryReader {
public:
GMXTrajectoryReader() = default;
......@@ -68,4 +68,4 @@ class GMXTrajectoryReader : public TrajectoryReader {
} // namespace csg
} // namespace votca
#endif /* _gmxtrajectoryreader_H */
#endif /* _VOTCA_CSG_GMXTRAJECTORYREADER_H */
......@@ -16,14 +16,17 @@
*/
#include "gmxtrajectorywriter.h"
#include <gromacs/fileio/trxio.h>
#include <gromacs/trajectory/trajectoryframe.h>
#include <string>
// this one is needed because of bool is defined in one of the headers included
// by gmx
#undef bool
namespace votca {
namespace csg {
using namespace std;
void GMXTrajectoryWriter::Open(string file, bool) {
void GMXTrajectoryWriter::Open(std::string file, bool) {
_file = open_trx((char *)file.c_str(), "w");
}
......@@ -40,7 +43,7 @@ void GMXTrajectoryWriter::Write(Topology *conf) {
frame.natoms = (int)N;
frame.bTime = true;
frame.time = conf->getTime();
frame.time = real(conf->getTime());
frame.bStep = true;
frame.step = conf->getStep();
frame.x = x;
......@@ -54,15 +57,15 @@ void GMXTrajectoryWriter::Write(Topology *conf) {
for (Index i = 0; i < 3; i++) {
for (Index j = 0; j < 3; j++) {
frame.box[j][i] = box(i, j);
frame.box[j][i] = real(box(i, j));
}
}
for (Index i = 0; i < N; ++i) {
Eigen::Vector3d pos = conf->getBead(i)->getPos();
x[i][0] = pos.x();
x[i][1] = pos.y();
x[i][2] = pos.z();
x[i][0] = real(pos.x());
x[i][1] = real(pos.y());
x[i][2] = real(pos.z());
}
if (frame.bV) {
......@@ -70,9 +73,9 @@ void GMXTrajectoryWriter::Write(Topology *conf) {
for (Index i = 0; i < N; ++i) {
frame.v = v;
Eigen::Vector3d vel = conf->getBead(i)->getVel();
v[i][0] = vel.x();
v[i][1] = vel.y();
v[i][2] = vel.z();
v[i][0] = real(vel.x());
v[i][1] = real(vel.y());
v[i][2] = real(vel.z());
}
}
if (frame.bF) {
......@@ -80,9 +83,9 @@ void GMXTrajectoryWriter::Write(Topology *conf) {
for (Index i = 0; i < N; ++i) {
frame.f = f;
Eigen::Vector3d force = conf->getBead(i)->getF();
f[i][0] = force.x();
f[i][1] = force.y();
f[i][2] = force.z();
f[i][0] = real(force.x());
f[i][1] = real(force.y());
f[i][2] = real(force.z());
}
}
......
......@@ -15,8 +15,8 @@
*
*/
#ifndef _GMXTRAJECTORYWRITER_H
#define _GMXTRAJECTORYWRITER_H
#ifndef _VOTCA_CSG_GMXTRAJECTORYWRITER_H
#define _VOTCA_CSG_GMXTRAJECTORYWRITER_H
#ifndef HAVE_NO_CONFIG
#include <votca_config.h>
......@@ -25,12 +25,7 @@
#include <votca/csg/topology.h>
#include <votca/csg/trajectorywriter.h>
#include <gromacs/fileio/trxio.h>
#include <gromacs/trajectory/trajectoryframe.h>
// this one is needed because of bool is defined in one of the headers included
// by gmx
#undef bool
struct t_trxstatus;
namespace votca {
namespace csg {
......@@ -49,4 +44,4 @@ class GMXTrajectoryWriter : public TrajectoryWriter {
} // namespace csg
} // namespace votca
#endif /* _GMXTRAJECTORYWRITER_H */
#endif /* _VOTCA_CSG_GMXTRAJECTORYWRITER_H */
......@@ -80,8 +80,10 @@ void GROWriter::Write(Topology *conf) {
}
l = pr + 5;
if (box(0, 1) || box(0, 2) || box(1, 0) || box(1, 2) || box(2, 0) ||
box(2, 1)) {
Eigen::Matrix3d box_offdiag = box;
box_offdiag.diagonal().array() = 0.0;
if (box_offdiag.isApproxToConstant(0, 1e-9)) {
sprintf(format,
"%%%ld.%ldf%%%ld.%ldf%%%ld.%ldf"
"%%%ld.%ldf%%%ld.%ldf%%%ld.%ldf%%%ld.%ldf%%%ld.%ldf%%%ld.%ldf\n",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment