Changeset 9879f6 for src/config.cpp


Ignore:
Timestamp:
Mar 5, 2010, 10:16:47 AM (16 years ago)
Author:
Frederik Heber <heber@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, Candidate_v1.7.0, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
Children:
d3347e
Parents:
e87acf
git-author:
Frederik Heber <heber@…> (03/05/10 10:08:44)
git-committer:
Frederik Heber <heber@…> (03/05/10 10:16:47)
Message:

Huge Refactoring due to class molecule now being an STL container.

  • molecule::start and molecule::end were dropped. Hence, the usual construct Walker = start while (Walker->next != end) {

Walker = walker->next
...

}
was changed to
for (molecule::iterator iter = begin(); iter != end(); ++iter) {

...

}
and (*iter) used instead of Walker.

  • Two build errors remain (beside some more in folder Actions, Patterns and unittest) in molecule_pointcloud.cpp and molecule.cpp
  • lists.cpp was deleted as specialization of atom* was not needed anymore
  • link, unlink, add, remove, removewithoutcheck all are not needed for atoms anymore, just for bonds (where first, last entries remain in molecule)
  • CreateFatherLookupTable() was put back into class molecule.
  • molecule::InternalPointer is now an iterator
  • class PointCloud: GoToPrevious() and GetTerminalPoint() were dropped as not needed.
  • some new STL functions in class molecule: size(), empty(), erase(), find() and insert()
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/config.cpp

    re87acf r9879f6  
    15421542  int AtomNo = -1;
    15431543  int MolNo = 0;
    1544   atom *Walker = NULL;
    15451544  FILE *f = NULL;
    15461545
     
    15551554  fprintf(f, "# Created by MoleCuilder\n");
    15561555
    1557   for (MoleculeList::const_iterator Runner = MolList->ListOfMolecules.begin(); Runner != MolList->ListOfMolecules.end(); Runner++) {
    1558     Walker = (*Runner)->start;
     1556  for (MoleculeList::const_iterator MolRunner = MolList->ListOfMolecules.begin(); MolRunner != MolList->ListOfMolecules.end(); MolRunner++) {
    15591557    int *elementNo = Calloc<int>(MAX_ELEMENTS, "config::SavePDB - elementNo");
    15601558    AtomNo = 0;
    1561     while (Walker->next != (*Runner)->end) {
    1562       Walker = Walker->next;
    1563       sprintf(name, "%2s%2d",Walker->type->symbol, elementNo[Walker->type->Z]);
    1564       elementNo[Walker->type->Z] = (elementNo[Walker->type->Z]+1) % 100;   // confine to two digits
     1559    for (molecule::const_iterator iter = (*MolRunner)->begin(); iter != (*MolRunner)->end(); ++iter) {
     1560      sprintf(name, "%2s%2d",(*iter)->type->symbol, elementNo[(*iter)->type->Z]);
     1561      elementNo[(*iter)->type->Z] = (elementNo[(*iter)->type->Z]+1) % 100;   // confine to two digits
    15651562      fprintf(f,
    15661563             "ATOM %6u %-4s %4s%c%4u    %8.3f%8.3f%8.3f%6.2f%6.2f      %4s%2s%2s\n",
    1567              Walker->nr,                /* atom serial number */
     1564             (*iter)->nr,                /* atom serial number */
    15681565             name,         /* atom name */
    1569              (*Runner)->name,      /* residue name */
     1566             (*MolRunner)->name,      /* residue name */
    15701567             'a'+(unsigned char)(AtomNo % 26),           /* letter for chain */
    15711568             MolNo,         /* residue sequence number */
    1572              Walker->node->x[0],                 /* position X in Angstroem */
    1573              Walker->node->x[1],                 /* position Y in Angstroem */
    1574              Walker->node->x[2],                 /* position Z in Angstroem */
    1575              (double)Walker->type->Valence,         /* occupancy */
    1576              (double)Walker->type->NoValenceOrbitals,          /* temperature factor */
     1569             (*iter)->node->x[0],                 /* position X in Angstroem */
     1570             (*iter)->node->x[1],                 /* position Y in Angstroem */
     1571             (*iter)->node->x[2],                 /* position Z in Angstroem */
     1572             (double)(*iter)->type->Valence,         /* occupancy */
     1573             (double)(*iter)->type->NoValenceOrbitals,          /* temperature factor */
    15771574             "0",            /* segment identifier */
    1578              Walker->type->symbol,    /* element symbol */
     1575             (*iter)->type->symbol,    /* element symbol */
    15791576             "0");           /* charge */
    15801577      AtomNo++;
     
    15961593{
    15971594  int AtomNo = -1;
    1598   atom *Walker = NULL;
    15991595  FILE *f = NULL;
    16001596
     
    16111607  fprintf(f, "# Created by MoleCuilder\n");
    16121608
    1613   Walker = mol->start;
    16141609  AtomNo = 0;
    1615   while (Walker->next != mol->end) {
    1616     Walker = Walker->next;
    1617     sprintf(name, "%2s%2d",Walker->type->symbol, elementNo[Walker->type->Z]);
    1618     elementNo[Walker->type->Z] = (elementNo[Walker->type->Z]+1) % 100;   // confine to two digits
     1610  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     1611    sprintf(name, "%2s%2d",(*iter)->type->symbol, elementNo[(*iter)->type->Z]);
     1612    elementNo[(*iter)->type->Z] = (elementNo[(*iter)->type->Z]+1) % 100;   // confine to two digits
    16191613    fprintf(f,
    16201614           "ATOM %6u %-4s %4s%c%4u    %8.3f%8.3f%8.3f%6.2f%6.2f      %4s%2s%2s\n",
    1621            Walker->nr,                /* atom serial number */
     1615           (*iter)->nr,                /* atom serial number */
    16221616           name,         /* atom name */
    16231617           mol->name,      /* residue name */
    16241618           'a'+(unsigned char)(AtomNo % 26),           /* letter for chain */
    16251619           0,         /* residue sequence number */
    1626            Walker->node->x[0],                 /* position X in Angstroem */
    1627            Walker->node->x[1],                 /* position Y in Angstroem */
    1628            Walker->node->x[2],                 /* position Z in Angstroem */
    1629            (double)Walker->type->Valence,         /* occupancy */
    1630            (double)Walker->type->NoValenceOrbitals,          /* temperature factor */
     1620           (*iter)->node->x[0],                 /* position X in Angstroem */
     1621           (*iter)->node->x[1],                 /* position Y in Angstroem */
     1622           (*iter)->node->x[2],                 /* position Z in Angstroem */
     1623           (double)(*iter)->type->Valence,         /* occupancy */
     1624           (double)(*iter)->type->NoValenceOrbitals,          /* temperature factor */
    16311625           "0",            /* segment identifier */
    1632            Walker->type->symbol,    /* element symbol */
     1626           (*iter)->type->symbol,    /* element symbol */
    16331627           "0");           /* charge */
    16341628    AtomNo++;
     
    16471641bool config::SaveTREMOLO(const char * const filename, const molecule * const mol) const
    16481642{
    1649   atom *Walker = NULL;
    16501643  ofstream *output = NULL;
    16511644  stringstream * const fname = new stringstream;
     
    16601653
    16611654  // scan maximum number of neighbours
    1662   Walker = mol->start;
    16631655  int MaxNeighbours = 0;
    1664   while (Walker->next != mol->end) {
    1665     Walker = Walker->next;
    1666     const int count = Walker->ListOfBonds.size();
     1656  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     1657    const int count = (*iter)->ListOfBonds.size();
    16671658    if (MaxNeighbours < count)
    16681659      MaxNeighbours = count;
    16691660  }
    1670   *output << "# ATOMDATA Id name resName resSeq x=3 charge type neighbors=" << MaxNeighbours << endl;
    1671 
    1672   Walker = mol->start;
    1673   while (Walker->next != mol->end) {
    1674     Walker = Walker->next;
    1675     *output << Walker->nr << "\t";
    1676     *output << Walker->Name << "\t";
     1661  *output << "# ATOMDATA Id name resName resSeq x=3 Charge type neighbors=" << MaxNeighbours << endl;
     1662
     1663  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     1664    *output << (*iter)->nr << "\t";
     1665    *output << (*iter)->Name << "\t";
    16771666    *output << mol->name << "\t";
    16781667    *output << 0 << "\t";
    1679     *output << Walker->node->x[0] << "\t" << Walker->node->x[1] << "\t" << Walker->node->x[2] << "\t";
    1680     *output << (double)Walker->type->Valence << "\t";
    1681     *output << Walker->type->symbol << "\t";
    1682     for (BondList::iterator runner = Walker->ListOfBonds.begin(); runner != Walker->ListOfBonds.end(); runner++)
    1683       *output << (*runner)->GetOtherAtom(Walker)->nr << "\t";
    1684     for(int i=Walker->ListOfBonds.size(); i < MaxNeighbours; i++)
     1668    for (int i=0;i<NDIM;i++)
     1669      *output << (*iter)->node->x[i] << "\t";
     1670    *output << (double)(*iter)->type->Valence << "\t";
     1671    *output << (*iter)->type->symbol << "\t";
     1672    for (BondList::iterator runner = (*iter)->ListOfBonds.begin(); runner != (*iter)->ListOfBonds.end(); runner++)
     1673      *output << (*runner)->GetOtherAtom((*iter))->nr << "\t";
     1674    for(int i=(*iter)->ListOfBonds.size(); i < MaxNeighbours; i++)
    16851675      *output << "-\t";
    16861676    *output << endl;
     
    17011691bool config::SaveTREMOLO(const char * const filename, const MoleculeListClass * const MolList) const
    17021692{
    1703   atom *Walker = NULL;
    17041693  ofstream *output = NULL;
    17051694  stringstream * const fname = new stringstream;
     
    17161705  int MaxNeighbours = 0;
    17171706  for (MoleculeList::const_iterator MolWalker = MolList->ListOfMolecules.begin(); MolWalker != MolList->ListOfMolecules.end(); MolWalker++) {
    1718     Walker = (*MolWalker)->start;
    1719     while (Walker->next != (*MolWalker)->end) {
    1720       Walker = Walker->next;
    1721       const int count = Walker->ListOfBonds.size();
     1707    for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
     1708      const int count = (*iter)->ListOfBonds.size();
    17221709      if (MaxNeighbours < count)
    17231710        MaxNeighbours = count;
    17241711    }
    17251712  }
    1726   *output << "# ATOMDATA Id name resName resSeq x=3 charge type neighbors=" << MaxNeighbours << endl;
     1713  *output << "# ATOMDATA Id name resName resSeq x=3 Charge type neighbors=" << MaxNeighbours << endl;
    17271714
    17281715  // create global to local id map
     
    17451732    int AtomNo = 0;
    17461733    for (MoleculeList::const_iterator MolWalker = MolList->ListOfMolecules.begin(); MolWalker != MolList->ListOfMolecules.end(); MolWalker++) {
    1747       Walker = (*MolWalker)->start;
    1748       while (Walker->next != (*MolWalker)->end) {
    1749         Walker = Walker->next;
     1734      for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
    17501735        *output << AtomNo << "\t";
    1751         *output << Walker->Name << "\t";
     1736        *output << (*iter)->Name << "\t";
    17521737        *output << (*MolWalker)->name << "\t";
    17531738        *output << MolCounter << "\t";
    1754         *output << Walker->node->x[0] << "\t" << Walker->node->x[1] << "\t" << Walker->node->x[2] << "\t";
    1755         *output << (double)Walker->type->Valence << "\t";
    1756         *output << Walker->type->symbol << "\t";
    1757         for (BondList::iterator runner = Walker->ListOfBonds.begin(); runner != Walker->ListOfBonds.end(); runner++)
    1758           *output << LocalNotoGlobalNoMap[MolCounter][ (*runner)->GetOtherAtom(Walker)->nr ] << "\t";
    1759         for(int i=Walker->ListOfBonds.size(); i < MaxNeighbours; i++)
     1739        for (int i=0;i<NDIM;i++)
     1740          *output << (*iter)->node->x[i] << "\t";
     1741        *output << (double)(*iter)->type->Valence << "\t";
     1742        *output << (*iter)->type->symbol << "\t";
     1743        for (BondList::iterator runner = (*iter)->ListOfBonds.begin(); runner != (*iter)->ListOfBonds.end(); runner++)
     1744          *output << LocalNotoGlobalNoMap[MolCounter][ (*runner)->GetOtherAtom((*iter))->nr ] << "\t";
     1745        for(int i=(*iter)->ListOfBonds.size(); i < MaxNeighbours; i++)
    17601746          *output << "-\t";
    17611747        *output << endl;
Note: See TracChangeset for help on using the changeset viewer.