Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/AnalysisAction/PairCorrelationAction.cpp

    r623e89 r112b09  
    66 */
    77
     8#include "Helpers/MemDebug.hpp"
     9
    810#include "Actions/AnalysisAction/PairCorrelationAction.hpp"
     11#include "CommandLineParser.hpp"
    912#include "analysis_correlation.hpp"
    10 #include "boundary.hpp"
    11 #include "linkedcell.hpp"
    1213#include "log.hpp"
    1314#include "element.hpp"
    14 #include "molecule.hpp"
    1515#include "periodentafel.hpp"
    16 #include "vector.hpp"
    1716#include "World.hpp"
    1817
     
    3837  Dialog *dialog = UIFactory::getInstance().makeDialog();
    3938  int ranges[3] = {1, 1, 1};
     39  double BinStart = 0.;
    4040  double BinEnd = 0.;
    41   double BinStart = 0.;
    42   double BinWidth = 0.;
    43   molecule *Boundary = NULL;
    4441  string outputname;
    4542  string binoutputname;
     
    4744  ofstream output;
    4845  ofstream binoutput;
    49   std::vector< element *> elements;
    50   string type;
    51   Vector Point;
    52   BinPairMap *binmap = NULL;
    53   MoleculeListClass *molecules = World::getInstance().getMolecules();
     46  const element *elemental1;
     47  const element *elemental2;
    5448
    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"));
     49  dialog->queryElement("elements", &elemental1, MapOfActions::getInstance().getDescription("elements"));
     50  dialog->queryElement("elements", &elemental2, MapOfActions::getInstance().getDescription("elements"));
    7151  dialog->queryDouble("bin-start", &BinStart, MapOfActions::getInstance().getDescription("bin-start"));
    72   dialog->queryDouble("bin-width", &BinWidth, MapOfActions::getInstance().getDescription("bin-width"));
    7352  dialog->queryDouble("bin-end", &BinEnd, MapOfActions::getInstance().getDescription("bin-end"));
    7453  dialog->queryString("output-file", &outputname, MapOfActions::getInstance().getDescription("output-file"));
     
    8059    binoutput.open(binoutputname.c_str());
    8160    PairCorrelationMap *correlationmap = NULL;
    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;
     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 );
    13967    OutputCorrelation ( &binoutput, binmap );
    14068    output.close();
Note: See TracChangeset for help on using the changeset viewer.