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

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

Properties

Name Value
svn:eol-style native