Ignore:
Timestamp:
Dec 28, 2011, 3:25:48 PM (14 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:
59fff1
Parents:
f99714
git-author:
Frederik Heber <heber@…> (12/22/11 13:14:16)
git-committer:
Frederik Heber <heber@…> (12/28/11 15:25:48)
Message:

Removed atomSet atoms in class molecule and replaced by a boost::transform_iterator.

  • atoms causes us a O(N2) complexity due to having to remove atoms from this linearized vector (in O(N) not O(log N) as for the atomIds.
  • marked Molecules/BondFile and Tesselation/BigNonConvex as XFAIL due to interchanged ids.
  • thanks to Jan Hamaekers for pointing this out.
  • NOTE: so far we have not specialized molecule::const_iterator, it simply points to molecule::iterator.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/molecule_geometry.cpp

    rf99714 r30c753  
    5555
    5656  // go through all atoms
    57   BOOST_FOREACH(atom* iter, atoms){
    58     std::cout << "atom before is at " << *iter << std::endl;
    59     *iter -= *Center;
    60     *iter += *CenterBox;
    61     std::cout << "atom after is at " << *iter << std::endl;
    62   }
    63   atoms.transformNodes(boost::bind(&Box::WrapPeriodically,domain,_1));
     57  for (iterator iter = begin(); iter != end(); ++iter) {
     58    if (DoLog(4) && (*Center != *CenterBox))
     59      LOG(4, "INFO: atom before is at " << **iter);
     60    **iter -= *Center;
     61    **iter += *CenterBox;
     62    if (DoLog(4) && (*Center != *CenterBox))
     63      LOG(4, "INFO: atom after is at " << **iter);
     64  }
     65  getAtomSet().transformNodes(boost::bind(&Box::WrapPeriodically,domain,_1));
    6466
    6567  delete(Center);
     
    7880
    7981  // go through all atoms
    80   atoms.transformNodes(boost::bind(&Box::WrapPeriodically,domain,_1));
     82  getAtomSet().transformNodes(boost::bind(&Box::WrapPeriodically,domain,_1));
    8183
    8284  return status;
     
    9294  Vector *min = new Vector;
    9395
    94   molecule::const_iterator iter = begin();  // start at first in list
     96  const_iterator iter = begin();  // start at first in list
    9597  if (iter != end()) { //list not empty?
    9698    for (int i=NDIM;i--;) {
     
    120122{
    121123  int Num = 0;
    122   molecule::const_iterator iter = begin();  // start at first in list
     124  const_iterator iter = begin();  // start at first in list
    123125  Vector Center;
    124126
     
    139141Vector * molecule::DetermineCenterOfAll() const
    140142{
    141   molecule::const_iterator iter = begin();  // start at first in list
     143  const_iterator iter = begin();  // start at first in list
    142144  Vector *a = new Vector();
    143145  double Num = 0;
     
    172174Vector * molecule::DetermineCenterOfGravity() const
    173175{
    174   molecule::const_iterator iter = begin();  // start at first in list
     176  const_iterator iter = begin();  // start at first in list
    175177  Vector *a = new Vector();
    176178  Vector tmp;
     
    200202  DeterminePeriodicCenter(NewCenter);
    201203  // go through all atoms
    202   BOOST_FOREACH(atom* iter, atoms){
    203     *iter -= NewCenter;
     204  for (iterator iter = begin(); iter != end(); ++iter) {
     205    **iter -= NewCenter;
    204206  }
    205207};
     
    213215{
    214216  // go through all atoms
    215   BOOST_FOREACH(atom* iter, atoms){
    216     *iter -= *newcenter;
     217  for (iterator iter = begin(); iter != end(); ++iter) {
     218    **iter -= *newcenter;
    217219  }
    218220};
     
    231233
    232234  // sum up inertia tensor
    233   for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     235  for (const_iterator iter = begin(); iter != end(); ++iter) {
    234236    Vector x = (*iter)->getPosition();
    235237    x -= *CenterOfGravity;
     
    284286
    285287  // and rotate
    286   for (molecule::iterator iter = begin(); iter != end(); ++iter) {
     288  for (iterator iter = begin(); iter != end(); ++iter) {
    287289    *(*iter) -= *CenterOfGravity;
    288290    (*iter)->setPosition(RotationAxis.rotateVector((*iter)->getPosition(), alpha));
     
    304306void molecule::Scale(const double ** const factor)
    305307{
    306   for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     308  for (const_iterator iter = begin(); iter != end(); ++iter) {
    307309    for (size_t j=0;j<(*iter)->getTrajectorySize();j++) {
    308310      Vector temp = (*iter)->getPositionAtStep(j);
     
    318320void molecule::Translate(const Vector *trans)
    319321{
    320   for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     322  for (const_iterator iter = begin(); iter != end(); ++iter) {
    321323    for (size_t j=0;j<(*iter)->getTrajectorySize();j++) {
    322324      (*iter)->setPositionAtStep(j, (*iter)->getPositionAtStep(j) + (*trans));
     
    334336
    335337  // go through all atoms
    336   BOOST_FOREACH(atom* iter, atoms){
    337     *iter += *trans;
    338   }
    339   atoms.transformNodes(boost::bind(&Box::WrapPeriodically,domain,_1));
     338  for (iterator iter = begin(); iter != end(); ++iter) {
     339    **iter += *trans;
     340  }
     341  getAtomSet().transformNodes(boost::bind(&Box::WrapPeriodically,domain,_1));
    340342
    341343};
     
    349351  OBSERVE;
    350352  Plane p(*n,0);
    351   atoms.transformNodes(boost::bind(&Plane::mirrorVector,p,_1));
     353  getAtomSet().transformNodes(boost::bind(&Plane::mirrorVector,p,_1));
    352354};
    353355
     
    369371    Center.Zero();
    370372    flag = true;
    371     for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     373    for (const_iterator iter = begin(); iter != end(); ++iter) {
    372374      if ((saturation == DontSaturate) || ((*iter)->getType()->getAtomicNumber() != 1)) {
    373375        Testvector = inversematrix * (*iter)->getPosition();
     
    433435  alpha = atan(-n->at(0)/n->at(2));
    434436  LOG(1, "INFO: Z-X-angle: " << alpha << " ... ");
    435   for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     437  for (const_iterator iter = begin(); iter != end(); ++iter) {
    436438    tmp = (*iter)->at(0);
    437439    (*iter)->set(0,  cos(alpha) * tmp + sin(alpha) * (*iter)->at(2));
     
    453455  alpha = atan(-n->at(1)/n->at(2));
    454456  LOG(1, "INFO: Z-Y-angle: " << alpha << " ... ");
    455   for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     457  for (const_iterator iter = begin(); iter != end(); ++iter) {
    456458    tmp = (*iter)->at(1);
    457459    (*iter)->set(1,  cos(alpha) * tmp + sin(alpha) * (*iter)->at(2));
Note: See TracChangeset for help on using the changeset viewer.