- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/AnalysisAction/PairCorrelationAction.cpp
r112b09 r623e89 6 6 */ 7 7 8 #include "Helpers/MemDebug.hpp"9 10 8 #include "Actions/AnalysisAction/PairCorrelationAction.hpp" 11 #include "CommandLineParser.hpp"12 9 #include "analysis_correlation.hpp" 10 #include "boundary.hpp" 11 #include "linkedcell.hpp" 13 12 #include "log.hpp" 14 13 #include "element.hpp" 14 #include "molecule.hpp" 15 15 #include "periodentafel.hpp" 16 #include "vector.hpp" 16 17 #include "World.hpp" 17 18 … … 37 38 Dialog *dialog = UIFactory::getInstance().makeDialog(); 38 39 int ranges[3] = {1, 1, 1}; 40 double BinEnd = 0.; 39 41 double BinStart = 0.; 40 double BinEnd = 0.; 42 double BinWidth = 0.; 43 molecule *Boundary = NULL; 41 44 string outputname; 42 45 string binoutputname; … … 44 47 ofstream output; 45 48 ofstream binoutput; 46 const element *elemental1; 47 const element *elemental2; 49 std::vector< element *> elements; 50 string type; 51 Vector Point; 52 BinPairMap *binmap = NULL; 53 MoleculeListClass *molecules = World::getInstance().getMolecules(); 48 54 49 dialog->queryElement("elements", &elemental1, MapOfActions::getInstance().getDescription("elements")); 50 dialog->queryElement("elements", &elemental2, MapOfActions::getInstance().getDescription("elements")); 55 // first dialog: Obtain which type of correlation 56 dialog->queryString(NAME, &type, MapOfActions::getInstance().getDescription(NAME)); 57 if(dialog->display()) { 58 delete dialog; 59 } else { 60 delete dialog; 61 return Action::failure; 62 } 63 64 // second dialog: Obtain parameters specific to this type 65 dialog = UIFactory::getInstance().makeDialog(); 66 if (type == "P") 67 dialog->queryVector("position", &Point, World::getInstance().getDomain(), false, MapOfActions::getInstance().getDescription("position")); 68 if (type == "S") 69 dialog->queryMolecule("molecule-by-id", &Boundary, MapOfActions::getInstance().getDescription("molecule-by-id")); 70 dialog->queryElement("elements", &elements, MapOfActions::getInstance().getDescription("elements")); 51 71 dialog->queryDouble("bin-start", &BinStart, MapOfActions::getInstance().getDescription("bin-start")); 72 dialog->queryDouble("bin-width", &BinWidth, MapOfActions::getInstance().getDescription("bin-width")); 52 73 dialog->queryDouble("bin-end", &BinEnd, MapOfActions::getInstance().getDescription("bin-end")); 53 74 dialog->queryString("output-file", &outputname, MapOfActions::getInstance().getDescription("output-file")); … … 59 80 binoutput.open(binoutputname.c_str()); 60 81 PairCorrelationMap *correlationmap = NULL; 61 if (periodic) 62 correlationmap = PeriodicPairCorrelation(World::getInstance().getMolecules(), elemental1, elemental2, ranges); 63 else 64 correlationmap = PairCorrelation(World::getInstance().getMolecules(), elemental1, elemental2); 65 //OutputCorrelationToSurface(&output, correlationmap); 66 BinPairMap *binmap = BinData( correlationmap, 0.5, BinStart, BinEnd ); 82 if (type == "E") { 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 //OutputCorrelationToSurface(&output, correlationmap); 89 binmap = BinData( correlationmap, BinWidth, BinStart, BinEnd ); 90 } else if (type == "P") { 91 cout << "Point to correlate to is " << Point << endl; 92 CorrelationToPointMap *correlationmap = NULL; 93 if (periodic) 94 correlationmap = PeriodicCorrelationToPoint(molecules, elements, &Point, ranges); 95 else 96 correlationmap = CorrelationToPoint(molecules, elements, &Point); 97 //OutputCorrelationToSurface(&output, correlationmap); 98 binmap = BinData( correlationmap, BinWidth, BinStart, BinEnd ); 99 } else if (type == "S") { 100 ASSERT(Boundary != NULL, "No molecule specified for SurfaceCorrelation."); 101 const double radius = 4.; 102 double LCWidth = 20.; 103 if (BinEnd > 0) { 104 if (BinEnd > 2.*radius) 105 LCWidth = BinEnd; 106 else 107 LCWidth = 2.*radius; 108 } 109 110 // get the boundary 111 class Tesselation *TesselStruct = NULL; 112 const LinkedCell *LCList = NULL; 113 // find biggest molecule 114 int counter = molecules->ListOfMolecules.size(); 115 bool *Actives = new bool[counter]; 116 counter = 0; 117 for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) { 118 Actives[counter++] = (*BigFinder)->ActiveFlag; 119 (*BigFinder)->ActiveFlag = (*BigFinder == Boundary) ? false : true; 120 } 121 LCList = new LinkedCell(Boundary, LCWidth); 122 FindNonConvexBorder(Boundary, TesselStruct, LCList, radius, NULL); 123 CorrelationToSurfaceMap *surfacemap = NULL; 124 if (periodic) 125 surfacemap = PeriodicCorrelationToSurface( molecules, elements, TesselStruct, LCList, ranges); 126 else 127 surfacemap = CorrelationToSurface( molecules, elements, TesselStruct, LCList); 128 OutputCorrelationToSurface(&output, surfacemap); 129 // check whether radius was appropriate 130 { 131 double start; double end; 132 GetMinMax( surfacemap, start, end); 133 if (LCWidth < end) 134 DoeLog(1) && (eLog()<< Verbose(1) << "Linked Cell width is smaller than the found range of values! Bins can only be correct up to: " << radius << "." << endl); 135 } 136 binmap = BinData( surfacemap, BinWidth, BinStart, BinEnd ); 137 } else 138 return Action::failure; 67 139 OutputCorrelation ( &binoutput, binmap ); 68 140 output.close();
Note:
See TracChangeset
for help on using the changeset viewer.