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