MercuryDPM  0.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HGRID.h
Go to the documentation of this file.
1 //Copyright (c) 2013-2014, The MercuryDPM Developers Team. All rights reserved.
2 //For the list of developers, see <http://www.MercuryDPM.org/Team>.
3 //
4 //Redistribution and use in source and binary forms, with or without
5 //modification, are permitted provided that the following conditions are met:
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above copyright
9 // notice, this list of conditions and the following disclaimer in the
10 // documentation and/or other materials provided with the distribution.
11 // * Neither the name MercuryDPM nor the
12 // names of its contributors may be used to endorse or promote products
13 // derived from this software without specific prior written permission.
14 //
15 //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 //ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 //WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 //DISCLAIMED. IN NO EVENT SHALL THE MERCURYDPM DEVELOPERS TEAM BE LIABLE FOR ANY
19 //DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 //(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 //LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 //ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 //(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 
26 #ifndef HGRID_H
27 #define HGRID_H
28 
29 #include <iostream>
30 #include <vector>
31 #include <stdlib.h>
32 #include "ExtendedMath.h"
33 
34 class BaseParticle;
35 
39 class HGrid
40 {
41 public:
42 
43  HGrid();
44 
45  //----- parameters ------
48 
49 
50  std::vector<double> cellSizes_;
51  std::vector<double> invCellSizes_;
52 
53  //----- internal variables ----------
56 
59 
62 
63  //-------------------------------------------------
65  HGrid(int num_buckets, double cellOverSizeRatio, std::vector<double>& cellSizes);
66 
68  ~HGrid();
69 
70  void Initialize_inv_size();
71 
72 
77 
79  int ComputeHashBucketIndex(int x, int y, int z, int l);
80 
82  int ComputeHashBucketIndex(int x, int y, int l);
83 
85 
87  void reset_num_buckets(int new_num_buckets);
88 };
89 #endif
void InsertParticleToHgrid(BaseParticle *obj)
This insert a particle given by CParticle in to the HGrid (i.e. it sets up the particle grid properts...
Definition: HGRID.cc:69
Mdouble cellOverSizeRatio_
Definition: HGRID.h:84
~HGrid()
constructor: initializes parameters and allocates space for internal variables
Definition: HGRID.cc:52
void reset_num_buckets(int new_num_buckets)
Definition: HGRID.cc:124
int NUM_BUCKETS
Number of buckets used for hashing.
Definition: HGRID.h:47
std::vector< double > invCellSizes_
Definition: HGRID.h:51
std::vector< double > cellSizes_
Definition: HGRID.h:50
HGrid()
Definition: HGRID.cc:29
double Mdouble
Definition: ExtendedMath.h:33
This is the HGRID class - This is the actually HGRID code.
Definition: HGRID.h:39
int ComputeHashBucketIndex(int x, int y, int z, int l)
Computes hash bucket index in range [0, NUM_BUCKETS-1].
Definition: HGRID.cc:93
void Initialize_inv_size()
Definition: HGRID.cc:57
bool * bucketIsChecked
bucketIsChecked[b] stores if hash bucket b is checked already; initially all zero ...
Definition: HGRID.h:61
int occupiedLevelsMask
l-th bit of occupiedLevelsMask is 1 if level l is contains particles; initially zero (Implies max 32 ...
Definition: HGRID.h:55
BaseParticle ** objectBucket
objectBucket[b] stores pointer to first element in hash bucket b; initially all NULL ...
Definition: HGRID.h:58