Commit f2d06c90 authored by Jens Wehner's avatar Jens Wehner

added brackets for all if,while,for

parent 22f51d1d
Pipeline #89513762 canceled with stages
in 88 minutes and 26 seconds
......@@ -274,10 +274,6 @@ class Bead : public BaseBead {
protected:
std::vector<int> parent_beads_;
// TODO: this is so far a pointer. this should change! each bead should have
// own options.
// Property *options_;
tools::byte_t symmetry_;
double charge_;
......@@ -291,7 +287,7 @@ class Bead : public BaseBead {
bool bW_;
bool bead_force_set_;
/// constructur
/// constructor
Bead(Topology *owner, int id, std::string type, tools::byte_t symmetry,
std::string name, int resnr, double m, double q)
: symmetry_(symmetry), charge_(q), residue_number_(resnr) {
......@@ -308,8 +304,6 @@ class Bead : public BaseBead {
bead_force_set_ = false;
}
// void *_userdata;
friend class Topology;
friend class Molecule;
};
......
......@@ -18,9 +18,9 @@
#ifndef _VOTCA_CSG_BEADLIST_H
#define _VOTCA_CSG_BEADLIST_H
#include "topology.h"
#include <list>
#include <string>
#include <votca/tools/eigen.h>
namespace votca {
namespace csg {
......@@ -32,6 +32,9 @@ namespace csg {
*/
class Topology;
class Bead;
class BeadList {
public:
/// \brief Select all beads of type <select>
......
......@@ -93,14 +93,18 @@ inline CGMoleculeDef *CGEngine::getMoleculeDef(std::string name) {
}
iter = _molecule_defs.find(name);
if (iter == _molecule_defs.end()) return nullptr;
if (iter == _molecule_defs.end()) {
return nullptr;
}
return (*iter).second;
}
inline bool CGEngine::IsIgnored(std::string ident) {
for (std::list<std::string>::iterator iter = _ignores.begin();
iter != _ignores.end(); ++iter) {
if (tools::wildcmp(iter->c_str(), ident.c_str())) return true;
if (tools::wildcmp(iter->c_str(), ident.c_str())) {
return true;
}
}
return false;
}
......
......@@ -59,10 +59,11 @@ class CsgApplication : public tools::Application {
/* \brief overload and return false to disable synchronized (while threaded)
* calculations */
virtual bool SynchronizeThreads(void) {
if (DoThreaded())
if (DoThreaded()) {
return true;
else
} else {
return false;
}
}
/// \brief if topology is always needed
......
......@@ -76,7 +76,10 @@ class ExclusionList {
inline ExclusionList::exclusion_t *ExclusionList::GetExclusions(Bead *bead) {
std::map<Bead *, exclusion_t *>::iterator iter = _excl_by_bead.find(bead);
if (iter == _excl_by_bead.end()) return nullptr;
if (iter == _excl_by_bead.end()) {
return nullptr;
}
return (*iter).second;
}
......@@ -106,11 +109,17 @@ template <typename iteratable>
inline void ExclusionList::InsertExclusion(Bead *bead1_, iteratable &l) {
for (typename iteratable::iterator i = l.begin(); i != l.end(); ++i) {
Bead *bead1 = bead1_;
;
Bead *bead2 = *i;
if (bead2->getId() < bead1->getId()) std::swap(bead1, bead2);
if (bead1 == bead2) continue;
if (IsExcluded(bead1, bead2)) continue;
if (bead2->getId() < bead1->getId()) {
std::swap(bead1, bead2);
}
if (bead1 == bead2) {
continue;
}
if (IsExcluded(bead1, bead2)) {
continue;
}
exclusion_t *e;
if ((e = GetExclusions(bead1)) == nullptr) {
e = new exclusion_t;
......@@ -124,9 +133,17 @@ inline void ExclusionList::InsertExclusion(Bead *bead1_, iteratable &l) {
// template<>
inline void ExclusionList::InsertExclusion(Bead *bead1, Bead *bead2) {
if (bead2->getId() < bead1->getId()) std::swap(bead1, bead2);
if (bead1 == bead2) return;
if (IsExcluded(bead1, bead2)) return;
if (bead2->getId() < bead1->getId()) {
std::swap(bead1, bead2);
}
if (bead1 == bead2) {
return;
}
if (IsExcluded(bead1, bead2)) {
return;
}
exclusion_t *e;
if ((e = GetExclusions(bead1)) == nullptr) {
......@@ -139,19 +156,35 @@ inline void ExclusionList::InsertExclusion(Bead *bead1, Bead *bead2) {
}
inline void ExclusionList::RemoveExclusion(Bead *bead1, Bead *bead2) {
if (bead2->getId() < bead1->getId()) std::swap(bead1, bead2);
if (bead1 == bead2) return;
if (!IsExcluded(bead1, bead2)) return;
if (bead2->getId() < bead1->getId()) {
std::swap(bead1, bead2);
}
if (bead1 == bead2) {
return;
}
if (!IsExcluded(bead1, bead2)) {
return;
}
std::list<exclusion_t *>::iterator ex;
for (ex = _exclusions.begin(); ex != _exclusions.end(); ++ex)
if ((*ex)->_atom == bead1) break;
if (ex == _exclusions.end()) return;
(*ex)->_exclude.remove(bead2);
if ((*ex)->_exclude.empty()) {
(*ex) = nullptr;
_exclusions.erase(ex);
for (ex = _exclusions.begin(); ex != _exclusions.end(); ++ex) {
if ((*ex)->_atom == bead1) {
break;
}
if (ex == _exclusions.end()) {
return;
}
(*ex)->_exclude.remove(bead2);
if ((*ex)->_exclude.empty()) {
(*ex) = nullptr;
_exclusions.erase(ex);
}
_exclusions.remove(nullptr);
}
_exclusions.remove(nullptr);
}
std::ostream &operator<<(std::ostream &out, ExclusionList &ex);
......
......@@ -23,13 +23,11 @@
#include <sstream>
#include <string>
namespace TOOLS = votca::tools;
namespace votca {
namespace csg {
/**
\brief base calss for all interactions
\brief base class for all interactions
This is the base class for all interactions.
......@@ -37,7 +35,7 @@ namespace csg {
*/
class Interaction {
public:
Interaction() : _index(-1), _group(""), _group_id(-1), _name(""), _mol(-1){};
Interaction() = default;
virtual ~Interaction() = default;
virtual double EvaluateVar(const Topology &top) = 0;
......@@ -88,11 +86,11 @@ class Interaction {
}
protected:
int _index;
std::string _group;
int _group_id;
std::string _name;
int _mol;
int _index = -1;
std::string _group = "";
int _group_id = -1;
std::string _name = "";
int _mol = -1;
std::vector<int> _beads;
void RebuildName();
......@@ -100,14 +98,22 @@ class Interaction {
inline void Interaction::RebuildName() {
std::stringstream s;
if (_mol != -1) s << "molecule " << _mol;
if (_mol != -1) {
{
s << "molecule " << _mol;
}
}
if (!_group.empty()) {
s << ":" << _group;
if (_group_id != -1) {
s << " " << _group_id;
}
}
if (_index != -1) s << ":index " << _index;
if (_index != -1) {
{
s << ":index " << _index;
}
}
_name = s.str();
}
......
......@@ -28,8 +28,6 @@
namespace votca {
namespace csg {
namespace TOOLS = votca::tools;
class Interaction;
/**
......@@ -108,7 +106,11 @@ class Molecule : public TopologyItem {
inline int Molecule::getBeadIdByName(const std::string &name) {
int i = getBeadByName(name);
if (i < 0) return i;
if (i < 0) {
{
return i;
}
}
return _beads[i]->getId();
}
......
......@@ -165,14 +165,18 @@ inline void NBList::SetMatchFunction(T *object,
bool (T::*fkt)(Bead *, Bead *,
const Eigen::Vector3d &,
const double)) {
if (_match_function) delete _match_function;
if (_match_function) {
delete _match_function;
}
_match_function = dynamic_cast<Functor *>(new FunctorMember<T>(object, fkt));
}
inline void NBList::SetMatchFunction(bool (*fkt)(Bead *, Bead *,
const Eigen::Vector3d &,
const double)) {
if (_match_function) delete _match_function;
if (_match_function) {
delete _match_function;
}
_match_function = dynamic_cast<Functor *>(new FunctorNonMember(fkt));
}
......
......@@ -202,7 +202,9 @@ inline void NBList_3Body::SetMatchFunction(
const Eigen::Vector3d &, const Eigen::Vector3d &,
const double dist12, const double dist13,
const double dist23)) {
if (_match_function) delete _match_function;
if (_match_function) {
delete _match_function;
}
_match_function = dynamic_cast<Functor *>(new FunctorMember<T>(object, fkt));
}
......@@ -210,7 +212,9 @@ inline void NBList_3Body::SetMatchFunction(bool (*fkt)(
Bead *, Bead *, Bead *, const Eigen::Vector3d &, const Eigen::Vector3d &,
const Eigen::Vector3d &, const double dist12, const double dist13,
const double dist23)) {
if (_match_function) delete _match_function;
if (_match_function) {
delete _match_function;
}
_match_function = dynamic_cast<Functor *>(new FunctorNonMember(fkt));
}
......
......@@ -78,8 +78,9 @@ inline void PairList<element_type, pair_type>::AddPair(pair_type *p) {
template <typename element_type, typename pair_type>
inline void PairList<element_type, pair_type>::Cleanup() {
for (iterator iter = _pairs.begin(); iter != _pairs.end(); ++iter)
for (iterator iter = _pairs.begin(); iter != _pairs.end(); ++iter) {
delete *iter;
}
_pairs.clear();
_pair_map.clear();
}
......@@ -90,11 +91,15 @@ inline pair_type *PairList<element_type, pair_type>::FindPair(element_type e1,
typename std::map<element_type, std::map<element_type, pair_type *>>::iterator
iter1;
iter1 = _pair_map.find(e1);
if (iter1 == _pair_map.end()) return nullptr;
if (iter1 == _pair_map.end()) {
return nullptr;
}
typename partners::iterator iter2;
iter2 = iter1->second.find(e2);
if (iter2 == iter1->second.end()) return nullptr;
if (iter2 == iter1->second.end()) {
return nullptr;
}
return iter2->second;
}
......@@ -105,11 +110,15 @@ inline const pair_type *PairList<element_type, pair_type>::FindPair(
typename std::map<element_type,
std::map<element_type, pair_type *>>::const_iterator iter1;
iter1 = _pair_map.find(e1);
if (iter1 == _pair_map.end()) return nullptr;
if (iter1 == _pair_map.end()) {
return nullptr;
}
typename partners::const_iterator iter2;
iter2 = iter1->second.find(e2);
if (iter2 == iter1->second.end()) return nullptr;
if (iter2 == iter1->second.end()) {
return nullptr;
}
return iter2->second;
}
......@@ -119,7 +128,9 @@ typename PairList<element_type, pair_type>::partners *
PairList<element_type, pair_type>::FindPartners(element_type e1) {
typename std::map<element_type, std::map<element_type, pair_type *>>::iterator
iter;
if ((iter = _pair_map.find(e1)) == _pair_map.end()) return nullptr;
if ((iter = _pair_map.find(e1)) == _pair_map.end()) {
return nullptr;
}
return &(iter->second);
}
......
......@@ -33,14 +33,12 @@
#include "orthorhombicbox.h"
#include "residue.h"
#include "triclinicbox.h"
#include <votca/tools/types.h>
namespace votca {
namespace csg {
class Interaction;
class ExclusionList;
typedef std::vector<Molecule *> MoleculeContainer;
typedef std::vector<Bead *> BeadContainer;
......
......@@ -71,8 +71,9 @@ inline void TripleList<element_type, triple_type>::AddTriple(triple_type *t) {
template <typename element_type, typename triple_type>
inline void TripleList<element_type, triple_type>::Cleanup() {
for (iterator iter = _triples.begin(); iter != _triples.end(); ++iter)
for (iterator iter = _triples.begin(); iter != _triples.end(); ++iter) {
delete *iter;
}
_triples.clear();
_triple_map.clear();
}
......@@ -85,16 +86,22 @@ inline triple_type *TripleList<element_type, triple_type>::FindTriple(
std::map<element_type, std::map<element_type, triple_type *>>>::iterator
iter1;
iter1 = _triple_map.find(e1);
if (iter1 == _triple_map.end()) return nullptr;
if (iter1 == _triple_map.end()) {
return nullptr;
}
typename std::map<element_type,
std::map<element_type, triple_type *>>::iterator iter2;
iter2 = iter1->second.find(e2);
if (iter2 == iter1->second.end()) return nullptr;
if (iter2 == iter1->second.end()) {
return nullptr;
}
typename std::map<element_type, triple_type *>::iterator iter3;
iter3 = iter2->second.find(e3);
if (iter3 == iter2->second.end()) return nullptr;
if (iter3 == iter2->second.end()) {
return nullptr;
}
return iter3->second;
}
......
......@@ -85,7 +85,9 @@ inline void XYZWriter::Write(T &container, std::string header) {
if (atomname.size() > 3) {
atomname = atomname.substr(0, 3);
}
while (atomname.size() < 3) atomname = " " + atomname;
while (atomname.size() < 3) {
atomname = " " + atomname;
}
_out << fmter % atomname % r.x() % r.y() % r.z();
}
......
......@@ -58,7 +58,9 @@ void CsgTestApp::EvalConfiguration(Topology *top, Topology *top_ref) {
nb.setCutoff(_cut_off);
nb.Generate(b);
NBList::iterator i;
for (i = nb.begin(); i != nb.end(); ++i) _rdf.Process((*i)->dist());
for (i = nb.begin(); i != nb.end(); ++i) {
_rdf.Process((*i)->dist());
}
}
void CsgTestApp::Initialize() {
......
......@@ -76,9 +76,10 @@ bool CsgBoltzmann::EvaluateOptions() {
bool CsgBoltzmann::EvaluateTopology(Topology *top, Topology *top_ref) {
if (OptionsMap().count("excl")) {
ExclusionList *ex;
if (top_ref->MoleculeCount() > 1)
if (top_ref->MoleculeCount() > 1) {
cout << "WARNING: cannot create exclusion list for topology with"
"multiple molecules, using only first molecule\n";
}
cout << "Writing exclusion list for atomistic molecule "
<< top_ref->MoleculeByIndex(0)->getName()
......@@ -147,7 +148,9 @@ ExclusionList *CsgBoltzmann::CreateExclusionList(Molecule &atomistic,
void CsgBoltzmann::Run() {
CsgApplication::Run();
if (OptionsMap().count("excl")) return;
if (OptionsMap().count("excl")) {
return;
}
InteractiveMode();
}
......@@ -183,12 +186,16 @@ void CsgBoltzmann::InteractiveMode() {
votca::tools::Tokenizer tok(line, " \t");
vector<string> args = tok.ToVector();
if (args.size() == 0) continue;
if (args.size() == 0) {
continue;
}
string cmd = args.front();
args.erase(args.begin());
if (cmd == "q") break;
if (cmd == "q") {
break;
}
std::map<string, AnalysisTool *>::iterator tool;
if (cmd == "help") {
......
......@@ -36,9 +36,15 @@ void StdAnalysis::Register(std::map<std::string, AnalysisTool *> &lib) {
void StdAnalysis::Command(BondedStatistics &bs, const std::string &cmd,
std::vector<std::string> &args) {
if (cmd == "vals") WriteValues(bs, args);
if (cmd == "cor") WriteCorrelations(bs, args);
if (cmd == "autocor") WriteAutocorrelation(bs, args);
if (cmd == "vals") {
WriteValues(bs, args);
}
if (cmd == "cor") {
WriteCorrelations(bs, args);
}
if (cmd == "autocor") {
WriteAutocorrelation(bs, args);
}
if (cmd == "list") {
votca::tools::DataCollection<double>::selection *sel =
bs.BondedValues().select("*");
......@@ -88,8 +94,9 @@ void StdAnalysis::WriteValues(BondedStatistics &bs,
votca::tools::DataCollection<double>::selection *sel = nullptr;
for (size_t i = 1; i < args.size(); i++)
for (size_t i = 1; i < args.size(); i++) {
sel = bs.BondedValues().select(args[i], sel);
}
out.open(args[0]);
out << *sel << std::endl;
......@@ -104,8 +111,9 @@ void StdAnalysis::WriteAutocorrelation(BondedStatistics &bs,
std::ofstream out;
votca::tools::DataCollection<double>::selection *sel = nullptr;
for (size_t i = 1; i < args.size(); i++)
for (size_t i = 1; i < args.size(); i++) {
sel = bs.BondedValues().select(args[i], sel);
}
votca::tools::CrossCorrelate c;
c.AutoCorrelate(sel, false);
......@@ -122,8 +130,9 @@ void StdAnalysis::WriteCorrelations(BondedStatistics &bs,
std::ofstream out;
votca::tools::DataCollection<double>::selection *sel = nullptr;
for (size_t i = 1; i < args.size(); i++)
for (size_t i = 1; i < args.size(); i++) {
sel = bs.BondedValues().select(args[i], sel);
}
votca::tools::Correlate c;
c.CalcCorrelations(sel);
......
......@@ -255,9 +255,9 @@ void TabulatedPotential::WritePotential(BondedStatistics &bs,
bool TabulatedPotential::SetOption_(Histogram::options_t &op,
const vector<string> &args) {
if (args.size() > 2) {
if (args[1] == "n")
if (args[1] == "n") {
op._n = boost::lexical_cast<int>(args[2]);
else if (args[1] == "min") {
} else if (args[1] == "min") {
op._min = boost::lexical_cast<double>(args[2]);
} else if (args[1] == "max") {
op._max = boost::lexical_cast<double>(args[2]);
......@@ -296,13 +296,15 @@ void TabulatedPotential::CalcForce_(vector<double> &U, vector<double> &F,
size_t n = U.size();
double f = 0.5 / dx;
F.resize(n);
if (bPeriodic)
if (bPeriodic) {
F[n - 1] = F[0] = -(U[1] - U[n - 2]) * f;
else {
} else {
F[0] = -(U[1] - U[0]) * 2 * f;
F[n - 1] = -(U[n - 1] - U[n - 2]) * 2 * f;
}
for (size_t i = 1; i < n - 1; i++) F[i] = -(U[i + 1] - U[i - 1]) * f;
for (size_t i = 1; i < n - 1; i++) {
F[i] = -(U[i + 1] - U[i - 1]) * f;
}
}
void TabulatedPotential::Smooth_(vector<double> &data, bool bPeriodic) {
......@@ -348,17 +350,20 @@ void TabulatedPotential::BoltzmannInvert_(vector<double> &data) {
for (size_t i = 0; i < data.size(); i++) {
_max = max(data[i], _max);
if (data[i] > 0) _min = min(data[i], _min);
if (data[i] > 0) {
_min = min(data[i], _min);
}
}
_max = -conv::kB * conv::ev2kj_per_mol * _Temperature * log(_max);
_min = -conv::kB * conv::ev2kj_per_mol * _Temperature * log(_min) - _max;
for (size_t i = 0; i < data.size(); i++) {
if (data[i] == 0)
if (data[i] == 0) {
data[i] = _min;
else
} else {
data[i] =
-conv::kB * conv::ev2kj_per_mol * _Temperature * log(data[i]) - _max;
}
}
}
......
......@@ -68,8 +68,10 @@ int BeadList::GenerateInSphericalSubvolume(Topology &top, const string &select,
}
for (iter = top.Beads().begin(); iter != top.Beads().end(); ++iter) {
if (_topology->BCShortestConnection(ref, (*iter)->getPos()).norm() > radius)
if (_topology->BCShortestConnection(ref, (*iter)->getPos()).norm() >
radius) {
continue;
}
if (!selectByName) {
if (tools::wildcmp(pSelect.c_str(), (*iter)->getType().c_str())) {
_beads.push_back(*iter);
......
......@@ -66,12 +66,16 @@ void BeadMotif::CalculateType_() {
}
bool BeadMotif::isSingle_() {
if (BeadCount() == 1) return true;
if (BeadCount() == 1) {
return true;
}
return false;
}
bool BeadMotif::isLine_() {
if (junctionExist_()) return false;
if (junctionExist_()) {
return false;
}
// Ensure that the degree of two of the vertices is 1
// all other vertices must be 2
int num_vertices_degree_1 = 0;
......@@ -87,17 +91,23 @@ bool BeadMotif::isLine_() {
return false;
}
}
if (num_vertices_degree_1 != 2) return false;
if (num_vertices_degree_1 != 2) {
return false;
}
return true;
}
bool BeadMotif::isLoop_() {
if (junctionExist_()) return false;
if (junctionExist_()) {
return false;
}
// Ensure that the degree of every vertex is 2
vector<int> vertices = graph_.getVertices();
for (int& vertex : vertices) {
if (graph_.getDegree(vertex) != 2) return false;
if (graph_.getDegree(vertex) != 2) {
return false;
}
}
return true;
}
......@@ -137,11 +147,15 @@ bool BeadMotif::isLoop_() {
* all the edges.
**/
bool BeadMotif::isFusedRing_() {
if (!junctionExist_()) return false;
if (!junctionExist_()) {
return false;
}
// Ensure that the degree of every vertex is 2 or greater
vector<int> vertices = graph_.getVertices();
for (int& vertex : vertices) {
if (graph_.getDegree(vertex) < 2) return false;
if (graph_.getDegree(vertex) < 2) {
return false;
}
}
// If exploring from one branch of a junction lets you explore every
// edge than it is a fused ring.
......
......@@ -31,8 +31,9 @@ CGEngine::CGEngine() = default;
CGEngine::~CGEngine() {
map<string, CGMoleculeDef *>::iterator i;
for (i = _molecule_defs.begin(); i != _molecule_defs.end(); ++i)
for (i = _molecule_defs.begin(); i != _molecule_defs.end(); ++i) {
delete (*i).second;
}
_molecule_defs.clear();
}
......@@ -45,7 +46,9 @@ TopologyMap *CGEngine::CreateCGTopology(Topology &in, Topology &out) {
TopologyMap *m = new TopologyMap(&in, &out);
for (iter = mols.begin(); iter != mols.end(); ++iter) {
Molecule *mol = *iter;
if (IsIgnored(mol->getName())) continue;
if (IsIgnored(mol->getName())) {