Changeset 0ba410


Ignore:
Timestamp:
Aug 5, 2010, 3:46:01 PM (15 years ago)
Author:
Tillmann Crueger <crueger@…>
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:
0eea14
Parents:
bf8e20
Message:

made the molecule::Output() method use STL algorithms

Location:
src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/atom.cpp

    rbf8e20 r0ba410  
    1919
    2020#include <iomanip>
     21#include <iostream>
    2122
    2223/************************************* Functions for class atom *************************************/
     
    165166  * \return true - \a *out present, false - \a *out is NULL
    166167 */
    167 bool atom::OutputArrayIndexed(ostream * const out, const int *ElementNo, int *AtomNo, const char *comment) const
     168bool atom::OutputArrayIndexed(ostream * const out,const enumeration<const element*> &elementLookup, int *AtomNo, const char *comment) const
    168169{
    169170  AtomNo[type->Z]++;  // increment number
    170171  if (out != NULL) {
    171     *out << "Ion_Type" << ElementNo[type->Z] << "_" << AtomNo[type->Z] << "\t"  << fixed << setprecision(9) << showpoint;
     172    cout << "Looking for atom with element " << *type << endl;
     173    ASSERT(elementLookup.there.find(type)!=elementLookup.there.end(),"Type of this atom was not in the formula upon enumeration");
     174    *out << "Ion_Type" << elementLookup.there.find(type)->second << "_" << AtomNo[type->Z] << "\t"  << fixed << setprecision(9) << showpoint;
    172175    *out << x[0] << "\t" << x[1] << "\t" << x[2];
    173176    *out << "\t" << FixedIon;
  • src/atom.hpp

    rbf8e20 r0ba410  
    5252
    5353  bool OutputIndexed(ofstream * const out, const int ElementNo, const int AtomNo, const char *comment = NULL) const;
    54   bool OutputArrayIndexed(ostream * const out, const int *ElementNo, int *AtomNo, const char *comment = NULL) const;
     54  bool OutputArrayIndexed(ostream * const out,const enumeration<const element*>&, int *AtomNo, const char *comment = NULL) const;
    5555  bool OutputXYZLine(ofstream *out) const;
    5656  bool OutputTrajectory(ofstream * const out, const int *ElementNo, int *AtomNo, const int step) const;
  • src/molecule.cpp

    rbf8e20 r0ba410  
    860860 * \param *out output stream
    861861 */
    862 bool molecule::Output(ofstream * const output)
    863 {
    864   int ElementNo[MAX_ELEMENTS], AtomNo[MAX_ELEMENTS];
    865 
    866   for (int i=0;i<MAX_ELEMENTS;++i) {
    867     AtomNo[i] = 0;
    868     ElementNo[i] = 0;
    869   }
     862bool molecule::Output(ostream * const output)
     863{
    870864  if (output == NULL) {
    871865    return false;
    872866  } else {
     867    int AtomNo[MAX_ELEMENTS];
     868    memset(AtomNo,0,(MAX_ELEMENTS-1)*sizeof(*AtomNo));
     869    enumeration<const element*> elementLookup = formula.enumerateElements();
     870    for(map<const element*,unsigned int>::iterator iter=elementLookup.there.begin();
     871        iter!=elementLookup.there.end();++iter){
     872      cout << "Enumerated element " << *iter->first << " with number " << iter->second << endl;
     873    }
    873874    *output << "#Ion_TypeNr._Nr.R[0]    R[1]    R[2]    MoveType (0 MoveIon, 1 FixedIon)" << endl;
    874     SetIndexedArrayForEachAtomTo ( ElementNo, &element::Z, &AbsoluteValue, 1);
    875     int current=1;
    876     for (int i=0;i<MAX_ELEMENTS;++i) {
    877       if (ElementNo[i] == 1)
    878         ElementNo[i] = current++;
    879     }
    880     ActOnAllAtoms( &atom::OutputArrayIndexed, (ostream * const) output, (const int *)ElementNo, (int *)AtomNo, (const char *) NULL );
     875    for_each(atoms.begin(),atoms.end(),boost::bind(&atom::OutputArrayIndexed,_1,output,elementLookup,AtomNo,(const char*)0));
    881876    return true;
    882877  }
  • src/molecule.hpp

    rbf8e20 r0ba410  
    341341
    342342  // Output routines.
    343   bool Output(ofstream * const output);
     343  bool Output(std::ostream * const output);
    344344  bool OutputTrajectories(ofstream * const output);
    345345  void OutputListOfBonds() const;
Note: See TracChangeset for help on using the changeset viewer.