Changeset 34c43a for src/linkedcell.hpp


Ignore:
Timestamp:
Mar 1, 2011, 10:16:38 AM (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:
caa06ef
Parents:
ba5215
git-author:
Frederik Heber <heber@…> (02/21/11 18:02:41)
git-committer:
Frederik Heber <heber@…> (03/01/11 10:16:38)
Message:

Bigger change: Replaced PointCloud by PointCloudAdaptor.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/linkedcell.hpp

    rba5215 r34c43a  
    2929#include "CodePatterns/Verbose.hpp"
    3030#include "Helpers/defs.hpp"
     31#include "LinearAlgebra/Vector.hpp"
    3132#include "World.hpp"
    32 #include "LinearAlgebra/Vector.hpp"
    3333
    3434/****************************************** forward declarations *****************************/
    3535
    36 class PointCloud;
     36class IPointCloud;
    3737class TesselPoint;
    3838
     
    4444/********************************************** declarations *******************************/
    4545
     46typedef std::list<TesselPoint *> TesselPointSTLList;
     47
    4648/** Linked Cell class for containing Vectors in real space efficiently.
    4749 */
     
    5052
    5153public:
    52   class LinkedNodes : public std::list<TesselPoint *> {
    53   public:
    54     LinkedNodes();
    55     ~LinkedNodes();
    56 
    57     TesselPoint * getValue (const_iterator &rhs) const;
    58     TesselPoint * getValue (iterator &rhs) const;
    59   };
    60   //typedef list<TesselPoint *> LinkedNodes;
    61 
    62 
    6354    Vector max;       // upper boundary
    6455    Vector min;       // lower boundary
    65     LinkedNodes *LC;  // linked cell list
     56    TesselPointSTLList *LC;  // linked cell list
    6657    double RADIUS;    // cell edge length
    6758    int N[NDIM];      // number of cells per axis
     
    7061
    7162    LinkedCell();
    72     LinkedCell(const PointCloud &set, const double radius);
    73     template <class T> LinkedCell(const T &set, const double radius) :
    74       LC(NULL),
    75       RADIUS(radius),
    76       index(-1)
    77     {
    78       class TesselPoint *Walker = NULL;
    79       for(int i=0;i<NDIM;i++)
    80         N[i] = 0;
    81       max.Zero();
    82       min.Zero();
    83       DoLog(1) && (Log() << Verbose(1) << "Begin of LinkedCell" << endl);
    84       if (set.begin() == set.end()) {
    85         DoeLog(1) && (eLog()<< Verbose(1) << "set contains no linked cell nodes!" << endl);
    86         return;
    87       }
    88       // 1. find max and min per axis of atoms
    89       typename T::const_iterator Runner = set.begin();
    90       for (int i=0;i<NDIM;i++) {
    91         max[i] = set.getValue(Runner)->at(i);
    92         min[i] = set.getValue(Runner)->at(i);
    93       }
    94       for (typename T::const_iterator Runner = set.begin(); Runner != set.end(); Runner++) {
    95         Walker = set.getValue(Runner);
    96         for (int i=0;i<NDIM;i++) {
    97           if (max[i] < Walker->at(i))
    98             max[i] = Walker->at(i);
    99           if (min[i] > Walker->at(i))
    100             min[i] = Walker->at(i);
    101         }
    102       }
    103       DoLog(2) && (Log() << Verbose(2) << "Bounding box is " << min << " and " << max << "." << endl);
    104 
    105       // 2. find then number of cells per axis
    106       for (int i=0;i<NDIM;i++) {
    107         N[i] = static_cast<int>(floor((max[i] - min[i])/RADIUS)+1);
    108       }
    109       DoLog(2) && (Log() << Verbose(2) << "Number of cells per axis are " << N[0] << ", " << N[1] << " and " << N[2] << "." << endl);
    110 
    111       // 3. allocate the lists
    112       DoLog(2) && (Log() << Verbose(2) << "Allocating cells ... ");
    113       if (LC != NULL) {
    114         DoeLog(1) && (eLog()<< Verbose(1) << "Linked Cell list is already allocated, I do nothing." << endl);
    115         return;
    116       }
    117       ASSERT(N[0]*N[1]*N[2] < MAX_LINKEDCELLNODES, "Number linked of linked cell nodes exceded hard-coded limit, use greater edge length!");
    118       LC = new LinkedNodes[N[0]*N[1]*N[2]];
    119       for (index=0;index<N[0]*N[1]*N[2];index++) {
    120         LC [index].clear();
    121       }
    122       DoLog(0) && (Log() << Verbose(0) << "done."  << endl);
    123 
    124       // 4. put each atom into its respective cell
    125       DoLog(2) && (Log() << Verbose(2) << "Filling cells ... ");
    126       for (typename T::const_iterator Runner = set.begin(); Runner != set.end(); Runner++) {
    127         Walker = set.getValue(Runner);
    128         for (int i=0;i<NDIM;i++) {
    129           n[i] = static_cast<int>(floor((Walker->at(i) - min[i])/RADIUS));
    130         }
    131         index = n[0] * N[1] * N[2] + n[1] * N[2] + n[2];
    132         LC[index].push_back(Walker);
    133         //Log() << Verbose(2) << *Walker << " goes into cell " << n[0] << ", " << n[1] << ", " << n[2] << " with No. " << index << "." << endl;
    134       }
    135       DoLog(0) && (Log() << Verbose(0) << "done."  << endl);
    136       DoLog(1) && (Log() << Verbose(1) << "End of LinkedCell" << endl);
    137     };
    138 
    139 
     63    LinkedCell(IPointCloud &set, const double radius);
    14064    ~LinkedCell();
    141     const LinkedCell::LinkedNodes* GetCurrentCell()const ;
    142     const LinkedCell::LinkedNodes* GetRelativeToCurrentCell(const int relative[NDIM])const ;
     65    const TesselPointSTLList* GetCurrentCell()const ;
     66    const TesselPointSTLList* GetRelativeToCurrentCell(const int relative[NDIM])const ;
    14367    bool SetIndexToNode(const TesselPoint * const Walker)const ;
    14468    bool SetIndexToVector(const Vector &x)const ;
     
    14872    void GetNeighbourBounds(int lower[NDIM], int upper[NDIM], int step = 1)const ;
    14973
    150     LinkedCell::LinkedNodes* GetallNeighbours(const double distance = 0) const;
    151     LinkedCell::LinkedNodes* GetPointsInsideSphere(const double radius, const Vector * const center) const;
     74    TesselPointSTLList* GetallNeighbours(const double distance = 0) const;
     75    TesselPointSTLList* GetPointsInsideSphere(const double radius, const Vector * const center) const;
    15276    // not implemented yet
    15377    bool AddNode(Vector *Walker);
Note: See TracChangeset for help on using the changeset viewer.