Skip to content
Snippets Groups Projects
Commit 07e03ff0 authored by Giovanni Bussi's avatar Giovanni Bussi
Browse files

Added class to manage bibliography

parent 0d204692
No related branches found
No related tags found
No related merge requests found
......@@ -251,6 +251,12 @@ grid_(false)
}else{
hillsfile_=fopen(hillsfname.c_str(),"w");
}
log<<" Bibliography "<<plumed.cite("Laio and Parrinello, PNAS 99, 12562 (2002)");
if(welltemp_) log<<plumed.cite(
"Barducci, Bussi, and Parrinello, Phys. Rev. Lett. 100, 020603 (2008)");
log<<"\n";
}
void BiasMetaD::readGaussians(FILE* file)
......
#include "Citations.h"
#include "PlumedException.h"
#include "Tools.h"
#include <iostream>
using namespace std;
using namespace PLMD;
std::string Citations::cite(const std::string & item){
unsigned i;
for(i=0;i<items.size();++i) if(items[i]==item) break;
if(i==items.size()) items.push_back(item);
plumed_assert(i<items.size());
string ret;
Tools::convert(i,ret);
ret="["+ret+"]";
return ret;
}
std::ostream & PLMD::operator<<(std::ostream &log,const Citations&cit){
for(unsigned i=0;i<cit.items.size();++i)
log<<" ["<<i<<"] "<<cit.items[i]<<"\n";
return log;
}
#ifndef __PLUMED_Citations_h
#define __PLUMED_Citations_h
#include <vector>
#include <string>
#include <iosfwd>
namespace PLMD{
/**
Class taking care of bibliography.
*/
class Citations{
std::vector<std::string> items;
public:
/// Add a citation.
/// It returns a string containing the reference number, something like "[10]"
std::string cite(const std::string &);
/// Dumps the bibliography.
/// It writes on the ostream the list of all the bibliographic itemrs
/// prefixed with their reference number
friend std::ostream &operator<<(std::ostream &,const Citations&);
};
std::ostream & operator<<(std::ostream &,const Citations&);
}
#endif
......@@ -20,6 +20,7 @@
#include "PlumedCommunicator.h"
#include "CLToolMain.h"
#include "Stopwatch.h"
#include "Citations.h"
using namespace PLMD;
using namespace std;
......@@ -32,6 +33,7 @@ PlumedMain::PlumedMain():
grex(NULL),
initialized(false),
log(*new Log(comm)),
citations(*new Citations),
step(0),
active(false),
atoms(*new Atoms(*this)),
......@@ -48,6 +50,7 @@ PlumedMain::~PlumedMain(){
stopwatch.stop();
if(initialized) log<<stopwatch;
delete &actionSet;
delete &citations;
delete &atoms;
delete &log;
if(grex) delete grex;
......@@ -302,6 +305,10 @@ void PlumedMain::init(){
}
atoms.updateUnits();
log.printf("Timestep: %f\n",atoms.getTimeStep());
log<<"Relevant bibliography:\n";
log<<citations;
log<<"Please read and cite where appropriate!\n";
log<<"Finished setupt\n";
}
void PlumedMain::readInputFile(std::string str){
......@@ -537,6 +544,10 @@ int PlumedMain::fclose(FILE*fp){
return std::fclose(fp);
}
std::string PlumedMain::cite(const std::string&item){
return citations.cite(item);
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
......
......@@ -35,6 +35,7 @@ class ActionSet;
class DLLoader;
class PlumedCommunicator;
class Stopwatch;
class Citations;
/// Main plumed object.
/// In MD engines this object is not manipulated directly but it is wrapped in
......@@ -61,7 +62,8 @@ private:
std::string MDEngine;
/// Log stream
Log& log;
/// Citations holder
Citations& citations;
/// Present step number.
int step;
......@@ -94,6 +96,9 @@ public:
/// Flag to switch off virial calculation (for debug)
bool novirial;
/// Add a citation, returning a string containing the reference number, something like "[10]"
std::string cite(const std::string&);
public:
PlumedMain();
// this is to access to WithCmd versions of cmd (allowing overloading of a virtual method)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment