Changeset bf46da for src


Ignore:
Timestamp:
May 8, 2008, 3:52:11 PM (17 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, 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:
a529de
Parents:
87f6c9
Message:

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

further and now final abstraction of FragmentMolecule()

Location:
src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/moleculelist.cpp

    r87f6c9 rbf46da  
    503503  if (FragmentList == NULL) {
    504504    KeySetCounter = Count();
    505     FragmentList = (Graph **) Malloc(sizeof(Graph *)*KeySetCounter, "molecule::FragmentMolecule - **BondFragments");
     505    FragmentList = (Graph **) Malloc(sizeof(Graph *)*KeySetCounter, "MoleculeLeafClass::AssignKeySetsToFragment - **FragmentList");
    506506    for(int i=0;i<KeySetCounter;i++)
    507507      FragmentList[i] = NULL;
  • src/molecules.cpp

    r87f6c9 rbf46da  
    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
  • src/molecules.hpp

    r87f6c9 rbf46da  
    348348  bool StoreKeySetFile(ofstream *out, Graph &KeySetList, char *path);
    349349  bool StoreForcesFile(ofstream *out, MoleculeListClass *BondFragments, char *path, int *SortIndex);
     350  bool CreateMappingLabelsToConfigSequence(ofstream *out, int *&SortIndex);
    350351  bool ScanBufferIntoKeySet(ofstream *out, char *buffer, KeySet &CurrentSet);
    351352  void BreadthFirstSearchAdd(ofstream *out, molecule *Mol, atom **&AddedAtomList, bond **&AddedBondList, atom *Root, bond *Bond, int BondOrder, bool IsAngstroem);
Note: See TracChangeset for help on using the changeset viewer.