ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/src/optimization/StatusFunction.hpp
Revision: 1750
Committed: Thu Jun 7 12:53:46 2012 UTC (12 years, 10 months ago) by gezelter
File size: 1569 byte(s)
Log Message:
Fixing some bugs in optimization, fixing status functions so that they
dump correctly (although some things are deferred until the Stats is
accumulator-based).

File Contents

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

Properties

Name Value
svn:eol-style native