MercuryDPM  Beta
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MercuryBase.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 MERCURYBASE_H
27 #define MERCURYBASE_H
28 
29 #include <ostream>
30 #include <iostream>
31 #include <stdlib.h>
32 
33 #include "DPMBase.h"
34 #include "HGrid.h"
35 #include "Logger.h"
36 
47 {
49 };
50 
64 {
66 };
67 
74 class MercuryBase : public virtual DPMBase
75 {
76 public:
80  MercuryBase();
81 
85  ~MercuryBase();
86 
90  MercuryBase(const MercuryBase& mercuryBase);
91 
95  void constructor();
96 
101  void hGridActionsBeforeTimeLoop() override;
102 
107  void hGridActionsBeforeTimeStep() override;
108 
112  void read(std::istream& is) override;
113 
117  void write(std::ostream& os, bool writeAllParticles = true) const override;
118 
123 
128 
132  void setHGridUpdateEachTimeStep(bool updateEachTimeStep);
133 
137  bool getHGridUpdateEachTimeStep() const override;
138 
142  void setHGridMaxLevels(unsigned int HGridMaxLevels);
143 
147  unsigned int getHGridMaxLevels() const;
148 
152  HGridMethod getHGridMethod() const;
153 
157  void setHGridMethod(HGridMethod hGridMethod);
158 
163 
167  void setHGridDistribution(HGridDistribution hGridDistribution);
168 
173 
177  void setHGridCellOverSizeRatio(Mdouble cellOverSizeRatio);
178 
182  bool hGridNeedsRebuilding();
183 
187  virtual unsigned int getHGridTargetNumberOfBuckets() const;
188 
193 
198 
202  bool checkParticleForInteraction(const BaseParticle& P) override;
203 
207  virtual Mdouble userHGridCellSize(unsigned int level);
208 
209 protected:
210 
214  void hGridRebuild();
215 
219  void hGridInsertParticle(BaseParticle* obj) override;
220 
225  void broadPhase(BaseParticle* i) override;
226 
232  virtual void hGridFindOneSidedContacts(BaseParticle* obj) = 0;
233 
238  virtual bool hGridHasParticleContacts(const BaseParticle* obj)=0;
239 
244  void hGridUpdateMove(BaseParticle * iP, Mdouble move) override;
245 
249  void hGridActionsBeforeIntegration() override;
250 
254  void hGridActionsAfterIntegration() override;
255 
259  HGrid* getHGrid();
260 
264  const HGrid* getHGrid() const;
265 
269  bool readNextArgument(int& i, int argc, char *argv[]) override;
270 
271 public:
275  void hGridInfo() const;
276 
277 private:
282 
294 
300 
308 
314 
322 
328 
341  unsigned int hGridMaxLevels_;
350 };
351 
352 #endif
virtual void hGridFindOneSidedContacts(BaseParticle *obj)=0
This is a purely virtual function that checks if an object is in the grid, this code is dimension dep...
bool checkParticleForInteraction(const BaseParticle &P) override
Checks if given BaseParticle has an interaction with a BaseWall or other BaseParticle.
Definition: MercuryBase.cc:609
The DPMBase header includes quite a few header files, defining all the handlers, which are essential...
Definition: DPMBase.h:61
bool hGridNeedsRebuilding()
Gets if the HGrid needs rebuilding before anything else happens.
Definition: MercuryBase.cc:520
Mdouble totalCurrentMaxRelativeDisplacement_
After each time step, this Mdouble is increased by 2*currentMaxRelativeDisplacement_.
Definition: MercuryBase.h:313
Mdouble getHGridCellOverSizeRatio() const
Gets the ratio of the smallest cell over the smallest particle.
Definition: MercuryBase.cc:477
HGrid * grid
A pointer to the HGrid associated with this MercuryBase.
Definition: MercuryBase.h:281
Mdouble getHGridCurrentMaxRelativeDisplacement() const
Returns hGridCurrentMaxRelativeDisplacement_.
Definition: MercuryBase.cc:154
virtual unsigned int getHGridTargetNumberOfBuckets() const
Gets the desired number of buckets, which is the maximum of the number of particles and 10...
Definition: MercuryBase.cc:558
void setHGridUpdateEachTimeStep(bool updateEachTimeStep)
Sets whether or not the HGrid must be updated every time step.
Definition: MercuryBase.cc:172
virtual Mdouble getHGridTargetMinInteractionRadius() const
Gets the desired size of the smallest cells of the HGrid.
Definition: MercuryBase.cc:575
HGridDistribution hGridDistribution_
Indicator for the distribution of the sizes of the cells of different levels of the HGrid...
Definition: MercuryBase.h:299
double Mdouble
unsigned int hGridMaxLevels_
Unsigned integer that indicates the maximum number of levels of the HGrid.
Definition: MercuryBase.h:341
HGridMethod getHGridMethod() const
Gets whether the HGrid in this MercuryBase is BOTTOMUP or TOPDOWN.
Definition: MercuryBase.cc:439
void hGridUpdateMove(BaseParticle *iP, Mdouble move) override
Computes the relative displacement of the given BaseParticle and updates the currentMaxRelativeDispla...
Definition: MercuryBase.cc:367
Mdouble hGridCellOverSizeRatio_
The maximum ratio between the size of the cells and the BaseParticle they contain.
Definition: MercuryBase.h:349
unsigned int getHGridMaxLevels() const
Gets the maximum number of levels of the HGrid in this MercuryBase.
Definition: MercuryBase.cc:512
void hGridActionsBeforeTimeStep() override
Performs all necessary actions before a time-step, like updating the particles and resetting all the ...
Definition: MercuryBase.cc:324
void hGridInfo() const
Writes the info of the HGrid to the screen in a nice format.
Definition: MercuryBase.cc:642
virtual Mdouble getHGridTargetMaxInteractionRadius() const
Gets the desired size of the largest cells of the HGrid.
Definition: MercuryBase.cc:591
HGridMethod
Enum class that indicates how particles in different levels (cross level checking) of the HGrid are c...
Definition: MercuryBase.h:46
void setHGridMethod(HGridMethod hGridMethod)
Sets the HGridMethod to either BOTTOMUP or TOPDOWN.
Definition: MercuryBase.cc:447
HGridMethod hGridMethod_
Indicator of which way the interactions between different levels are tested.
Definition: MercuryBase.h:293
This is the base class for both Mercury2D and Mercury3D. Note the actually abstract grid is defined i...
Definition: MercuryBase.h:74
Mdouble getHGridTotalCurrentMaxRelativeDisplacement() const
Returns hGridTotalCurrentMaxRelativeDisplacement_.
Definition: MercuryBase.cc:163
void hGridActionsAfterIntegration() override
Sets the totalCurrentMaxRelativeDisplacement_ as 2*currentMaxRelativeDisplacement_.
Definition: MercuryBase.cc:381
void write(std::ostream &os, bool writeAllParticles=true) const override
Writes the MercuryBase to an output stream, for example a restart file.
Definition: MercuryBase.cc:132
In the HGrid class, here all information about the HGrid is stored.
Definition: HGrid.h:41
bool readNextArgument(int &i, int argc, char *argv[]) override
Reads the next command line argument.
Definition: MercuryBase.cc:419
void hGridInsertParticle(BaseParticle *obj) override
Inserts a single Particle to current grid.
Definition: MercuryBase.cc:297
~MercuryBase()
This is the default destructor.
Definition: MercuryBase.cc:40
void setHGridCellOverSizeRatio(Mdouble cellOverSizeRatio)
Sets the ratio of the smallest cell over the smallest particle.
Definition: MercuryBase.cc:487
HGridDistribution
Enum that indicates what the ratio of the size of the cells in different levels is.
Definition: MercuryBase.h:63
bool updateEachTimeStep_
Boolean which indicates whether or not the cell in which a particle is must be updated every timestep...
Definition: MercuryBase.h:327
void setHGridMaxLevels(unsigned int HGridMaxLevels)
Sets the maximum number of levels of the HGrid in this MercuryBase.
Definition: MercuryBase.cc:500
void hGridActionsBeforeTimeLoop() override
This sets up the broad phase information, has to be done at this stage because it requires the partic...
Definition: MercuryBase.cc:95
MercuryBase()
This is the default constructor. It sets sensible defaults.
Definition: MercuryBase.cc:34
void hGridRebuild()
This sets up the parameters required for the contact model.
Definition: MercuryBase.cc:201
virtual bool hGridHasParticleContacts(const BaseParticle *obj)=0
Purely virtual function that checks if the given particle has a possible contact with any other BaseP...
HGridDistribution getHGridDistribution() const
Gets how the sizes of the cells of different levels are distributed.
Definition: MercuryBase.cc:455
void constructor()
This is the actual constructor, it is called do both constructors above.
Definition: MercuryBase.cc:80
bool gridNeedsUpdate_
Boolean that indicates whether or not the grid needs to be updated.
Definition: MercuryBase.h:321
void read(std::istream &is) override
Reads the MercuryBase from an input stream, for example a restart file.
Definition: MercuryBase.cc:105
bool getHGridUpdateEachTimeStep() const override
Gets whether or not the HGrid is updated every time step.
Definition: MercuryBase.cc:180
void broadPhase(BaseParticle *i) override
This checks particles in the HGRID to see if for closer enough for possible contact.
Definition: MercuryBase.cc:314
virtual Mdouble userHGridCellSize(unsigned int level)
Virtual function that enables inheriting classes to implement a function to let the user set the cell...
Definition: MercuryBase.cc:406
void setHGridDistribution(HGridDistribution hGridDistribution)
Sets how the sizes of the cells of different levels are distributed.
Definition: MercuryBase.cc:464
HGrid * getHGrid()
Gets the HGrid used by this problem.
Definition: MercuryBase.cc:389
Mdouble currentMaxRelativeDisplacement_
Mdouble that denotes the maximum of the displacement of a particle divided by the cell size of the le...
Definition: MercuryBase.h:307
void hGridActionsBeforeIntegration() override
Resets the currentMaxRelativeDisplacement_ to 0.
Definition: MercuryBase.cc:376