Changeset d00370 for src


Ignore:
Timestamp:
Apr 6, 2012, 11:46:16 AM (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:
c0ed1e
Parents:
760c4c
git-author:
Frederik Heber <heber@…> (04/06/12 11:03:57)
git-committer:
Frederik Heber <heber@…> (04/06/12 11:46:16)
Message:

FIX: Box does not notify (though update) when set conditions or matrix is the same.

  • TESTFIX: BoxUnitTest adapted accordingly and added checks for no notify on these cases.
Location:
src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/Box.cpp

    r760c4c rd00370  
    119119  ASSERT(_M.determinant()!=0,"Matrix in Box construction was not invertible");
    120120  OBSERVE;
    121   NOTIFY(MatrixChanged);
     121  if (_M != *M)
     122    NOTIFY(MatrixChanged);
    122123  *M    =_M;
    123124  *Minv = M->invert();
     
    343344{
    344345  OBSERVE;
    345   NOTIFY(BoundaryConditionsChanged);
     346  if (conditions.get(i) != _condition)
     347    NOTIFY(BoundaryConditionsChanged);
    346348  conditions.set(i, _condition);
    347349}
     
    350352{
    351353  OBSERVE;
     354  if (conditions.get() != _conditions)
    352355  NOTIFY(BoundaryConditionsChanged);
    353356  conditions.set(_conditions);
  • src/unittests/BoxUnitTest.cpp

    r760c4c rd00370  
    16291629  UpdateCountObserver *observer_general = new UpdateCountObserver();
    16301630  NotificationObserver *observer_matrix = new NotificationObserver(
    1631       unitBox->getChannel(Box::MatrixChanged));
     1631      stretchedBox1->getChannel(Box::MatrixChanged));
    16321632  NotificationObserver *observer_bc = new NotificationObserver(
    1633       unitBox->getChannel(Box::BoundaryConditionsChanged));
     1633      stretchedBox1->getChannel(Box::BoundaryConditionsChanged));
    16341634  CPPUNIT_ASSERT_EQUAL((int)0, observer_general->updates);
    16351635  CPPUNIT_ASSERT_EQUAL(false, observer_matrix->wasNotified);
    16361636  CPPUNIT_ASSERT_EQUAL(false, observer_bc->wasNotified);
    1637   unitBox->signOn(observer_general);
    1638   unitBox->signOn(observer_matrix, Box::MatrixChanged);
    1639   unitBox->signOn(observer_bc, Box::BoundaryConditionsChanged);
     1637  stretchedBox1->signOn(observer_general);
     1638  stretchedBox1->signOn(observer_matrix, Box::MatrixChanged);
     1639  stretchedBox1->signOn(observer_bc, Box::BoundaryConditionsChanged);
    16401640
    16411641  // create update MatrixChanged
    1642   unitBox->setM(*unit);
     1642  stretchedBox1->setM(*unit);
    16431643  CPPUNIT_ASSERT_EQUAL((int)1, observer_general->updates);
    16441644  CPPUNIT_ASSERT_EQUAL(true, observer_matrix->wasNotified);
     
    16461646  observer_matrix->wasNotified = false;
    16471647
    1648   // create update BoundaryConditionsChanged
    1649   unitBox->setCondition(0, BoundaryConditions::Wrap);
     1648  // same matrix does not notify but update
     1649  stretchedBox1->setM(*unit);
    16501650  CPPUNIT_ASSERT_EQUAL((int)2, observer_general->updates);
    16511651  CPPUNIT_ASSERT_EQUAL(false, observer_matrix->wasNotified);
     1652  CPPUNIT_ASSERT_EQUAL(false, observer_bc->wasNotified);
     1653
     1654  // create update BoundaryConditionsChanged
     1655  stretchedBox1->setCondition(0, BoundaryConditions::Bounce);
     1656  CPPUNIT_ASSERT_EQUAL((int)3, observer_general->updates);
     1657  CPPUNIT_ASSERT_EQUAL(false, observer_matrix->wasNotified);
    16521658  CPPUNIT_ASSERT_EQUAL(true, observer_bc->wasNotified);
     1659  observer_bc->wasNotified = false;
     1660
     1661  // set same conditions does not notify but update
     1662  stretchedBox1->setCondition(0, BoundaryConditions::Bounce);
     1663  CPPUNIT_ASSERT_EQUAL((int)4, observer_general->updates);
     1664  CPPUNIT_ASSERT_EQUAL(false, observer_matrix->wasNotified);
     1665  CPPUNIT_ASSERT_EQUAL(false, observer_bc->wasNotified);
    16531666
    16541667  // remove observers again
    1655   unitBox->signOff(observer_general);
    1656   unitBox->signOff(observer_matrix, Box::MatrixChanged);
    1657   unitBox->signOff(observer_bc, Box::BoundaryConditionsChanged);
     1668  stretchedBox1->signOff(observer_general);
     1669  stretchedBox1->signOff(observer_matrix, Box::MatrixChanged);
     1670  stretchedBox1->signOff(observer_bc, Box::BoundaryConditionsChanged);
    16581671  delete observer_general;
    16591672  delete observer_matrix;
Note: See TracChangeset for help on using the changeset viewer.