Changeset 3867a7 for src/Atom


Ignore:
Timestamp:
Feb 17, 2012, 3:24:18 PM (13 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:
b97a60
Parents:
9f8b01
git-author:
Frederik Heber <heber@…> (01/06/12 15:38:26)
git-committer:
Frederik Heber <heber@…> (02/17/12 15:24:18)
Message:

AtomicInfo now stores Father by id not ref.

  • this migh have caused a crash before with Remove- and UndoActins by:
    • additionalAtomData pointing nowhere because the id might have changed.
    • father is stored as ref and not as id. If it's its own father, the ref is wrong.
    • molecule is given as ref and not as id.
  • atom::setMolecule() - NULL ref is allowed.
  • AtomicInfo: stores ids and not refs, first calls changeId then assigns father and mol (who both need updated id).
Location:
src/Atom
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/Atom/AtomicInfo.cpp

    r9f8b01 r3867a7  
    2222#include "atom.hpp"
    2323#include "AtomicInfo.hpp"
     24#include "Descriptors/AtomIdDescriptor.hpp"
     25#include "Descriptors/MoleculeIdDescriptor.hpp"
    2426#include "Element/element.hpp"
    2527#include "LinearAlgebra/Vector.hpp"
     28#include "molecule.hpp"
     29#include "World.hpp"
    2630
    2731/********************************** Functions for class AtomicInfo **********************************/
     
    2933AtomicInfo::AtomicInfo() :
    3034    Type(NULL),
    31     Father(NULL),
    32     Id(-1)
     35    FatherId(0),
     36    MolId(0),
     37    Id(0)
    3338{}
    3439AtomicInfo::AtomicInfo(const atom &_atom) :
     
    3641    Type(_atom.getType()),
    3742    Velocity(_atom.getAtomicVelocity()),
    38     Father(_atom.father),
    39     Mol(_atom.getMolecule()),
     43    FatherId(_atom.father->getId()),
     44    MolId(_atom.getMolecule()->getId()),
    4045    Id(_atom.getId())
    4146{}
     
    4954  _atom.setPosition(Position);
    5055  _atom.setType(Type);
    51   _atom.father = const_cast<atom *>(Father); // TODO: Actually, atom::father should be const atom *!
    52   _atom.setMolecule(const_cast<molecule *>(Mol)); // this is ok, mol is const within AtomicInfo, but not outside (atoms need to register)
    5356  _atom.setAtomicVelocity(Velocity);
    54   if (_atom.getId() == Id)
    55     return true;
     57
     58  // set old id
     59  bool status = true;
     60  if (_atom.getId() != Id)
     61    status = _atom.changeId(Id);
     62
     63  // set its father
     64  atom * const _father = World::getInstance().getAtom(AtomById(FatherId));
     65  if (_father == NULL)
     66    _atom.father = &_atom;
    5667  else
    57     return (_atom.changeId(Id));
     68    _atom.father = _father;
     69
     70  // setting molecule
     71  molecule * const _mol = World::getInstance().getMolecule(MoleculeById(MolId));
     72  if (_mol != NULL)
     73    _atom.setMolecule(_mol); // this is ok, mol is const within AtomicInfo, but not outside (atoms need to register)
     74
     75  return status;
    5876}
    5977
     
    6886  Position = AI.Position;
    6987  Type = AI.Type;
    70   Father = AI.Father;
    71   Mol = AI.Mol;
     88  FatherId = AI.FatherId;
     89  MolId = AI.MolId;
    7290  Velocity = AI.Velocity;
    7391  Id = AI.Id;
  • src/Atom/AtomicInfo.hpp

    r9f8b01 r3867a7  
    3838  const element * Type;
    3939  Vector Velocity;
    40   const atom * Father;
    41   const molecule * Mol;
     40  atomId_t FatherId;
     41  moleculeId_t MolId;
    4242  atomId_t Id;
    4343};
  • src/Atom/atom.cpp

    r9f8b01 r3867a7  
    297297  removeFromMolecule();
    298298  mol = _mol;
    299   if(!mol->containsAtom(this)){
     299  if ((mol) && (!mol->containsAtom(this)))
    300300    mol->insert(this);
    301   }
    302301}
    303302
Note: See TracChangeset for help on using the changeset viewer.