MercuryDPM  0.11
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ExtremeOverlapUnitTest.cpp
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 #include "DPMBase.h"
26 #include "Particles/BaseParticle.h"
27 #include "Walls/InfiniteWall.h"
28 #include <iostream>
30 #include <Logger.h>
31 
46 public:
47 
54  {
55  //Define the radii of the two particles
56  Mdouble r0=0.01;
57  Mdouble r1=0.001;
58 
59  //Define the bounding box (for viewing the output only; no walls are created)
60  setYMax(2.0*(r0+r1));
61  setYMin(0.0);
62  setZMax(r0);
63  setZMin(-r0);
64  setXMax(r0);
65  setXMin(-r0);
66 
67  //Create both particles and set their positions, radii, and velocities.
68  BaseParticle p;
69  p.setPosition(Vec3D(0.0,r0,0.0));
70  p.setVelocity(Vec3D(0.0,0.0,0.0));
71  p.setRadius(r0);
73  p.setPosition(Vec3D(0.0,1.5*r0,0.0));
74  p.setVelocity(Vec3D(1.0,0.0,0));
75  p.setRadius(r1);
77  }
78 
79 // /*!
80 // * print the time, the position of both particles and the position of the
81 // * contact point to the screen. This allows you to plot these variables in
82 // * gnuplot; you can see that the contact point is not between the two
83 // * particles anymore.
84 // */
85 // void printTime() const final
86 // {
87 // if (interactionHandler.getNumberOfObjects()>0)
88 // std::cout
89 // << getTime() << " "
90 // << particleHandler.getObject(0)->getPosition().Z << " "
91 // << particleHandler.getObject(1)->getPosition().Z << " "
92 // << interactionHandler.getObject(0)->getContactPoint().Z <<std::endl;
93 // }
94 
95 };
96 
97 int main(int argc, char *argv[])
98 {
99  ExtremeOverlapUnitTest OverlapProblem;
100 
101  //set some contact parameters; the contact is elastic (so we can check
102  //energy conservation), and very soft (so the particles repel each other slowly))
103  //To check Energy conservation, use gnuplot:
104  // p 'ExtremeOverlapUnitTest.ene' u 1:($2+$3+$4+$5)
106  species->setDensity(2000);
107  species->setStiffness(1e1);
108  species->setDissipation(0.0);
109  species->setSlidingFrictionCoefficient(1.0);
110  species->setSlidingStiffness(2.0/7.0*species->getStiffness());
111  species->setSlidingDissipation(2.0/7.0*species->getDissipation());
112 
113  OverlapProblem.setName("ExtremeOverlapUnitTest");
114  OverlapProblem.setFileType(FileType::NO_FILE);
115  OverlapProblem.dataFile.setFileType(FileType::ONE_FILE);
116  OverlapProblem.setSaveCount(10000);
117  OverlapProblem.setDimension(2);
118  OverlapProblem.setTimeStep(1e-8);
119  OverlapProblem.setTimeMax(0.01);
120  OverlapProblem.solve(argc,argv);
121 
122  Vec3D position = OverlapProblem.particleHandler.getObject(0)->getPosition();
123  Vec3D positionToCompare = Vec3D(-1.031389999146e-06, 0.009506389407855, 0);
124  if (!position.isEqualTo(positionToCompare, 1e-10))
125  logger(FATAL,"Large particle is in the wrong position. It is at % and should be %",position,positionToCompare);
126  else
127  std::cout << "Test passed" << std::endl;
128  position = OverlapProblem.particleHandler.getObject(1)->getPosition();
129  positionToCompare = Vec3D(0.01010314899993, 0.01487096023445, 0);
130  if (!position.isEqualTo(positionToCompare, 1e-10))
131  logger(FATAL,"Large particle is in the wrong position. It is at % and should be %",position,positionToCompare);
132  else
133  std::cout << "Test passed" << std::endl;
134  //std::cout.precision(13); std::cout << position << std::endl;
135  return 0;
136 }
void setXMax(Mdouble newXMax)
If the length of the problem domain in x-direction is XMax - XMin, this method sets XMax...
Definition: DPMBase.cc:309
void solve()
The work horse of the code.
Definition: DPMBase.cc:1895
The DPMBase header includes quite a few header files, defining all the handlers, which are essential...
Definition: DPMBase.h:61
void setVelocity(const Vec3D &velocity)
set the velocity of the BaseInteractable.
void setTimeMax(Mdouble newTMax)
Allows the upper time limit to be changed.
Definition: DPMBase.cc:179
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
void setYMin(Mdouble newYMin)
If the length of the problem domain in y-direction is YMax - YMin, this method sets YMin...
Definition: DPMBase.cc:280
void setZMax(Mdouble newZMax)
If the length of the problem domain in z-direction is XMax - XMin, this method sets ZMax...
Definition: DPMBase.cc:338
void setDimension(unsigned int newDim)
Sets the system and particle dimension.
Definition: DPMBase.cc:445
Species< LinearViscoelasticNormalSpecies, SlidingFrictionSpecies > LinearViscoelasticSlidingFrictionSpecies
void setFileType(FileType fileType)
Sets File::fileType_ for all files (ene, data, fstat, restart, stat)
Definition: Files.cc:169
bool isEqualTo(const Vec3D &other, const double tol) const
Checks if the length this Vec3D is equal the length of other with a certain tolerance.
Definition: Vector.cc:390
void setRadius(const Mdouble radius)
Sets the particle's radius_ (and adjusts the mass_ accordingly, based on the particle's species) ...
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
void setYMax(Mdouble newYMax)
If the length of the problem domain in y-direction is YMax - YMin, this method sets YMax...
Definition: DPMBase.cc:324
file will not be created/read
void setName(const std::string &name)
Allows to set the name of all the files (ene, data, fstat, restart, stat)
Definition: Files.cc:149
U * copyAndAddObject(const U &O)
Creates a copy of a Object and adds it to the BaseHandler.
Definition: BaseHandler.h:268
void setXMin(Mdouble newXMin)
If the length of the problem domain in x-direction is XMax - XMin, this method sets XMin...
Definition: DPMBase.cc:266
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:878
all data will be written into/ read from a single file called name_
T * getObject(const unsigned int id)
Gets a pointer to the Object at the specified index in the BaseHandler.
Definition: BaseHandler.h:415
Makes sure that the behavior is still sensible if the overlap of two particles grows extremely large...
LL< Log::FATAL > FATAL
Fatal log level.
Definition: Logger.cc:25
void setSaveCount(unsigned int saveCount)
Sets File::saveCount_ for all files (ene, data, fstat, restart, stat)
Definition: Files.cc:138
File dataFile
An instance of class File to handle in- and output into a .data file.
Definition: Files.h:204
void setZMin(Mdouble newZMin)
If the length of the problem domain in z-direction is ZMax - ZMin, this method sets ZMin...
Definition: DPMBase.cc:295
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. elastic, linear visco-elastic... et cetera...
Definition: DPMBase.h:868
void setFileType(FileType fileType)
Sets the type of file needed to write into or read from. File::fileType_.
Definition: File.cc:209
void setPosition(const Vec3D &position)
Sets the position of this BaseInteractable.
void setTimeStep(Mdouble newDt)
Allows the time step dt to be changed.
Definition: DPMBase.cc:353
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:45
int main(int argc, char *argv[])