Ignore:
Timestamp:
Jan 2, 2012, 1:34:42 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:
455043
Parents:
8c31865
git-author:
Frederik Heber <heber@…> (12/21/11 10:35:41)
git-committer:
Frederik Heber <heber@…> (01/02/12 13:34:42)
Message:

Removed short-wiring of updates as they are now passed through LinkedCellArrayCache.

  • replaced ..._internal() calls by Changes->addUpdate(..) in LinkedCell_Model.
  • added some verbosity to allow for following the chain of updates.
  • new unit test function lazyUpdatesTest() in LinkedCell_ModelTest.
  • TESTFIX: nodeTest() and insertPointCloudTest() needed a forced update at the right places due to the cached nature now as they access internals bypassing the automatic updates.
Location:
src/LinkedCell/unittests
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/LinkedCell/unittests/LinkedCell_ModelUnitTest.cpp

    r8c31865 r54f3d1  
    3232#include "LinkedCell/LinkedCell.hpp"
    3333#include "LinkedCell/LinkedCell_Model.hpp"
     34#include "LinkedCell/LinkedCell_Model_changeModel.hpp"
    3435#include "LinkedCell/LinkedCell_Model_LinkedCellArrayCache.hpp"
     36#include "LinkedCell/LinkedCell_Model_Update.hpp"
    3537#include "LinkedCell/PointCloudAdaptor.hpp"
    3638#include "LinkedCell/unittests/defs.hpp"
     
    141143  LC->insertPointCloud(cloud);
    142144
     145  // assure that we are updated before accessing internals
     146  CPPUNIT_ASSERT_EQUAL( true, *(LC->N->UpToDate) );
    143147  // test structure
    144148  CPPUNIT_ASSERT_EQUAL(((size_t)floor(NUMBERCELLS)), LC->CellLookup.size());
     
    236240  {
    237241    LC->addNode(Walker);
     242    // assure that we are updated before accessing internals
     243    CPPUNIT_ASSERT_EQUAL( true, *(LC->N->UpToDate) );
    238244    CPPUNIT_ASSERT_EQUAL( NodeList.size()+1, LC->CellLookup.size());
    239245    LinkedCell::tripleIndex index1 = LC->getIndexToVector(Walker->getPosition());
     
    251257    // we have to call moveNode ourselves, as we have just added TesselPoints, not via World
    252258    LC->moveNode(Walker);
     259    // assure that we are updated before accessing internals
     260    CPPUNIT_ASSERT_EQUAL( true, *(LC->N->UpToDate) );
    253261    const LinkedCell::tripleIndex &newindex2 = LC->CellLookup[Walker]->getIndices();
    254262    CPPUNIT_ASSERT( index2 != newindex2);
     
    258266  {
    259267    LC->deleteNode(Walker);
     268    // assure that we are updated before accessing internals
     269    CPPUNIT_ASSERT_EQUAL( true, *(LC->N->UpToDate) );
    260270    CPPUNIT_ASSERT_EQUAL( NodeList.size(), LC->CellLookup.size());
    261271  }
     
    263273  delete Walker;
    264274}
     275
     276/** UnitTest whether lazy updates are working.
     277 */
     278void LinkedCell_ModelTest::lazyUpdatesTest()
     279{
     280  // create point
     281  TesselPoint * Walker = new TesselPoint();
     282  Walker->setName(std::string("Walker9"));
     283  Walker->setPosition(Vector(9.8,7.6,5.4));
     284  TesselPoint * Walker2 = new TesselPoint();
     285  Walker2->setName(std::string("Walker10"));
     286  Walker2->setPosition(Vector(9.8,7.6,5.4));
     287  PointCloudAdaptor< PointSet > cloud(&NodeList, std::string("NodeList"));
     288  LC->insertPointCloud(cloud);
     289
     290  // initial read operation
     291  {
     292    CPPUNIT_ASSERT( !NodeList.empty() );
     293    LinkedCell::tripleIndex index = LC->getIndexToVector((*NodeList.begin())->getPosition());
     294    const size_t size = LC->N->getN()(index)->size(); // this will cause the update
     295    CPPUNIT_ASSERT( size >= (size_t)1 );
     296  }
     297
     298  // do some write ops
     299  LC->addNode(Walker);
     300  LC->addNode(Walker2);
     301  CPPUNIT_ASSERT( LC->Changes->queue.find(Walker) != LC->Changes->queue.end() );
     302  LinkedCell::LinkedCell_Model::Update *update = LC->Changes->queue[Walker];
     303  Walker->setPosition(Vector(0.,0.,0.));
     304  LC->moveNode(Walker);
     305
     306  // check that they all reside in cache and nothing is changed so far
     307  CPPUNIT_ASSERT( LC->Changes->queue.size() > (size_t)0 );
     308
     309  // check that add priority is prefered over move
     310  CPPUNIT_ASSERT( LC->Changes->queue[Walker] == update );
     311
     312  // perform read op
     313  {
     314    LinkedCell::tripleIndex index = LC->getIndexToVector(Walker->getPosition());
     315    CPPUNIT_ASSERT( LC->N->getN()(index)->size() >= (size_t)1 );
     316  }
     317
     318  // check that cache is emptied
     319  CPPUNIT_ASSERT( LC->Changes->queue.size() == (size_t)0 );
     320
     321  delete Walker;
     322  delete Walker2;
     323}
  • src/LinkedCell/unittests/LinkedCell_ModelUnitTest.hpp

    r8c31865 r54f3d1  
    3535    CPPUNIT_TEST ( getIndexToVectorTest );
    3636    CPPUNIT_TEST ( nodeTest );
     37    CPPUNIT_TEST ( lazyUpdatesTest );
    3738    CPPUNIT_TEST_SUITE_END();
    3839
     
    4950      void getIndexToVectorTest();
    5051      void nodeTest();
     52      void lazyUpdatesTest();
    5153
    5254private:
Note: See TracChangeset for help on using the changeset viewer.