Skip to content
This repository has been archived by the owner on Sep 27, 2021. It is now read-only.

Commit

Permalink
Merge pull request #486 from votca/piece-wise-remove-topology-item
Browse files Browse the repository at this point in the history
Piece wise remove topology item
  • Loading branch information
junghans authored Dec 24, 2019
2 parents f7903ee + 56d5b2e commit 0c458e9
Show file tree
Hide file tree
Showing 24 changed files with 197 additions and 212 deletions.
8 changes: 1 addition & 7 deletions include/votca/csg/basebead.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@
* limitations under the License.
*
*/
#pragma once
#ifndef VOTCA_CSG_BASEBEAD_H
#define VOTCA_CSG_BASEBEAD_H
#pragma once

#include "topologyitem.h"
#include <assert.h>
#include <memory>
#include <votca/tools/constants.h>
Expand Down Expand Up @@ -74,9 +73,6 @@ class BaseBead {
*/
Index getMoleculeId() const noexcept { return molecule_id_; }

/// Gets the topology pointer the bead is attached too
Topology *getParent() const { return topology_item_.getParent(); }

/**
* get the bead type
* \return const string
Expand Down Expand Up @@ -141,8 +137,6 @@ class BaseBead {
protected:
BaseBead(){};

TopologyItem topology_item_ = nullptr;

std::string type_ = tools::topology_constants::unassigned_bead_type;
Index id_ = tools::topology_constants::unassigned_residue_id;
Index molecule_id_ = tools::topology_constants::unassigned_molecule_id;
Expand Down
12 changes: 6 additions & 6 deletions include/votca/csg/bead.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
*
*/

#ifndef _VOTCA_CSG_BEAD_H
#define _VOTCA_CSG_BEAD_H
#ifndef VOTCA_CSG_BEAD_H
#define VOTCA_CSG_BEAD_H
#pragma once

#include <assert.h>
#include <cassert>
Expand Down Expand Up @@ -289,10 +290,9 @@ class Bead : public BaseBead {
bool bead_force_set_;

/// constructor
Bead(Topology *owner, Index id, std::string type, Symmetry symmetry,
std::string name, Index resnr, double m, double q)
Bead(Index id, std::string type, Symmetry symmetry, std::string name,
Index resnr, double m, double q)
: symmetry_(symmetry), charge_(q), residue_number_(resnr) {
topology_item_._parent = owner;
setId(id);
setType(type);
setName(name);
Expand Down Expand Up @@ -372,4 +372,4 @@ inline void Bead::HasW(bool b) { bW_ = b; }
} // namespace csg
} // namespace votca

#endif // _VOTCA_CSG_BEAD_H
#endif // VOTCA_CSG_BEAD_H
51 changes: 0 additions & 51 deletions include/votca/csg/beadtype.h

This file was deleted.

10 changes: 9 additions & 1 deletion include/votca/csg/boundarycondition.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
* limitations under the License.
*
*/
#pragma once
#ifndef VOTCA_CSG_BOUNDARYCONDITION_H
#define VOTCA_CSG_BOUNDARYCONDITION_H
#pragma once

#include <memory>
#include <votca/tools/eigen.h>
Expand Down Expand Up @@ -62,6 +62,14 @@ class BoundaryCondition {
*/
const Eigen::Matrix3d &getBox() const noexcept { return _box; };

/**
* @brief Self explanatory gets the shortest dimension of the boundary
* conditions
*
* @return
*/
double getShortestBoxDimension() const;

/**
* get the volume of the box
* \return box volume as double
Expand Down
11 changes: 6 additions & 5 deletions include/votca/csg/interaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
*
*/

#ifndef _VOTCA_CSG_INTERACTION_H
#define _VOTCA_CSG_INTERACTION_H
#pragma once
#ifndef VOTCA_CSG_INTERACTION_H
#define VOTCA_CSG_INTERACTION_H

#include "bead.h"
#include "topology.h"
Expand Down Expand Up @@ -79,8 +80,8 @@ class Interaction {
}

virtual Eigen::Vector3d Grad(const Topology &top, Index bead) = 0;
Index BeadCount() { return _beads.size(); }
Index getBeadId(Index bead) {
Index BeadCount() const { return _beads.size(); }
Index getBeadId(Index bead) const {
assert(bead > -1 && boost::lexical_cast<size_t>(bead) < _beads.size());
return _beads[bead];
}
Expand Down Expand Up @@ -321,4 +322,4 @@ inline Eigen::Vector3d IDihedral::Grad(const Topology &top, Index bead) {
} // namespace csg
} // namespace votca

#endif // _VOTCA_CSG_INTERACTION_H
#endif // VOTCA_CSG_INTERACTION_H
16 changes: 9 additions & 7 deletions include/votca/csg/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
*
*/

#ifndef _VOTCA_CSG_MAP_H
#define _VOTCA_CSG_MAP_H
#ifndef VOTCA_CSG_MAP_H
#define VOTCA_CSG_MAP_H
#pragma once

#include "boundarycondition.h"
#include "molecule.h"
#include <vector>
#include <votca/tools/eigen.h>
Expand All @@ -37,7 +39,7 @@ class Map {

void AddBeadMap(BeadMap *bmap) { _maps.push_back(bmap); }

void Apply();
void Apply(const BoundaryCondition &bc);

protected:
Molecule _in, _out;
Expand All @@ -50,7 +52,7 @@ class Map {
class BeadMap {
public:
virtual ~BeadMap() = default;
virtual void Apply() = 0;
virtual void Apply(const BoundaryCondition &) = 0;
virtual void Initialize(Molecule *in, Bead *out, tools::Property *opts_map,
tools::Property *opts_bead);

Expand All @@ -76,7 +78,7 @@ inline void BeadMap::Initialize(Molecule *in, Bead *out,
class Map_Sphere : public BeadMap {
public:
Map_Sphere() = default;
void Apply() override;
void Apply(const BoundaryCondition &) override;

void Initialize(Molecule *in, Bead *out, tools::Property *opts_bead,
tools::Property *opts_map) override;
Expand Down Expand Up @@ -106,12 +108,12 @@ inline void Map_Sphere::AddElem(Bead *in, double weight, double force_weight) {
class Map_Ellipsoid : public Map_Sphere {
public:
Map_Ellipsoid() = default;
void Apply() override;
void Apply(const BoundaryCondition &) override;

protected:
};

} // namespace csg
} // namespace votca

#endif /* _VOTCA_CSG_MAP_H */
#endif // VOTCA_CSG_MAP_H
13 changes: 6 additions & 7 deletions include/votca/csg/molecule.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
*
*/

#ifndef _VOTCA_CSG_MOLECULE_H
#define _VOTCA_CSG_MOLECULE_H
#pragma once
#ifndef VOTCA_CSG_MOLECULE_H
#define VOTCA_CSG_MOLECULE_H

#include "bead.h"
#include "topologyitem.h"
#include <assert.h>
#include <map>
#include <string>
Expand All @@ -39,7 +39,7 @@ class Interaction;
\todo sort atoms in molecule
*/
class Molecule : public TopologyItem {
class Molecule {
public:
/// get the molecule ID
Index getId() const { return _id; }
Expand Down Expand Up @@ -98,8 +98,7 @@ class Molecule : public TopologyItem {
void *_userdata;

/// constructor
Molecule(Topology *parent, Index id, std::string name)
: TopologyItem(parent), _id(id), _name(name) {}
Molecule(Index id, std::string name) : _id(id), _name(name) {}

friend class Topology;
};
Expand All @@ -117,4 +116,4 @@ inline Index Molecule::getBeadIdByName(const std::string &name) {
} // namespace csg
} // namespace votca

#endif /* _VOTCA_CSG_MOLECULE_H */
#endif // VOTCA_CSG_MOLECULE_H
14 changes: 6 additions & 8 deletions include/votca/csg/residue.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@
* limitations under the License.
*
*/
#pragma once
#ifndef VOTCA_CSG_RESIDUE_H
#define VOTCA_CSG_RESIDUE_H

#ifndef _VOTCA_CSG_RESIDUE_H
#define _VOTCA_CSG_RESIDUE_H

#include "topologyitem.h"
#include <string>

namespace votca {
Expand All @@ -32,7 +31,7 @@ namespace csg {
based on their residue.
*/
class Residue : public TopologyItem {
class Residue {
public:
/// get the name of the residue
const std::string &getName();
Expand All @@ -46,8 +45,7 @@ class Residue : public TopologyItem {

private:
/// constructor
Residue(Topology *parent, Index id, const std::string &name)
: TopologyItem(parent), _id(id), _name(name) {}
Residue(Index id, const std::string &name) : _id(id), _name(name) {}
friend class Topology;
};

Expand All @@ -56,4 +54,4 @@ inline const std::string &Residue::getName() { return _name; }
} // namespace csg
} // namespace votca

#endif /* _VOTCA_CSG_RESIDUE_H */
#endif // VOTCA_CSG_RESIDUE_H
26 changes: 18 additions & 8 deletions include/votca/csg/topology.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
*
*/

#ifndef _VOTCA_CSG_TOPOLOGY_H
#define _VOTCA_CSG_TOPOLOGY_H
#ifndef VOTCA_CSG_TOPOLOGY_H
#define VOTCA_CSG_TOPOLOGY_H
#pragma once

#include <cassert>
#include <list>
Expand All @@ -25,7 +26,6 @@
#include <vector>

#include "bead.h"
#include "beadtype.h"
#include "boundarycondition.h"
#include "exclusionlist.h"
#include "molecule.h"
Expand Down Expand Up @@ -176,6 +176,9 @@ class Topology {
* @return bonded interaction container
*/
InteractionContainer &BondedInteractions() { return _interactions; }
const InteractionContainer &BondedInteractions() const {
return _interactions;
}

void AddBondedInteraction(Interaction *ic);
std::list<Interaction *> InteractionsInGroup(const std::string &group);
Expand Down Expand Up @@ -289,6 +292,13 @@ class Topology {
*/
const Eigen::Matrix3d &getBox() const { return _bc->getBox(); };

/**
* @brief Return the boundary condition object
*/
const BoundaryCondition &getBoundary() const {
assert(_bc != nullptr && "Cannot return boundary condition is null");
return *_bc;
};
/**
* set the time of current frame
* \param t simulation time in ns
Expand Down Expand Up @@ -427,25 +437,25 @@ inline Bead *Topology::CreateBead(Bead::Symmetry symmetry, std::string name,
std::string type, Index resnr, double m,
double q) {

Bead *b = new Bead(this, _beads.size(), type, symmetry, name, resnr, m, q);
Bead *b = new Bead(_beads.size(), type, symmetry, name, resnr, m, q);
_beads.push_back(b);
return b;
}

inline Molecule *Topology::CreateMolecule(std::string name) {
Molecule *mol = new Molecule(this, _molecules.size(), name);
Molecule *mol = new Molecule(_molecules.size(), name);
_molecules.push_back(mol);
return mol;
}

inline Residue *Topology::CreateResidue(std::string name, Index id) {
Residue *res = new Residue(this, id, name);
Residue *res = new Residue(id, name);
_residues.push_back(res);
return res;
}

inline Residue *Topology::CreateResidue(std::string name) {
Residue *res = new Residue(this, _residues.size(), name);
Residue *res = new Residue(_residues.size(), name);
_residues.push_back(res);
return res;
}
Expand All @@ -464,4 +474,4 @@ inline void Topology::InsertExclusion(Bead *bead1, iteratable &l) {

#include "interaction.h"

#endif /* _VOTCA_CSG_TOPOLOGY_H */
#endif // VOTCA_CSG_TOPOLOGY_H
Loading

0 comments on commit 0c458e9

Please sign in to comment.