ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/src/optimization/StatusFunction.hpp
Revision: 1764
Committed: Tue Jul 3 18:32:27 2012 UTC (12 years, 9 months ago) by gezelter
File size: 1644 byte(s)
Log Message:
Refactored Snapshot and Stats to use the Accumulator classes.  Collected
a number of methods into Thermo that belonged there.

File Contents

# Content
1 #ifndef OPTIMIZATION_STATUSFUNCTION_HPP
2 #define OPTIMIZATION_STATUSFUNCTION_HPP
3 #include "config.h"
4 #include "io/DumpWriter.hpp"
5 #include "brains/Stats.hpp"
6 #include "io/StatWriter.hpp"
7
8 namespace OpenMD {
9 class StatusFunction {
10 public:
11 virtual ~StatusFunction() {}
12 virtual void writeStatus(int functionCount, int gradientCount, const DynamicVector<RealType>& x, RealType f) { std::cerr << "doing status\n"; }
13 };
14
15 //! No status
16 class NoStatus : public StatusFunction {
17 public:
18 virtual void writeStatus(int functionCount, int gradientCount, const DynamicVector<RealType>& x, RealType f) {};
19 };
20
21 class DumpStatusFunction : public StatusFunction {
22
23 public:
24 DumpStatusFunction(SimInfo* info) : StatusFunction(), info_(info) {
25 stats = new Stats(info_);
26 dumpWriter = new DumpWriter(info_);
27 Stats::StatsBitSet mask;
28 mask.set(Stats::TIME);
29 mask.set(Stats::POTENTIAL_ENERGY);
30 stats->setStatsMask(mask);
31 statWriter = new StatWriter(info_->getStatFileName(), stats);
32 }
33 virtual void writeStatus(int functionCount, int gradientCount, const DynamicVector<RealType>& x, RealType f) {
34 Snapshot* curSnapshot =info_->getSnapshotManager()->getCurrentSnapshot();
35 curSnapshot->setTime(functionCount);
36
37 stats->collectStats();
38 statWriter->writeStat();
39
40 dumpWriter->writeDumpAndEor();
41 }
42 ~DumpStatusFunction() {
43 delete dumpWriter;
44 delete statWriter;
45 }
46
47 private:
48 SimInfo* info_;
49 Stats* stats;
50 DumpWriter* dumpWriter;
51 StatWriter* statWriter;
52 };
53
54
55 }
56 #endif

Properties

Name Value
svn:eol-style native