19#include <boost/algorithm/string/trim.hpp>
42 " atomistic topology file");
47 "cg", boost::program_options::value<std::string>(),
48 " coarse graining mapping and bond definitions (xml-file)")(
49 "map-ignore", boost::program_options::value<std::string>(),
50 " list of molecules to ignore separated by ;")(
"no-map",
52 "and act on original "
56 "cg", boost::program_options::value<std::string>(),
57 " [OPTIONAL] coarse graining mapping and bond definitions\n"
58 " (xml-file). If no file is given, program acts on original "
60 "map-ignore", boost::program_options::value<std::string>(),
61 " list of molecules to ignore if mapping is done separated by ;");
67 "trj", boost::program_options::value<std::string>(),
68 " atomistic trajectory file")(
69 "begin", boost::program_options::value<double>()->default_value(0.0),
70 " skip frames before this time (only works for Gromacs files)")(
71 "first-frame", boost::program_options::value<Index>()->default_value(0),
72 " start with this frame")(
"nframes",
73 boost::program_options::value<Index>(),
74 " process the given number of frames");
82 "nt", boost::program_options::value<Index>()->default_value(1),
83 " number of threads");
99 CheckRequired(
"cg",
"no coarse graining definition specified");
104 throw std::runtime_error(
105 "no-map and cg options are mutually exclusive!");
151 id = worker->
getId();
180 if (worker->
getId() == 0) {
191 worker->
map_->Apply();
202 std::unique_ptr<TopologyReader> reader =
204 if (reader ==
nullptr) {
205 throw std::runtime_error(std::string(
"input format not supported: ") +
209 class DummyWorker :
public Worker {
220 myWorkers_.emplace_back(std::make_unique<DummyWorker>());
231 reader->ReadTopology(
OptionsMap()[
"top"].as<std::string>(), master->
top_);
235 std::cout <<
"I have " << master->
top_.
BeadCount() <<
" beads in "
246 for (std::string str : tok) {
248 if (str.length() > 0) {
258 <<
" molecules for the coarsegraining" << std::endl;
266 master->
map_->Apply();
281 bool has_begin =
false;
299 throw std::runtime_error(std::string(
"input format not supported: ") +
316 reader->ReadTopology(
OptionsMap()[
"top"].as<std::string>(),
318 myWorkers_.back()->top_.CheckMoleculeNaming();
334 <<
"NOTE: You are using OpenBox boundary conditions. Check if this "
340 for (bok =
true; bok ==
true; bok =
traj_reader_->NextFrame(master->
top_)) {
341 if ((has_begin && (master->
top_.
getTime() < begin)) || first_frame > 1) {
351 throw std::runtime_error(
352 "trajectory was too short, did not process a single frame");
357 master->
map_->Apply();
367 for (
size_t thread = 0; thread <
myWorkers_.size(); thread++) {
391 myWorker->WaitDone();
415 ob->BeginCG(top, top_ref);
427 ob->EvalConfiguration(top, top_ref);
432 throw std::runtime_error(
"ForkWorker not implemented in application");
437 throw std::runtime_error(
"MergeWorker not implemented in application");
std::unique_ptr< TopologyMap > CreateCGTopology(const Topology &in, Topology &out)
void AddIgnore(const std::string &pattern)
ignores molecule in mapping process
void LoadMoleculeType(const std::string &filename)
Observer class for analysis hook.
Worker, derived from Thread, does the work.
virtual void EvalConfiguration(Topology *top, Topology *top_ref=nullptr)=0
overload with the actual computation
std::unique_ptr< TopologyMap > map_
Index getId()
returns worker id
void Run(void) override
Run() executes the actual code.
virtual bool DoMapping(void)
overload and return true to enable mapping command line options
virtual bool EvaluateTopology(Topology *, Topology *=nullptr)
called after topology was loaded
std::vector< std::unique_ptr< tools::Mutex > > threadsMutexesIn_
stores Mutexes used to impose order for input
void ShowHelpText(std::ostream &out) override
bool EvaluateOptions() override
Process command line options.
virtual bool SynchronizeThreads(void)
virtual void EndEvaluate()
called after the last frame
void Initialize() override
Initialize application data.
std::list< CGObserver * > observers_
virtual void MergeWorker(Worker *worker)
virtual void BeginEvaluate(Topology *top, Topology *top_ref=nullptr)
called before the first frame
virtual bool DoMappingDefault(void)
if DoMapping is true, will by default require mapping or not
virtual bool DoTrajectory(void)
overload and return true to enable trajectory command line options
bool ProcessData(Worker *worker)
Gets frames from TrajectoryReader in an ordered way and, if successful, calls Worker::EvalConfigurati...
virtual bool NeedsTopology(void)
if topology is always needed
virtual std::unique_ptr< Worker > ForkWorker(void)
virtual void EvalConfiguration(Topology *top, Topology *top_ref=nullptr)
std::vector< std::unique_ptr< tools::Mutex > > threadsMutexesOut_
stores Mutexes used to impose order for output
tools::Mutex traj_readerMutex_
std::vector< std::unique_ptr< Worker > > myWorkers_
std::unique_ptr< TrajectoryReader > traj_reader_
void Run(void) override
Main body of application.
virtual bool DoThreaded(void)
static void RegisterPlugins(void)
topology of the whole system
BoundaryCondition::eBoxtype getBoxType() const
void setBox(const Eigen::Matrix3d &box, BoundaryCondition::eBoxtype boxtype=BoundaryCondition::typeAuto)
Index MoleculeCount() const
number of molecules in the system
const Eigen::Matrix3d & getBox() const
void CheckMoleculeNaming(void)
checks weather molecules with the same name really contain the same number of beads
static void RegisterPlugins(void)
static void RegisterPlugins(void)
FileFormatFactory< TopologyReader > & TopReaderFactory()
void HelpTextHeader(const std::string &tool_name)
FileFormatFactory< TrajectoryReader > & TrjReaderFactory()
base class for all analysis tools