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

# 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     #include "io/StatWriter.hpp"
6    
7     namespace OpenMD {
8     class StatusFunction {
9     public:
10     virtual ~StatusFunction() {}
11 gezelter 1750 virtual void writeStatus(int functionCount, int gradientCount, const DynamicVector<RealType>& x, RealType f) { std::cerr << "doing status\n"; }
12 gezelter 1741 };
13    
14     //! No status
15     class NoStatus : public StatusFunction {
16     public:
17 gezelter 1750 virtual void writeStatus(int functionCount, int gradientCount, const DynamicVector<RealType>& x, RealType f) {};
18 gezelter 1741 };
19    
20     class DumpStatusFunction : public StatusFunction {
21    
22     public:
23 gezelter 1750 DumpStatusFunction(SimInfo* info) : StatusFunction(), info_(info), thermo(info) {
24 gezelter 1741 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 gezelter 1750 virtual void writeStatus(int functionCount, int gradientCount, const DynamicVector<RealType>& x, RealType f) {
31 gezelter 1741 Snapshot* curSnapshot =info_->getSnapshotManager()->getCurrentSnapshot();
32 gezelter 1750 thermo.saveStat();
33     curSnapshot->setTime(functionCount);
34 gezelter 1741 dumpWriter->writeDumpAndEor();
35     statWriter->writeStat(curSnapshot->statData);
36     }
37 gezelter 1750 ~DumpStatusFunction() {
38     delete dumpWriter;
39     delete statWriter;
40     }
41 gezelter 1741
42     private:
43     SimInfo* info_;
44     DumpWriter* dumpWriter;
45     StatWriter* statWriter;
46 gezelter 1750 Thermo thermo;
47 gezelter 1741 };
48    
49    
50     }
51     #endif

Properties

Name Value
svn:eol-style native