Ignore:
Timestamp:
Dec 16, 2010, 5:32:22 PM (15 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:
fc5c3a
Parents:
512f85
git-author:
Frederik Heber <heber@…> (12/11/10 15:57:00)
git-committer:
Frederik Heber <heber@…> (12/16/10 17:32:22)
Message:

Extended FormatParser::save() to use vector<atom *> to save.

  • This is needed to make the save functions also work on selected atoms or molecules only.
  • Within ParserCommonUnitTest, ParserTremoloUnitTest we create the vector by calling World's getAllAtoms() (which would have been done before in the specialized save() functions).
  • new functions in FormatParserStorage:
    • saveSelectedAtoms().
    • saveSelectedMolecules().
    • saveWorld().
  • renamed ::get() and ::put() to ::load() and ::save() to have it more consistent with underlying FormatParser functions and also to avoid misinterpretation with all ::get...() functions.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/PcpParser.cpp

    r512f85 r73916f  
    368368}
    369369
    370 /** Saves the World into a PCP config file.
    371  * \param *file output stream to save to
    372  */
    373 void PcpParser::save(std::ostream* file)
     370/**
     371 * Saves the \a atoms into as a PCP file.
     372 *
     373 * \param file where to save the state
     374 * \param atoms atoms to store
     375 */
     376void PcpParser::save(std::ostream* file, const std::vector<atom *> &atoms)
    374377{
    375378  DoLog(0) && (Log() << Verbose(0) << "Saving changes to pcp." << std::endl);
     
    379382  if (!file->fail()) {
    380383    // calculate number of Psis
    381     vector<atom *> allatoms = World::getInstance().getAllAtoms();
    382     CalculateOrbitals(allatoms);
     384    CalculateOrbitals(atoms);
    383385    *file << "# ParallelCarParinello - main configuration file - created with molecuilder" << endl;
    384386    *file << endl;
     
    468470    *file << "RelativeCoord\t" << RelativeCoord << "\t# whether ion coordinates are relative (1) or absolute (0)" << endl;
    469471    map<int, int> ZtoIndexMap;
    470     OutputElements(file, allatoms, ZtoIndexMap);
    471     OutputAtoms(file, allatoms, ZtoIndexMap);
     472    OutputElements(file, atoms, ZtoIndexMap);
     473    OutputAtoms(file, atoms, ZtoIndexMap);
    472474  } else {
    473475    DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open output file." << endl);
     
    479481 * \param &allatoms all atoms to store away
    480482 */
    481 void PcpParser::CalculateOrbitals(vector<atom *> &allatoms)
     483void PcpParser::CalculateOrbitals(const std::vector<atom *> &allatoms)
    482484{
    483485  PlaneWaveSpecifics.MaxPsiDouble = PlaneWaveSpecifics.PsiMaxNoDown = PlaneWaveSpecifics.PsiMaxNoUp = PlaneWaveSpecifics.PsiType = 0;
    484   for (vector<atom *>::iterator runner = allatoms.begin(); runner != allatoms.end(); ++runner) {
     486  for (vector<atom *>::const_iterator runner = allatoms.begin(); runner != allatoms.end(); ++runner) {
    485487    PlaneWaveSpecifics.MaxPsiDouble += (*runner)->getType()->getNoValenceOrbitals();
    486488  }
     
    512514 * \param &ZtoIndexMap map of which atoms belong to which ion number
    513515 */
    514 void PcpParser::OutputElements(ostream *file, vector<atom *> &allatoms, map<int, int> &ZtoIndexMap)
     516void PcpParser::OutputElements(ostream *file, const std::vector<atom *> &allatoms, map<int, int> &ZtoIndexMap)
    515517{
    516518  map<int, int> PresentElements;
    517519  pair <   map<int, int>::iterator, bool > Inserter;
    518520  // insert all found elements into the map
    519   for (vector<atom *>::iterator AtomRunner = allatoms.begin();AtomRunner != allatoms.end();++AtomRunner) {
     521  for (vector<atom *>::const_iterator AtomRunner = allatoms.begin();AtomRunner != allatoms.end();++AtomRunner) {
    520522    Inserter = PresentElements.insert(pair<int, int>((*AtomRunner)->getType()->getAtomicNumber(), 1));
    521523    if (!Inserter.second) // increase if present
     
    542544 * \param &ZtoIndexMap map of which atoms belong to which ion number
    543545 */
    544 void PcpParser::OutputAtoms(ostream *file, vector<atom *> &allatoms, map<int, int> &ZtoIndexMap)
     546void PcpParser::OutputAtoms(ostream *file, const std::vector<atom *> &allatoms, map<int, int> &ZtoIndexMap)
    545547{
    546548  *file << "#Ion_TypeNr._Nr.R[0]    R[1]    R[2]    MoveType (0 MoveIon, 1 FixedIon)" << endl;
     
    548550  pair <   map<int, int>::iterator, bool > Inserter;
    549551  int nr = 0;
    550   for (vector<atom *>::iterator AtomRunner = allatoms.begin();AtomRunner != allatoms.end();++AtomRunner) {
     552  for (vector<atom *>::const_iterator AtomRunner = allatoms.begin();AtomRunner != allatoms.end();++AtomRunner) {
    551553    Inserter = ZtoCountMap.insert( pair<int, int>((*AtomRunner)->getType()->getAtomicNumber(), 1) );
    552554    if (!Inserter.second)
Note: See TracChangeset for help on using the changeset viewer.