update colvars to another set of changes from the upstream repo

(cherry picked from commit cb816f8cba)
This commit is contained in:
Axel Kohlmeyer 2016-08-10 09:35:21 -04:00
parent 1b33d00785
commit 977b9e542f
14 changed files with 44 additions and 50 deletions

View File

@ -1952,4 +1952,4 @@ void colvar::calc_runave()
// Static members
std::vector<cvm::deps::feature *> colvar::cv_features;
std::vector<colvardeps::feature *> colvar::cv_features;

View File

@ -38,7 +38,7 @@
/// \link colvarvalue \endlink type, you should also add its
/// initialization line in the \link colvar \endlink constructor.
class colvar : public colvarparse, public cvm::deps {
class colvar : public colvarparse, public colvardeps {
public:

View File

@ -1192,6 +1192,6 @@ void cvm::atom_group::apply_force(cvm::rvector const &force)
// Static members
std::vector<cvm::deps::feature *> cvm::atom_group::ag_features;
std::vector<colvardeps::feature *> cvm::atom_group::ag_features;

View File

@ -139,7 +139,7 @@ public:
/// \brief Group of \link atom \endlink objects, mostly used by a
/// \link cvc \endlink object to gather all atomic data
class colvarmodule::atom_group
: public colvarparse, public cvm::deps
: public colvarparse, public colvardeps
{
public:

View File

@ -246,4 +246,4 @@ std::ostream & colvarbias::write_traj(std::ostream &os)
// Static members
std::vector<cvm::deps::feature *> colvarbias::cvb_features;
std::vector<colvardeps::feature *> colvarbias::cvb_features;

View File

@ -9,7 +9,7 @@
/// \brief Collective variable bias, base class
class colvarbias : public colvarparse, public cvm::deps {
class colvarbias : public colvarparse, public colvardeps {
public:
/// Name of this bias

View File

@ -103,7 +103,7 @@ int colvar::cvc::setup()
description = "cvc " + name;
for (i = 0; i < atom_groups.size(); i++) {
add_child((cvm::deps *) atom_groups[i]);
add_child((colvardeps *) atom_groups[i]);
}
return COLVARS_OK;
@ -272,4 +272,4 @@ void colvar::cvc::debug_gradients(cvm::atom_group *group)
// Static members
std::vector<cvm::deps::feature *> colvar::cvc::cvc_features;
std::vector<colvardeps::feature *> colvar::cvc::cvc_features;

View File

@ -61,7 +61,7 @@
/// call to e.g. apply_force().
class colvar::cvc
: public colvarparse, public cvm::deps
: public colvarparse, public colvardeps
{
public:

View File

@ -2,7 +2,7 @@
#include "colvardeps.h"
cvm::deps::~deps() {
colvardeps::~colvardeps() {
size_t i;
for (i=0; i<feature_states.size(); i++) {
@ -25,12 +25,12 @@ cvm::deps::~deps() {
}
void cvm::deps::provide(int feature_id) {
void colvardeps::provide(int feature_id) {
feature_states[feature_id]->available = true;
}
int cvm::deps::enable(int feature_id,
int colvardeps::enable(int feature_id,
bool dry_run /* default: false */,
// dry_run: fail silently, do not enable if available
// flag is passed recursively to deps of this feature
@ -193,7 +193,7 @@ int cvm::deps::enable(int feature_id,
features()[f]->requires_alt.back()[1] = h; \
features()[f]->requires_alt.back()[2] = i
void cvm::deps::init_cvb_requires() {
void colvardeps::init_cvb_requires() {
int i;
if (features().size() == 0) {
for (i = 0; i < f_cvb_ntot; i++) {
@ -225,7 +225,7 @@ void cvm::deps::init_cvb_requires() {
}
void cvm::deps::init_cv_requires() {
void colvardeps::init_cv_requires() {
size_t i;
if (features().size() == 0) {
for (i = 0; i < f_cv_ntot; i++) {
@ -342,11 +342,11 @@ void cvm::deps::init_cv_requires() {
}
void cvm::deps::init_cvc_requires() {
void colvardeps::init_cvc_requires() {
size_t i;
// Initialize static array once and for all
if (features().size() == 0) {
for (i = 0; i < cvm::deps::f_cvc_ntot; i++) {
for (i = 0; i < colvardeps::f_cvc_ntot; i++) {
features().push_back(new feature);
}
@ -384,7 +384,7 @@ void cvm::deps::init_cvc_requires() {
// Initialize feature_states for each instance
// default as unavailable, not enabled
feature_states.reserve(f_cvc_ntot);
for (i = 0; i < cvm::deps::f_cvc_ntot; i++) {
for (i = 0; i < colvardeps::f_cvc_ntot; i++) {
feature_states.push_back(new feature_state(this, feature_states.size(), false, false));
}
@ -392,12 +392,12 @@ void cvm::deps::init_cvc_requires() {
// Each cvc specifies what other features are available
feature_states[f_cvc_active]->available = true;
feature_states[f_cvc_gradient]->available = true;
feature_states[f_cvc_scalable_com]->available = (proxy->scalable_group_coms() == COLVARS_OK);
feature_states[f_cvc_scalable_com]->available = (cvm::proxy->scalable_group_coms() == COLVARS_OK);
feature_states[f_cvc_scalable]->available = feature_states[f_cvc_scalable_com]->available;
}
void cvm::deps::init_ag_requires() {
void colvardeps::init_ag_requires() {
size_t i;
// Initialize static array once and for all
if (features().size() == 0) {
@ -428,18 +428,18 @@ void cvm::deps::init_ag_requires() {
// Initialize feature_states for each instance
// default as unavailable, not enabled
feature_states.reserve(f_ag_ntot);
for (i = 0; i < cvm::deps::f_ag_ntot; i++) {
for (i = 0; i < colvardeps::f_ag_ntot; i++) {
feature_states.push_back(new feature_state(this, feature_states.size(), false, false));
}
// Features that are implemented (or not) by all atom groups
feature_states[f_ag_active]->available = true;
feature_states[f_ag_scalable_com]->available = (proxy->scalable_group_coms() == COLVARS_OK);
feature_states[f_ag_scalable_com]->available = (cvm::proxy->scalable_group_coms() == COLVARS_OK);
feature_states[f_ag_scalable]->available = feature_states[f_ag_scalable_com]->available;
}
void cvm::deps::print_state() {
void colvardeps::print_state() {
size_t i;
cvm::log("Enabled features of " + description);
for (i = 0; i < feature_states.size(); i++) {
@ -456,13 +456,13 @@ void cvm::deps::print_state() {
void cvm::deps::add_child(deps *child) {
void colvardeps::add_child(colvardeps *child) {
children.push_back(child);
child->parents.push_back((deps *)this);
child->parents.push_back((colvardeps *)this);
}
void cvm::deps::remove_child(deps *child) {
void colvardeps::remove_child(colvardeps *child) {
int i;
bool found = false;
@ -490,7 +490,7 @@ void cvm::deps::remove_child(deps *child) {
}
void cvm::deps::remove_all_children() {
void colvardeps::remove_all_children() {
size_t i;
int j;
bool found;

View File

@ -16,11 +16,11 @@
// It seems important to have available default to false (for safety) and enabled to false (for efficiency)
class cvm::deps {
class colvardeps {
public:
deps() {}
virtual ~deps();
colvardeps() {}
virtual ~colvardeps();
// Subclasses should initialize the following members:
@ -29,13 +29,13 @@ public:
/// This contains the current state of each feature for each object
class feature_state {
private:
cvm::deps *const deps_object;
colvardeps *const deps_object;
int const id;
operator int() { return 0; } // never cast as int
public:
inline cvm::deps *object() const { return deps_object; }
inline colvardeps *object() const { return deps_object; }
inline int feature_id() const { return id; }
feature_state(cvm::deps *o, int i, bool a, bool e)
feature_state(colvardeps *o, int i, bool a, bool e)
: deps_object(o), id(i), available(a), enabled(e) {}
/// Available means: supported, subject to dependencies as listed,
@ -97,9 +97,9 @@ public:
// implement this as virtual to allow overriding
virtual std::vector<feature *>&features() = 0;
void add_child(deps *child);
void add_child(colvardeps *child);
void remove_child(deps *child);
void remove_child(colvardeps *child);
/// Used before deleting an object, if not handled by that object's destructor
/// (useful for cvcs because their children are member objects)
@ -111,11 +111,11 @@ private:
// pointers to objects this object depends on
// list should be maintained by any code that modifies the object
// this could be secured by making lists of colvars / cvcs / atom groups private and modified through accessor functions
std::vector<deps *> children;
std::vector<colvardeps *> children;
// pointers to objects that depend on this object
// the size of this array is in effect a reference counter
std::vector<deps *> parents;
std::vector<colvardeps *> parents;
public:
// disabling a feature f:
@ -128,7 +128,7 @@ public:
//
// }
// std::vector<deps *> parents; // Needed to trigger a refresh if capabilities of this object change
// std::vector<colvardeps *> parents; // Needed to trigger a refresh if capabilities of this object change
// End of members to be initialized by subclasses

View File

@ -302,7 +302,7 @@ int colvarmodule::parse_biases(std::string const &conf)
size_t i;
for (i = 0; i < biases.size(); i++) {
biases[i]->enable(cvm::deps::f_cvb_active);
biases[i]->enable(colvardeps::f_cvb_active);
if (cvm::debug())
biases[i]->print_state();
}
@ -310,8 +310,8 @@ int colvarmodule::parse_biases(std::string const &conf)
size_t n_hist_dep_biases = 0;
std::vector<std::string> hist_dep_biases_names;
for (i = 0; i < biases.size(); i++) {
if (biases[i]->is_enabled(cvm::deps::f_cvb_apply_force) &&
biases[i]->is_enabled(cvm::deps::f_cvb_history_dependent)) {
if (biases[i]->is_enabled(colvardeps::f_cvb_apply_force) &&
biases[i]->is_enabled(colvardeps::f_cvb_history_dependent)) {
n_hist_dep_biases++;
hist_dep_biases_names.push_back(biases[i]->name);
}
@ -531,7 +531,7 @@ int colvarmodule::calc_colvars()
// Determine which colvars are active at this time step
for (cvi = colvars.begin(); cvi != colvars.end(); cvi++) {
(*cvi)->feature_states[cvm::deps::f_cv_active]->enabled = (step_absolute() % (*cvi)->get_time_step_factor() == 0);
(*cvi)->feature_states[colvardeps::f_cv_active]->enabled = (step_absolute() % (*cvi)->get_time_step_factor() == 0);
}
// if SMP support is available, split up the work
@ -689,7 +689,7 @@ int colvarmodule::update_colvar_forces()
cvm::log("Communicating forces from the colvars to the atoms.\n");
cvm::increase_depth();
for (cvi = colvars.begin(); cvi != colvars.end(); cvi++) {
if ((*cvi)->is_enabled(cvm::deps::f_cv_gradient)) {
if ((*cvi)->is_enabled(colvardeps::f_cv_gradient)) {
if (!(*cvi)->is_enabled()) continue;
(*cvi)->communicate_forces();
if (cvm::get_error()) {

View File

@ -74,9 +74,6 @@ private:
public:
/// Base class to handle mutual dependencies of most objects
class deps;
friend class colvarproxy;
// TODO colvarscript should be unaware of colvarmodule's internals
friend class colvarscript;

View File

@ -356,7 +356,7 @@ bool colvarparse::get_keyval(std::string const &conf,
bool colvarparse::get_keyval(std::string const &conf,
char const *key,
cvm::deps::feature_state *value,
colvardeps::feature_state *value,
bool const &def_value,
Parse_Mode const parse_mode)
{
@ -695,7 +695,6 @@ bool colvarparse::key_lookup(std::string const &conf,
line+"\".\n", INPUT_ERROR);
return false;
}
size_t const old_end = line.size();
line_begin = line_end;
nl = conf.find('\n', line_begin+1);
@ -715,8 +714,6 @@ bool colvarparse::key_lookup(std::string const &conf,
}
}
cvm::log("Value so far = "+line.substr(data_begin, (data_end-data_begin))+".\n");
// strip the leading and trailing braces
data_begin = line.find_first_of('{') + 1;
data_begin = line.find_first_not_of(white_space,

View File

@ -183,7 +183,7 @@ public:
Parse_Mode const parse_mode = parse_normal);
bool get_keyval(std::string const &conf,
char const *key,
cvm::deps::feature_state *value,
colvardeps::feature_state *value,
bool const &def_value = false,
Parse_Mode const parse_mode = parse_normal);