1 | /*
|
---|
2 | * PairCorrelationAction.cpp
|
---|
3 | *
|
---|
4 | * Created on: May 9, 2010
|
---|
5 | * Author: heber
|
---|
6 | */
|
---|
7 |
|
---|
8 | #include "Helpers/MemDebug.hpp"
|
---|
9 |
|
---|
10 | #include "Actions/AnalysisAction/PairCorrelationAction.hpp"
|
---|
11 | #include "analysis_correlation.hpp"
|
---|
12 | #include "boundary.hpp"
|
---|
13 | #include "linkedcell.hpp"
|
---|
14 | #include "verbose.hpp"
|
---|
15 | #include "log.hpp"
|
---|
16 | #include "element.hpp"
|
---|
17 | #include "molecule.hpp"
|
---|
18 | #include "periodentafel.hpp"
|
---|
19 | #include "vector.hpp"
|
---|
20 | #include "World.hpp"
|
---|
21 |
|
---|
22 | #include <iostream>
|
---|
23 | #include <string>
|
---|
24 |
|
---|
25 | using namespace std;
|
---|
26 |
|
---|
27 | #include "UIElements/UIFactory.hpp"
|
---|
28 | #include "UIElements/Dialog.hpp"
|
---|
29 | #include "Actions/MapOfActions.hpp"
|
---|
30 |
|
---|
31 | const char AnalysisPairCorrelationAction::NAME[] = "pair-correlation";
|
---|
32 |
|
---|
33 | AnalysisPairCorrelationAction::AnalysisPairCorrelationAction() :
|
---|
34 | Action(NAME)
|
---|
35 | {}
|
---|
36 |
|
---|
37 | AnalysisPairCorrelationAction::~AnalysisPairCorrelationAction()
|
---|
38 | {}
|
---|
39 |
|
---|
40 | Dialog* AnalysisPairCorrelationAction::createDialog() {
|
---|
41 | Dialog *dialog = UIFactory::getInstance().makeDialog();
|
---|
42 | int ranges[3] = {1, 1, 1};
|
---|
43 | double BinEnd = 0.;
|
---|
44 | double BinStart = 0.;
|
---|
45 | double BinWidth = 0.;
|
---|
46 | molecule *Boundary = NULL;
|
---|
47 | string outputname;
|
---|
48 | string binoutputname;
|
---|
49 | bool periodic;
|
---|
50 | ofstream output;
|
---|
51 | ofstream binoutput;
|
---|
52 | std::vector< element *> elements;
|
---|
53 | string type;
|
---|
54 | Vector Point;
|
---|
55 | BinPairMap *binmap = NULL;
|
---|
56 |
|
---|
57 | dialog->queryElement("elements", &elements, MapOfActions::getInstance().getDescription("elements"));
|
---|
58 | dialog->queryDouble("bin-start", &BinStart, MapOfActions::getInstance().getDescription("bin-start"));
|
---|
59 | dialog->queryDouble("bin-width", &BinWidth, MapOfActions::getInstance().getDescription("bin-width"));
|
---|
60 | dialog->queryDouble("bin-end", &BinEnd, MapOfActions::getInstance().getDescription("bin-end"));
|
---|
61 | dialog->queryString("output-file", &outputname, MapOfActions::getInstance().getDescription("output-file"));
|
---|
62 | dialog->queryString("bin-output-file", &binoutputname, MapOfActions::getInstance().getDescription("bin-output-file"));
|
---|
63 | dialog->queryBoolean("periodic", &periodic, MapOfActions::getInstance().getDescription("periodic"));
|
---|
64 |
|
---|
65 | return dialog;
|
---|
66 | }
|
---|
67 |
|
---|
68 | Action::state_ptr AnalysisPairCorrelationAction::performCall() {
|
---|
69 | int ranges[3] = {1, 1, 1};
|
---|
70 | double BinEnd = 0.;
|
---|
71 | double BinStart = 0.;
|
---|
72 | double BinWidth = 0.;
|
---|
73 | molecule *Boundary = NULL;
|
---|
74 | string outputname;
|
---|
75 | string binoutputname;
|
---|
76 | bool periodic;
|
---|
77 | ofstream output;
|
---|
78 | ofstream binoutput;
|
---|
79 | std::vector< element *> elements;
|
---|
80 | string type;
|
---|
81 | Vector Point;
|
---|
82 | BinPairMap *binmap = NULL;
|
---|
83 | MoleculeListClass *molecules = World::getInstance().getMolecules();
|
---|
84 |
|
---|
85 | // obtain information
|
---|
86 | MapOfActions::getInstance().queryCurrentValue("elements", elements);
|
---|
87 | MapOfActions::getInstance().queryCurrentValue("bin-start", BinStart);
|
---|
88 | MapOfActions::getInstance().queryCurrentValue("bin-width", BinWidth);
|
---|
89 | MapOfActions::getInstance().queryCurrentValue("bin-end", BinEnd);
|
---|
90 | MapOfActions::getInstance().queryCurrentValue("output-file", outputname);
|
---|
91 | MapOfActions::getInstance().queryCurrentValue("bin-output-file", binoutputname);
|
---|
92 | MapOfActions::getInstance().queryCurrentValue("periodic", periodic);
|
---|
93 |
|
---|
94 | // execute action
|
---|
95 | output.open(outputname.c_str());
|
---|
96 | binoutput.open(binoutputname.c_str());
|
---|
97 | PairCorrelationMap *correlationmap = NULL;
|
---|
98 | if (periodic)
|
---|
99 | correlationmap = PeriodicPairCorrelation(World::getInstance().getMolecules(), elements, ranges);
|
---|
100 | else
|
---|
101 | correlationmap = PairCorrelation(World::getInstance().getMolecules(), elements);
|
---|
102 | OutputPairCorrelation(&output, correlationmap);
|
---|
103 | binmap = BinData( correlationmap, BinWidth, BinStart, BinEnd );
|
---|
104 | OutputCorrelation ( &binoutput, binmap );
|
---|
105 | delete(binmap);
|
---|
106 | delete(correlationmap);
|
---|
107 | output.close();
|
---|
108 | binoutput.close();
|
---|
109 | return Action::success;
|
---|
110 | }
|
---|
111 |
|
---|
112 | Action::state_ptr AnalysisPairCorrelationAction::performUndo(Action::state_ptr _state) {
|
---|
113 | return Action::success;
|
---|
114 | }
|
---|
115 |
|
---|
116 | Action::state_ptr AnalysisPairCorrelationAction::performRedo(Action::state_ptr _state){
|
---|
117 | return Action::success;
|
---|
118 | }
|
---|
119 |
|
---|
120 | bool AnalysisPairCorrelationAction::canUndo() {
|
---|
121 | return true;
|
---|
122 | }
|
---|
123 |
|
---|
124 | bool AnalysisPairCorrelationAction::shouldUndo() {
|
---|
125 | return true;
|
---|
126 | }
|
---|
127 |
|
---|
128 | const string AnalysisPairCorrelationAction::getName() {
|
---|
129 | return NAME;
|
---|
130 | }
|
---|