Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/builder.cpp

    r39af9f rc78d44  
    15551555              performCriticalExit();
    15561556            } else {
    1557               ArgcList.insert(argptr-1);
    1558               ArgcList.insert(argptr);
     1557              DoLog(0) && (Log() << Verbose(0) << "Using " << argv[argptr] << " as elements database." << endl);
     1558              strncpy (configuration.databasepath, argv[argptr], MAXSTRINGSIZE-1);
     1559              DatabasePathGiven = true;
    15591560              argptr+=1;
    15601561            }
     
    15651566              performCriticalExit();
    15661567            } else {
    1567               ArgcList.insert(argptr-1);
    1568               ArgcList.insert(argptr);
     1568              BondGraphFileName = argv[argptr];
     1569              DoLog(0) && (Log() << Verbose(0) << "Using " << BondGraphFileName << " as bond length table." << endl);
    15691570              argptr+=1;
    15701571            }
     
    16001601
    16011602    // 3a. Parse the element database
    1602 //    if (DatabasePathGiven)
    1603 //      if (periode->LoadPeriodentafel(configuration.databasepath)) {
    1604 //        DoLog(0) && (Log() << Verbose(0) << "Element list loaded successfully." << endl);
    1605 //        //periode->Output();
    1606 //      } else {
    1607 //        DoLog(0) && (Log() << Verbose(0) << "Element list loading failed." << endl);
    1608 //        return 1;
    1609 //      }
     1603    if (DatabasePathGiven)
     1604      if (periode->LoadPeriodentafel(configuration.databasepath)) {
     1605        DoLog(0) && (Log() << Verbose(0) << "Element list loaded successfully." << endl);
     1606        //periode->Output();
     1607      } else {
     1608        DoLog(0) && (Log() << Verbose(0) << "Element list loading failed." << endl);
     1609        return 1;
     1610      }
    16101611    // 3b. Find config file name and parse if possible, also BondGraphFileName
    16111612    if (argv[1][0] != '-') {
     
    17621763                  switch(argv[argptr][0]) {
    17631764                    case 'E':
    1764                       ArgcList.insert(argptr-1);
    1765                       ArgcList.insert(argptr);
    1766                       ArgcList.insert(argptr+1);
    1767                       ArgcList.insert(argptr+2);
    1768                       ArgcList.insert(argptr+3);
    1769                       ArgcList.insert(argptr+4);
    1770                       ArgcList.insert(argptr+5);
    1771                       ArgcList.insert(argptr+6);
    1772                       ArgcList.insert(argptr+7);
    1773                       ArgcList.insert(argptr+8);
    1774                       ArgcList.insert(argptr+9);
    1775                       ArgcList.insert(argptr+10);
    1776                       ArgcList.insert(argptr+11);
    1777                       argptr+=12;
     1765                      {
     1766                        if ((argptr+6 >= argc) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+5])) || (!IsValidNumber(argv[argptr+6])) || (!IsValidNumber(argv[argptr+2])) || (argv[argptr+1][0] == '-') || (argv[argptr+2][0] == '-') || (argv[argptr+3][0] == '-') || (argv[argptr+4][0] == '-')) {
     1767                          ExitFlag = 255;
     1768                          DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for pair correlation analysis: -C E <Z1> <Z2> <output> <bin output> <binstart> <binend>" << endl);
     1769                          performCriticalExit();
     1770                        } else {
     1771                          ofstream output(argv[argptr+3]);
     1772                          ofstream binoutput(argv[argptr+4]);
     1773                          const double BinStart = atof(argv[argptr+5]);
     1774                          const double BinEnd = atof(argv[argptr+6]);
     1775
     1776                          std::vector<element *> elements;
     1777                          elements.push_back(periode->FindElement((const int) atoi(argv[argptr+1])));
     1778                          elements.push_back(periode->FindElement((const int) atoi(argv[argptr+2])));
     1779                          PairCorrelationMap *correlationmap = NULL;
     1780                          if (periodic)
     1781                            correlationmap = PeriodicPairCorrelation(molecules, elements, ranges);
     1782                          else
     1783                            correlationmap = PairCorrelation(molecules, elements);
     1784                          OutputPairCorrelation(&output, correlationmap);
     1785                          BinPairMap *binmap = BinData( correlationmap, 0.5, BinStart, BinEnd );
     1786                          OutputCorrelation ( &binoutput, binmap );
     1787                          output.close();
     1788                          binoutput.close();
     1789                          delete(binmap);
     1790                          delete(correlationmap);
     1791                          argptr+=7;
     1792                        }
     1793                      }
    17781794                      break;
    17791795
    17801796                    case 'P':
    1781                       ArgcList.insert(argptr-1);
    1782                       ArgcList.insert(argptr);
    1783                       ArgcList.insert(argptr+1);
    1784                       ArgcList.insert(argptr+2);
    1785                       ArgcList.insert(argptr+3);
    1786                       ArgcList.insert(argptr+4);
    1787                       ArgcList.insert(argptr+5);
    1788                       ArgcList.insert(argptr+6);
    1789                       ArgcList.insert(argptr+7);
    1790                       ArgcList.insert(argptr+8);
    1791                       ArgcList.insert(argptr+9);
    1792                       ArgcList.insert(argptr+10);
    1793                       ArgcList.insert(argptr+11);
    1794                       ArgcList.insert(argptr+12);
    1795                       ArgcList.insert(argptr+13);
    1796                       ArgcList.insert(argptr+14);
    1797                       argptr+=15;
     1797                      {
     1798                        if ((argptr+8 >= argc) || (!IsValidNumber(argv[argptr+1])) ||  (!IsValidNumber(argv[argptr+2])) || (!IsValidNumber(argv[argptr+3])) || (!IsValidNumber(argv[argptr+4])) || (!IsValidNumber(argv[argptr+7])) || (!IsValidNumber(argv[argptr+8])) || (argv[argptr+1][0] == '-') || (argv[argptr+2][0] == '-') || (argv[argptr+3][0] == '-') || (argv[argptr+4][0] == '-') || (argv[argptr+5][0] == '-') || (argv[argptr+6][0] == '-')) {
     1799                          ExitFlag = 255;
     1800                          DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for pair correlation analysis: -C P <Z1> <x> <y> <z> <output> <bin output> <binstart> <binend>" << endl);
     1801                          performCriticalExit();
     1802                        } else {
     1803                          ofstream output(argv[argptr+5]);
     1804                          ofstream binoutput(argv[argptr+6]);
     1805                          const double BinStart = atof(argv[argptr+7]);
     1806                          const double BinEnd = atof(argv[argptr+8]);
     1807
     1808                          std::vector<element *> elements;
     1809                          elements.push_back(periode->FindElement((const int) atoi(argv[argptr+1])));
     1810                          Vector *Point = new Vector((const double) atof(argv[argptr+1]),(const double) atof(argv[argptr+2]),(const double) atof(argv[argptr+3]));
     1811                          CorrelationToPointMap *correlationmap = NULL;
     1812                          if (periodic)
     1813                            correlationmap  = PeriodicCorrelationToPoint(molecules, elements, Point, ranges);
     1814                          else
     1815                            correlationmap = CorrelationToPoint(molecules, elements, Point);
     1816                          OutputCorrelationToPoint(&output, correlationmap);
     1817                          BinPairMap *binmap = BinData( correlationmap, 0.5, BinStart, BinEnd );
     1818                          OutputCorrelation ( &binoutput, binmap );
     1819                          output.close();
     1820                          binoutput.close();
     1821                          delete(Point);
     1822                          delete(binmap);
     1823                          delete(correlationmap);
     1824                          argptr+=9;
     1825                        }
     1826                      }
    17981827                      break;
    17991828
    18001829                    case 'S':
    1801                       ArgcList.insert(argptr-1);
    1802                       ArgcList.insert(argptr);
    1803                       ArgcList.insert(argptr+1);
    1804                       ArgcList.insert(argptr+2);
    1805                       ArgcList.insert(argptr+3);
    1806                       ArgcList.insert(argptr+4);
    1807                       ArgcList.insert(argptr+5);
    1808                       ArgcList.insert(argptr+6);
    1809                       ArgcList.insert(argptr+7);
    1810                       ArgcList.insert(argptr+8);
    1811                       ArgcList.insert(argptr+9);
    1812                       ArgcList.insert(argptr+10);
    1813                       ArgcList.insert(argptr+11);
    1814                       ArgcList.insert(argptr+12);
    1815                       ArgcList.insert(argptr+13);
    1816                       ArgcList.insert(argptr+14);
    1817                       argptr+=15;
     1830                      {
     1831                        if ((argptr+6 >= argc) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+4])) || (!IsValidNumber(argv[argptr+5])) || (!IsValidNumber(argv[argptr+6])) || (argv[argptr+1][0] == '-') || (argv[argptr+2][0] == '-') || (argv[argptr+3][0] == '-')) {
     1832                          ExitFlag = 255;
     1833                          DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for pair correlation analysis: -C S <Z> <output> <bin output> <BinWidth> <BinStart> <BinEnd>" << endl);
     1834                          performCriticalExit();
     1835                        } else {
     1836                          ofstream output(argv[argptr+2]);
     1837                          ofstream binoutput(argv[argptr+3]);
     1838                          const double radius = 4.;
     1839                          const double BinWidth = atof(argv[argptr+4]);
     1840                          const double BinStart = atof(argv[argptr+5]);
     1841                          const double BinEnd = atof(argv[argptr+6]);
     1842                          double LCWidth = 20.;
     1843                          if (BinEnd > 0) {
     1844                            if (BinEnd > 2.*radius)
     1845                                LCWidth = BinEnd;
     1846                            else
     1847                              LCWidth = 2.*radius;
     1848                          }
     1849
     1850                          // get the boundary
     1851                          class molecule *Boundary = NULL;
     1852                          class Tesselation *TesselStruct = NULL;
     1853                          const LinkedCell *LCList = NULL;
     1854                          // find biggest molecule
     1855                          int counter  = 0;
     1856                          for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) {
     1857                            if ((Boundary == NULL) || (Boundary->getAtomCount() < (*BigFinder)->getAtomCount())) {
     1858                              Boundary = *BigFinder;
     1859                            }
     1860                            counter++;
     1861                          }
     1862                          bool *Actives = new bool[counter];
     1863                          counter = 0;
     1864                          for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) {
     1865                            Actives[counter++] = (*BigFinder)->ActiveFlag;
     1866                            (*BigFinder)->ActiveFlag = (*BigFinder == Boundary) ? false : true;
     1867                          }
     1868                          LCList = new LinkedCell(Boundary, LCWidth);
     1869                          std::vector<element *> elements;
     1870                          elements.push_back(periode->FindElement((const int) atoi(argv[argptr+1])));
     1871                          FindNonConvexBorder(Boundary, TesselStruct, LCList, radius, NULL);
     1872                          CorrelationToSurfaceMap *surfacemap = NULL;
     1873                          if (periodic)
     1874                            surfacemap = PeriodicCorrelationToSurface( molecules, elements, TesselStruct, LCList, ranges);
     1875                          else
     1876                            surfacemap = CorrelationToSurface( molecules, elements, TesselStruct, LCList);
     1877                          OutputCorrelationToSurface(&output, surfacemap);
     1878                          // check whether radius was appropriate
     1879                          {
     1880                            double start; double end;
     1881                            GetMinMax( surfacemap, start, end);
     1882                            if (LCWidth < end)
     1883                              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);
     1884                          }
     1885                          BinPairMap *binmap = BinData( surfacemap, BinWidth, BinStart, BinEnd );
     1886                          OutputCorrelation ( &binoutput, binmap );
     1887                          output.close();
     1888                          binoutput.close();
     1889                          counter = 0;
     1890                          for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++)
     1891                            (*BigFinder)->ActiveFlag = Actives[counter++];
     1892                          delete[](Actives);
     1893                          delete(LCList);
     1894                          delete(TesselStruct);
     1895                          delete(binmap);
     1896                          delete(surfacemap);
     1897                          argptr+=7;
     1898                        }
     1899                      }
    18181900                      break;
    18191901
     
    21552237                SaveFlag = true;
    21562238                DoLog(0) && (Log() << Verbose(0) << "Converting to prinicipal axis system." << endl);
    2157                 mol->PrincipalAxisSystem((bool)j);
    21582239              } else
    2159                 ArgcList.insert(argptr-1);
    2160                 argptr+=0;
     2240                DoLog(0) && (Log() << Verbose(0) << "Evaluating prinicipal axis." << endl);
     2241              mol->PrincipalAxisSystem((bool)j);
    21612242              break;
    21622243            case 'o':
     
    23142395      // handle remaining arguments by CommandLineParser
    23152396      MapOfActions::getInstance().AddOptionsToParser();
    2316       map <std::string, std::string> ShortFormToActionMap = MapOfActions::getInstance().getShortFormToActionMap();
    2317       CommandLineParser::getInstance().Run(ArgcSize,Arguments, ShortFormToActionMap);
     2397      CommandLineParser::getInstance().Run(ArgcSize,Arguments);
    23182398      if (!CommandLineParser::getInstance().isEmpty()) {
    23192399        DoLog(0) && (Log() << Verbose(0) << "Setting UI to CommandLine." << endl);
Note: See TracChangeset for help on using the changeset viewer.