Ignore:
Timestamp:
May 8, 2008, 3:52:11 PM (17 years ago)
Author:
Frederik Heber <heber@…>
Children:
461e93
Parents:
2b79c3
Message:

new function molecule::CreateMappingLabelsToConfigSequence() creates SortIndex in molecule::FragmentMolecule()

further and now final abstraction of FragmentMolecule()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified molecuilder/src/molecules.cpp

    r2b79c3 rd88597  
    21612161};
    21622162
     2163/** Create a SortIndex to map from BFS labels to the sequence in which the atoms are given in the config file.
     2164 * \param *out output stream for debugging
     2165 * \param *&SortIndex Mapping array of size molecule::AtomCount
     2166 * \return true - success, false - failure of SortIndex alloc
     2167 */
     2168bool molecule::CreateMappingLabelsToConfigSequence(ofstream *out, int *&SortIndex)
     2169{
     2170  element *runner = elemente->start;
     2171  int AtomNo = 0;
     2172  atom *Walker = NULL;
     2173 
     2174  if (SortIndex != NULL) {
     2175    *out << Verbose(1) << "SortIndex is " << SortIndex << " and not NULL as expected." << endl;
     2176    return false;
     2177  }
     2178  SortIndex = (int *) Malloc(sizeof(int)*AtomCount, "molecule::FragmentMolecule: *SortIndex");
     2179  for(int i=0;i<AtomCount;i++)
     2180    SortIndex[i] = -1;
     2181  while (runner->next != elemente->end) { // go through every element
     2182    runner = runner->next;
     2183    if (ElementsInMolecule[runner->Z]) { // if this element got atoms
     2184      Walker = start;
     2185      while (Walker->next != end) { // go through every atom of this element
     2186        Walker = Walker->next;
     2187        if (Walker->type->Z == runner->Z) // if this atom fits to element
     2188          SortIndex[Walker->nr] = AtomNo++;
     2189      }
     2190    }
     2191  }
     2192  return true;
     2193};
     2194
    21632195/** Performs a many-body bond order analysis for a given bond order.
    21642196 * -# parses adjacency, keysets and orderatsite files
     
    21812213{
    21822214        MoleculeListClass *BondFragments = NULL;
    2183   atom *Walker = NULL;
    21842215  int *SortIndex = NULL;
    2185   element *runner = NULL;
    2186   int AtomNo;
    21872216  int MinimumRingSize;
    21882217  int FragmentCounter;
     
    23022331  // ===== 9. Save fragments' configuration and keyset files et al to disk ===
    23032332  if (BondFragments->NumberOfMolecules != 0) {
    2304     // create a SortIndex to map from BFS labels to the sequence in which the atoms are given in the config file
    2305     SortIndex = (int *) Malloc(sizeof(int)*AtomCount, "molecule::FragmentMolecule: *SortIndex");
    2306     for(int i=0;i<AtomCount;i++)
    2307       SortIndex[i] = -1;
    2308     runner = elemente->start;
    2309     AtomNo = 0;
    2310     while (runner->next != elemente->end) { // go through every element
    2311       runner = runner->next;
    2312       if (ElementsInMolecule[runner->Z]) { // if this element got atoms
    2313         Walker = start;
    2314         while (Walker->next != end) { // go through every atom of this element
    2315           Walker = Walker->next;
    2316           if (Walker->type->Z == runner->Z) // if this atom fits to element
    2317             SortIndex[Walker->nr] = AtomNo++;
    2318         }
    2319       }
    2320     }
     2333    // create the SortIndex from BFS labels to order in the config file
     2334    CreateMappingLabelsToConfigSequence(out, SortIndex);
     2335   
    23212336    *out << Verbose(1) << "Writing " << BondFragments->NumberOfMolecules << " possible bond fragmentation configs" << endl;
    23222337    if (BondFragments->OutputConfigForListOfFragments(out, configuration, SortIndex))
     
    23432358    *out << Verbose(1) << "Freeing bond memory" << endl;
    23442359    delete(FragmentList); // remove bond molecule from memory
    2345     FragmentList = NULL;
    23462360    Free((void **)&SortIndex, "molecule::FragmentMolecule: *SortIndex");
    23472361  } else
Note: See TracChangeset for help on using the changeset viewer.