Changeset c80643 for src/LinkedCell


Ignore:
Timestamp:
Jan 2, 2012, 1:34:29 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:
53d894
Parents:
4459fc
git-author:
Frederik Heber <heber@…> (12/19/11 21:49:53)
git-committer:
Frederik Heber <heber@…> (01/02/12 13:34:29)
Message:

LinkedCell_Controller::getView() now needs a PointCloud set.

  • this will allow the World to initialise new LinkedCell_Model, which at the very start first need to know about all presents atoms in the World.
Location:
src/LinkedCell
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/LinkedCell/LinkedCell_Controller.cpp

    r4459fc rc80643  
    2626#include "LinkedCell_Model.hpp"
    2727#include "LinkedCell_View.hpp"
     28#include "IPointCloud.hpp"
    2829
    2930
     
    153154 *
    154155 * @param distance edge length of the requested linked cell structure
     156 * @param set of initial points to insert when new model is created (not always), should be World's
    155157 * @return LinkedCell_View wrapping the best LinkedCell_Model
    156158 */
    157 LinkedCell_View LinkedCell_Controller::getView(const double distance)
     159LinkedCell_View LinkedCell_Controller::getView(const double distance, IPointCloud &set)
    158160{
    159161  /// Look for best instance.
     
    163165  if (LCModel_best == NULL) {
    164166    LinkedCell_Model *LCModel_new = new LinkedCell_Model(distance, domain);
     167    LCModel_new->insertPointCloud(set);
    165168    insertNewModel(distance, LCModel_new);
    166169    LinkedCell_View view(const_cast<const LinkedCell_Model &>(*LCModel_new));
  • src/LinkedCell/LinkedCell_Controller.hpp

    r4459fc rc80643  
    2020
    2121class LinkedCell_ControllerTest;
     22class IPointCloud;
    2223
    2324namespace LinkedCell {
     
    4748    ~LinkedCell_Controller();
    4849
    49     LinkedCell_View getView(const double distance);
     50    LinkedCell_View getView(const double distance, IPointCloud &set);
    5051
    5152  private:
  • src/LinkedCell/LinkedCell_Model.cpp

    r4459fc rc80643  
    139139  N.resize(index);
    140140  ASSERT(getSize(0)*getSize(1)*getSize(2) < MAX_LINKEDCELLNODES,
    141       "LinkedCell_Model::AllocateCells() - Number linked of linked cell nodes exceded hard-coded limit, use greater edge length!");
     141      "LinkedCell_Model::AllocateCells() - Number linked of linked cell nodes exceeded hard-coded limit, use greater edge length!");
    142142
    143143  // allocate LinkedCell instances
  • src/LinkedCell/LinkedCell_Model.hpp

    r4459fc rc80643  
    6767    void setPartition(double distance);
    6868
     69    void insertPointCloud(IPointCloud &set);
     70
    6971    //!> static indices to get nearest neighbors as default argument
    7072    static tripleIndex NearestNeighbors;
     
    7880    void AllocateCells();
    7981    void Reset();
    80     void insertPointCloud(IPointCloud &set);
    8182
    8283    void startListening();
  • src/LinkedCell/unittests/LinkedCell_ControllerUnitTest.cpp

    r4459fc rc80643  
    2424#include <cppunit/ui/text/TestRunner.h>
    2525
     26#include "Atom/atom.hpp"
    2627#include "Box.hpp"
    2728#include "CodePatterns/Assert.hpp"
     
    3031#include "LinkedCell/LinkedCell_View.hpp"
    3132#include "LinkedCell/unittests/defs.hpp"
     33#include "LinkedCell/PointCloudAdaptor.hpp"
    3234
    3335#include "LinkedCell_ControllerUnitTest.hpp"
     
    5759
    5860  controller = new LinkedCell::LinkedCell_Controller(*domain);
     61
     62  // create empty set
     63  emptyset = new PointCloudAdaptor< std::vector<atom *> >(&emptyvector, std::string("emptyset"));
    5964}
    6065
     
    6469  delete controller;
    6570  delete domain;
     71  delete emptyset;
    6672}
    6773
     
    113119  /// obtain a view
    114120  CPPUNIT_ASSERT_EQUAL( (size_t)0, controller->ModelsMap.size() );
    115   LinkedCell::LinkedCell_View view = controller->getView(2.);
     121  LinkedCell::LinkedCell_View view = controller->getView(2., *emptyset);
    116122  CPPUNIT_ASSERT_EQUAL( (size_t)1, controller->ModelsMap.size() );
    117123
    118124  {
    119125    /// get same view again and check that now new instance appears
    120     LinkedCell::LinkedCell_View view_again = controller->getView(2.);
     126    LinkedCell::LinkedCell_View view_again = controller->getView(2., *emptyset);
    121127    CPPUNIT_ASSERT_EQUAL( (size_t)1, controller->ModelsMap.size() );
    122128  }
     
    129135  /// obtain a view
    130136  CPPUNIT_ASSERT_EQUAL( (size_t)0, controller->ModelsMap.size() );
    131   LinkedCell::LinkedCell_View view = controller->getView(2.);
     137  LinkedCell::LinkedCell_View view = controller->getView(2., *emptyset);
    132138  CPPUNIT_ASSERT_EQUAL( (size_t)1, controller->ModelsMap.size() );
    133139
    134140  {
    135141    /// pick another view that is not close enough
    136     LinkedCell::LinkedCell_View view_other = controller->getView(5.);
     142    LinkedCell::LinkedCell_View view_other = controller->getView(5., *emptyset);
    137143    CPPUNIT_ASSERT_EQUAL( (size_t)2, controller->ModelsMap.size() );
    138144  }
     
    146152  const double edgelength = 2.;
    147153  CPPUNIT_ASSERT_EQUAL( (size_t)0, controller->ModelsMap.size() );
    148   LinkedCell::LinkedCell_View view = controller->getView(edgelength);
     154  LinkedCell::LinkedCell_View view = controller->getView(edgelength, *emptyset);
    149155  CPPUNIT_ASSERT_EQUAL( (size_t)1, controller->ModelsMap.size() );
    150156
     
    153159  {
    154160    /// ... at half lower interval half
    155     LinkedCell::LinkedCell_View view_lowerhalf = controller->getView((edgelength + interval.first)/2.);
     161    LinkedCell::LinkedCell_View view_lowerhalf = controller->getView((edgelength + interval.first)/2., *emptyset);
    156162    CPPUNIT_ASSERT_EQUAL( (size_t)1, controller->ModelsMap.size() );
    157163  }
    158164  {
    159165    /// ... at half upper interval half
    160     LinkedCell::LinkedCell_View view_upperhalf = controller->getView((interval.last + edgelength)/2.);
     166    LinkedCell::LinkedCell_View view_upperhalf = controller->getView((interval.last + edgelength)/2., *emptyset);
    161167    CPPUNIT_ASSERT_EQUAL( (size_t)1, controller->ModelsMap.size() );
    162168  }
    163169  {
    164170    /// ... close to lower boundary
    165     LinkedCell::LinkedCell_View view_closelower = controller->getView(interval.first + std::numeric_limits<double>::round_error());
     171    LinkedCell::LinkedCell_View view_closelower = controller->getView(interval.first + std::numeric_limits<double>::round_error(), *emptyset);
    166172    CPPUNIT_ASSERT_EQUAL( (size_t)1, controller->ModelsMap.size() );
    167173  }
    168174  {
    169175    /// ... close to upper boundary
    170     LinkedCell::LinkedCell_View view_closerupper = controller->getView(interval.last - std::numeric_limits<double>::round_error());
     176    LinkedCell::LinkedCell_View view_closerupper = controller->getView(interval.last - std::numeric_limits<double>::round_error(), *emptyset);
    171177    CPPUNIT_ASSERT_EQUAL( (size_t)1, controller->ModelsMap.size() );
    172178  }
    173179  {
    174180    /// on lower boundary
    175     LinkedCell::LinkedCell_View view_onlower = controller->getView(interval.first);
     181    LinkedCell::LinkedCell_View view_onlower = controller->getView(interval.first, *emptyset);
    176182    CPPUNIT_ASSERT_EQUAL( (size_t)1, controller->ModelsMap.size() );
    177183  }
     
    187193  /// obtain a view
    188194  CPPUNIT_ASSERT_EQUAL( (size_t)0, controller->ModelsMap.size() );
    189   LinkedCell::LinkedCell_View view = controller->getView(edgelength);
     195  LinkedCell::LinkedCell_View view = controller->getView(edgelength, *emptyset);
    190196  CPPUNIT_ASSERT_EQUAL( (size_t)1, controller->ModelsMap.size() );
    191197
     
    194200  {
    195201    /// ... outside lower boundary
    196     LinkedCell::LinkedCell_View view_outsidelower = controller->getView(interval.first - std::numeric_limits<double>::round_error());
     202    LinkedCell::LinkedCell_View view_outsidelower = controller->getView(interval.first - std::numeric_limits<double>::round_error(), *emptyset);
    197203    CPPUNIT_ASSERT_EQUAL( (size_t)2, controller->ModelsMap.size() );
    198204  }
    199205  {
    200206    /// ... on upper boundary
    201     LinkedCell::LinkedCell_View view_onupper = controller->getView(interval.last);
     207    LinkedCell::LinkedCell_View view_onupper = controller->getView(interval.last, *emptyset);
    202208    CPPUNIT_ASSERT_EQUAL( (size_t)3, controller->ModelsMap.size() );
    203209  }
     
    211217  const double edgelength = 1.9*controller->lower_threshold;
    212218  CPPUNIT_ASSERT_EQUAL( (size_t)0, controller->ModelsMap.size() );
    213   LinkedCell::LinkedCell_View view = controller->getView(edgelength);
     219  LinkedCell::LinkedCell_View view = controller->getView(edgelength, *emptyset);
    214220  CPPUNIT_ASSERT_EQUAL( (size_t)1, controller->ModelsMap.size() );
    215221
    216222  {
    217223    /// get a view at threshold and check that no new instance has been created
    218     LinkedCell::LinkedCell_View view_onlower = controller->getView(controller->lower_threshold);
     224    LinkedCell::LinkedCell_View view_onlower = controller->getView(controller->lower_threshold, *emptyset);
    219225    CPPUNIT_ASSERT_EQUAL( (size_t)1, controller->ModelsMap.size() );
    220226  }
    221227  {
    222228    /// pick a view below 1.
    223     LinkedCell::LinkedCell_View view_beneathlower = controller->getView(0.1*controller->lower_threshold);
     229    LinkedCell::LinkedCell_View view_beneathlower = controller->getView(0.1*controller->lower_threshold, *emptyset);
    224230    CPPUNIT_ASSERT_EQUAL( (size_t)1, controller->ModelsMap.size() );
    225231  }
     
    233239  const double edgelength = controller->upper_threshold;
    234240  CPPUNIT_ASSERT_EQUAL( (size_t)0, controller->ModelsMap.size() );
    235   LinkedCell::LinkedCell_View view = controller->getView(edgelength);
     241  LinkedCell::LinkedCell_View view = controller->getView(edgelength, *emptyset);
    236242  CPPUNIT_ASSERT_EQUAL( (size_t)1, controller->ModelsMap.size() );
    237243
    238244  {
    239245    /// get a view beyond threshold and check that no new instance has been created
    240     LinkedCell::LinkedCell_View view_beyondupper = controller->getView(1.1*controller->upper_threshold);
     246    LinkedCell::LinkedCell_View view_beyondupper = controller->getView(1.1*controller->upper_threshold, *emptyset);
    241247    CPPUNIT_ASSERT_EQUAL( (size_t)1, controller->ModelsMap.size() );
    242248  }
     
    246252    range<double> interval = controller->getHeuristicRange(edgelength);
    247253    if ( !interval.isInRange(0.1*controller->upper_threshold) ) {
    248       LinkedCell::LinkedCell_View view_beneathupper = controller->getView(0.1*controller->upper_threshold);
     254      LinkedCell::LinkedCell_View view_beneathupper = controller->getView(0.1*controller->upper_threshold, *emptyset);
    249255      CPPUNIT_ASSERT_EQUAL( (size_t)2, controller->ModelsMap.size() );
    250256    }
  • src/LinkedCell/unittests/LinkedCell_ControllerUnitTest.hpp

    r4459fc rc80643  
    1717#include <cppunit/extensions/HelperMacros.h>
    1818
     19#include <vector>
     20
     21#include "LinkedCell/PointCloudAdaptor.hpp"
     22
     23class atom;
    1924class Box;
    2025class RealSpaceMatrix;
     
    5459      Box *domain;
    5560      RealSpaceMatrix *BoxM;
     61      std::vector<atom *> emptyvector;
     62      PointCloudAdaptor< std::vector<atom *> > *emptyset;
    5663      LinkedCell::LinkedCell_Controller *controller;
    5764};
Note: See TracChangeset for help on using the changeset viewer.