Ignore:
Timestamp:
Mar 27, 2012, 3:53:35 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:
955b91
Parents:
b49de6
git-author:
Frederik Heber <heber@…> (03/15/12 17:00:53)
git-committer:
Frederik Heber <heber@…> (03/27/12 15:53:35)
Message:

FIX: AddEmptyBoundaryAction just returns Action::failure if there are no atoms.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/WorldAction/AddEmptyBoundaryAction.cpp

    rb49de6 r912c40  
    6161  // get maximum and minimum
    6262  std::vector<atom *> AllAtoms = World::getInstance().getAllAtoms();
    63   ASSERT(AllAtoms.size() > 0, "There must be atoms present for AddingEmptyBoundary.");
    64   std::vector<atom *>::iterator AtomRunner = AllAtoms.begin();
    65   Min = (*AtomRunner)->getPosition();
    66   Max = (*AtomRunner)->getPosition();
    67   for (; AtomRunner != AllAtoms.end(); ++AtomRunner) {
     63  if (AllAtoms.size() > 0) {
     64    std::vector<atom *>::iterator AtomRunner = AllAtoms.begin();
     65    Min = (*AtomRunner)->getPosition();
     66    Max = (*AtomRunner)->getPosition();
     67    for (; AtomRunner != AllAtoms.end(); ++AtomRunner) {
     68      for (int i=0;i<NDIM;i++) {
     69        if ((*AtomRunner)->at(i) > Max[i])
     70          Max[i] = (*AtomRunner)->at(i);
     71        if ((*AtomRunner)->at(i) < Min[i])
     72          Min[i] = (*AtomRunner)->at(i);
     73      }
     74    }
     75    // set new box size
     76    double * const cell_size = new double[6];
     77    for (j=0;j<6;j++)
     78      cell_size[j] = 0.;
     79    j=-1;
    6880    for (int i=0;i<NDIM;i++) {
    69       if ((*AtomRunner)->at(i) > Max[i])
    70         Max[i] = (*AtomRunner)->at(i);
    71       if ((*AtomRunner)->at(i) < Min[i])
    72         Min[i] = (*AtomRunner)->at(i);
     81      j += i+1;
     82      cell_size[j] = (Max[i]-Min[i]+2.*params.boundary[i]);
    7383    }
     84    World::getInstance().setDomain(cell_size);
     85    delete[] cell_size;
     86    // translate all atoms, such that Min is aty (0,0,0)
     87    AtomRunner = AllAtoms.begin();
     88    for (std::vector<atom *>::iterator AtomRunner = AllAtoms.begin();
     89        AtomRunner != AllAtoms.end();
     90        ++AtomRunner)
     91      *(*AtomRunner) -= Min - params.boundary;
     92
     93    // give final box size
     94    LOG(0, "Box domain is now " << World::getInstance().getDomain().getM());
     95
     96    // create undo state
     97    WorldAddEmptyBoundaryState *UndoState =
     98        new WorldAddEmptyBoundaryState(
     99            undostream.str(),
     100            World::getInstance().getDomain().getM(),
     101            Min,
     102            params
     103            );
     104
     105    return Action::state_ptr(UndoState);
     106  } else {
     107    ELOG(2, "There must be atoms present for AddingEmptyBoundary.");
     108    return Action::failure;
    74109  }
    75   // set new box size
    76   double * const cell_size = new double[6];
    77   for (j=0;j<6;j++)
    78     cell_size[j] = 0.;
    79   j=-1;
    80   for (int i=0;i<NDIM;i++) {
    81     j += i+1;
    82     cell_size[j] = (Max[i]-Min[i]+2.*params.boundary[i]);
    83   }
    84   World::getInstance().setDomain(cell_size);
    85   delete[] cell_size;
    86   // translate all atoms, such that Min is aty (0,0,0)
    87   AtomRunner = AllAtoms.begin();
    88   for (std::vector<atom *>::iterator AtomRunner = AllAtoms.begin();
    89       AtomRunner != AllAtoms.end();
    90       ++AtomRunner)
    91     *(*AtomRunner) -= Min - params.boundary;
    92 
    93   // give final box size
    94   LOG(0, "Box domain is now " << World::getInstance().getDomain().getM());
    95 
    96   // create undo state
    97   WorldAddEmptyBoundaryState *UndoState =
    98       new WorldAddEmptyBoundaryState(
    99           undostream.str(),
    100           World::getInstance().getDomain().getM(),
    101           Min,
    102           params
    103           );
    104 
    105   return Action::state_ptr(UndoState);
    106110}
    107111
Note: See TracChangeset for help on using the changeset viewer.