Codes for tutorials

Particle motion in outer space (code)

Return to tutorial T1: Particle motion in outer space

1 //Copyright (c) 2013-2023, 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 // Tutorial 1
27 
28 /*
29 ** This file is annotated with DoxyFile comments in order to show the code on
30 ** the documentation - This is not needed for your real drivers.
31 ** Please ignore these comments.
32 **
33 ** For full documentation of this code, go to http://docs.mercurydpm.org/Alpha/d0/db0/BeginnerTutorials.html#T1
34 */
35 
37 #include <Mercury3D.h>
38 #include <Species/Species.h>
41 
43 class Tutorial1 : public Mercury3D
44 {
45 
46 public:
47 
48  void setupInitialConditions() override {
52  p0.setRadius(0.05); // sets particle radius
53  p0.setPosition(Vec3D(0.1 * getXMax(), 0.1 * getYMax(), 0.1 * getZMax())); // sets particle position
54  p0.setVelocity(Vec3D(0.5, 0.1, 0.1));// sets particle velocity
57  }
58 };
60 
62 int main(int argc, char* argv[])
63 {
64  // Problem setup
65  Tutorial1 problem;
66 
68  problem.setName("Tutorial1");
69  problem.setSystemDimensions(3);
70  problem.setGravity(Vec3D(0.0, 0.0, 0.0));
71  problem.setXMax(1.0);
72  problem.setYMax(1.0);
73  problem.setZMax(1.0);
74  problem.setTimeMax(2.0);
76 
78  //Set the species of particles and walls
79  //The normal spring stiffness and normal dissipation is computed and set as
80  //For collision time tc=0.005 and restitution coefficeint rc=1.0
82  species.setDensity(2500.0); //sets the species type_0 density
83  species.setStiffness(258.5);//sets the spring stiffness.
84  species.setDissipation(0.0); //sets the dissipation.
85  problem.speciesHandler.copyAndAddObject(species);
87 
89  problem.setSaveCount(10);
94  logger(INFO, "run number: %", problem.dataFile.getCounter());
96 
98  problem.setXBallsAdditionalArguments("-solidf -v0");
100 
102  problem.setTimeStep(0.005 / 50.0); // (collision time)/50.0
103  problem.solve(argc, argv);
105  return 0;
106 }
@ NO_FILE
file will not be created/read
@ ONE_FILE
all data will be written into/ read from a single file called name_
LL< Log::INFO > INFO
Info log level.
Definition: Logger.cc:55
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
int main(int argc, char *argv[])
[T1:class]
Definition: Tutorial1_ParticleInOuterSpace.cpp:62
std::enable_if<!std::is_pointer< U >::value, U * >::type copyAndAddObject(const U &object)
Creates a copy of a Object and adds it to the BaseHandler.
Definition: BaseHandler.h:379
T * getObject(const unsigned int id)
Gets a pointer to the Object at the specified index in the BaseHandler.
Definition: BaseHandler.h:613
void setVelocity(const Vec3D &velocity)
set the velocity of the BaseInteractable.
Definition: BaseInteractable.cc:350
virtual void setPosition(const Vec3D &position)
Sets the position of this BaseInteractable.
Definition: BaseInteractable.h:239
virtual void setRadius(Mdouble radius)
Sets the particle's radius_ (and adjusts the mass_ accordingly, based on the particle's species)
Definition: BaseParticle.cc:553
void setSpecies(const ParticleSpecies *species)
Definition: BaseParticle.cc:818
Mdouble getXMax() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMax() returns XMax.
Definition: DPMBase.h:626
void setSaveCount(unsigned int saveCount)
Sets File::saveCount_ for all files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:408
File eneFile
An instance of class File to handle in- and output into a .ene file.
Definition: DPMBase.h:1488
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. LinearViscoelasticSpecies, etc.
Definition: DPMBase.h:1427
File fStatFile
An instance of class File to handle in- and output into a .fstat file.
Definition: DPMBase.h:1483
void setName(const std::string &name)
Allows to set the name of all the files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:422
File dataFile
An instance of class File to handle in- and output into a .data file.
Definition: DPMBase.h:1478
void setYMax(Mdouble newYMax)
Sets the value of YMax, the upper bound of the problem domain in the y-direction.
Definition: DPMBase.cc:1191
File restartFile
An instance of class File to handle in- and output into a .restart file.
Definition: DPMBase.h:1493
void setXBallsAdditionalArguments(std::string newXBArgs)
Set the additional arguments for xballs.
Definition: DPMBase.cc:1347
void setXMax(Mdouble newXMax)
Sets the value of XMax, the upper bound of the problem domain in the x-direction.
Definition: DPMBase.cc:1165
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created.
Definition: DPMBase.h:1437
void setZMax(Mdouble newZMax)
Sets the value of ZMax, the upper bound of the problem domain in the z-direction.
Definition: DPMBase.cc:1217
Mdouble getYMax() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMax() returns XMax.
Definition: DPMBase.h:638
void setTimeStep(Mdouble newDt)
Sets a new value for the simulation time step.
Definition: DPMBase.cc:1234
void setTimeMax(Mdouble newTMax)
Sets a new value for the maximum simulation duration.
Definition: DPMBase.cc:873
void setSystemDimensions(unsigned int newDim)
Sets the system dimensionality.
Definition: DPMBase.cc:1417
void solve()
The work horse of the code.
Definition: DPMBase.cc:4270
void setGravity(Vec3D newGravity)
Sets a new value for the gravitational acceleration.
Definition: DPMBase.cc:1383
Mdouble getZMax() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMax() returns ZMax.
Definition: DPMBase.h:650
void setFileType(FileType fileType)
Sets the type of file needed to write into or read from. File::fileType_.
Definition: File.cc:215
unsigned int getCounter() const
In case of multiple files, File::getCounter() returns the the number (FILE::Counter_) of the next fil...
Definition: File.cc:223
void setDissipation(Mdouble dissipation)
Allows the normal dissipation to be changed.
Definition: LinearViscoelasticNormalSpecies.cc:117
void setStiffness(Mdouble new_k)
Allows the spring constant to be changed.
Definition: LinearViscoelasticNormalSpecies.cc:93
This adds on the hierarchical grid code for 3D problems.
Definition: Mercury3D.h:37
void setDensity(Mdouble density)
Definition: ParticleSpecies.cc:108
A spherical particle is the most simple particle used in MercuryDPM.
Definition: SphericalParticle.h:37
[T1:headers]
Definition: Tutorial1_ParticleInOuterSpace.cpp:44
void setupInitialConditions() override
This function allows to set the initial conditions for our problem to be solved, by default particle ...
Definition: Tutorial1_ParticleInOuterSpace.cpp:48
Definition: Vector.h:51

Return to tutorial T1: Particle motion in outer space

Particle motion on earth (code)

Return to tutorial T2: Particle motion on earth

1 //Copyright (c) 2013-2023, 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 // Tutorial 2
27 
28 /*
29 ** This file is annotated with DoxyFile comments in order to show the code on
30 ** the documentation - This is not needed for your real drivers.
31 ** Please ignore these comments.
32 **
33 ** For full documentation of this code, go to http://docs.mercurydpm.org/Alpha/d0/db0/BeginnerTutorials.html#T2
34 */
35 
38 #include <Mercury3D.h>
40 
42 class Tutorial2 : public Mercury3D
43 {
44 public:
45 
46  void setupInitialConditions() override {
50  p0.setRadius(0.05);
51  p0.setPosition(Vec3D(0.5 * getXMax(), 0.5 * getYMax(), getZMax()));
52  p0.setVelocity(Vec3D(0.0, 0.0, 0.0));
55  }
56 
57 };
59 
61 int main(int argc, char* argv[])
62 {
63  // Problem setup
64  Tutorial2 problem;
65 
67  problem.setName("Tutorial2");
68  problem.setSystemDimensions(3);
69  problem.setGravity(Vec3D(0.0, 0.0, -9.81));
70  problem.setXMax(1.0);
71  problem.setYMax(1.0);
72  problem.setZMax(5.0);
73  problem.setTimeMax(1.5);
75 
77  // The normal spring stiffness and normal dissipation is computed and set as
78  // For collision time tc=0.005 and restitution coefficeint rc=1.0,
80  species.setDensity(2500.0); //sets the species type_0 density
81  species.setStiffness(258.5);//sets the spring stiffness.
82  species.setDissipation(0.0); //sets the dissipation.
83  problem.speciesHandler.copyAndAddObject(species);
85 
87  problem.setSaveCount(10);
93 
95  problem.setXBallsAdditionalArguments("-solidf -v0");
97 
99  problem.setTimeStep(.005 / 50.0);// (collision time)/50.0
100  problem.solve(argc, argv);
102 
103  return 0;
104 }
int main(int argc, char *argv[])
[T2:class]
Definition: Tutorial2_ParticleUnderGravity.cpp:61
[T2:headers]
Definition: Tutorial2_ParticleUnderGravity.cpp:43
void setupInitialConditions() override
This function allows to set the initial conditions for our problem to be solved, by default particle ...
Definition: Tutorial2_ParticleUnderGravity.cpp:46

Return to tutorial T2: Particle motion on earth

Bouncing ball - elastic (code)

Return to tutorial T3: Bouncing ball (elastic)

1 //Copyright (c) 2013-2023, 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 // Tutorial 3
27 
28 /*
29 ** This file is annotated with DoxyFile comments in order to show the code on
30 ** the documentation - This is not needed for your real drivers.
31 ** Please ignore these comments.
32 **
33 ** For full documentation of this code, go to http://docs.mercurydpm.org/Alpha/d0/db0/BeginnerTutorials.html#T3
34 */
35 
38 #include <Mercury3D.h>
39 #include <Walls/InfiniteWall.h>
41 
43 class Tutorial3 : public Mercury3D
44 {
45 public:
46 
47  void setupInitialConditions() override {
50  p0.setRadius(0.005);
51  p0.setPosition(Vec3D(0.5 * getXMax(), 0.5 * getYMax(), getZMax()));
52  p0.setVelocity(Vec3D(0.0, 0.0, 0.0));
54 
56  InfiniteWall w0;
58  w0.set(Vec3D(0.0, 0.0, -1.0), Vec3D(0, 0, getZMin()));
61  }
62 
63 };
65 
66 int main(int argc, char* argv[])
67 {
68 
69  // Problem setup
70  Tutorial3 problem;
71 
72  problem.setName("Tutorial3");
73  problem.setSystemDimensions(3);
74  problem.setGravity(Vec3D(0.0, 0.0, -9.81));
75  problem.setXMax(1.0);
76  problem.setYMax(1.0);
77  problem.setZMax(2.0);
78  problem.setTimeMax(5.0);
79 
81  // The normal spring stiffness and normal dissipation is computed and set as
82  // For collision time tc=0.005 and restitution coefficeint rc=1.0,
84  species.setDensity(2500.0); //sets the species type_0 density
85  species.setStiffness(258.5);//sets the spring stiffness.
86  species.setDissipation(0.0); //sets the dissipation.
87  problem.speciesHandler.copyAndAddObject(species);
89 
90  problem.setSaveCount(10);
95 
96  problem.setXBallsAdditionalArguments("-solidf -v0");
97  problem.wallHandler.setWriteVTK(true);
98  problem.setParticlesWriteVTK(true);
99 
100  problem.setTimeStep(0.005 / 50.0); // (collision time)/50.0
101  problem.solve(argc, argv);
102 
103  return 0;
104 }
int main(int argc, char *argv[])
[T3:class]
Definition: Tutorial3_BouncingBallElastic.cpp:66
void setSpecies(const ParticleSpecies *species)
Defines the species of the current wall.
Definition: BaseWall.cc:169
WallHandler wallHandler
An object of the class WallHandler. Contains pointers to all the walls created.
Definition: DPMBase.h:1447
void setParticlesWriteVTK(bool writeParticlesVTK)
Sets whether particles are written in a VTK file.
Definition: DPMBase.cc:942
Mdouble getZMin() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMin() returns ZMin.
Definition: DPMBase.h:644
A infinite wall fills the half-space {point: (position_-point)*normal_<=0}.
Definition: InfiniteWall.h:48
void set(Vec3D normal, Vec3D point)
Defines a standard wall, given an outward normal vector s.t. normal*x=normal*point for all x of the w...
Definition: InfiniteWall.cc:118
[T3:headers]
Definition: Tutorial3_BouncingBallElastic.cpp:44
void setupInitialConditions() override
This function allows to set the initial conditions for our problem to be solved, by default particle ...
Definition: Tutorial3_BouncingBallElastic.cpp:47
void setWriteVTK(FileType)
Sets whether walls are written into a VTK file.
Definition: WallHandler.cc:467

Return to tutorial T3: Bouncing ball (elastic)

Bouncing ball - inelastic (code)

Return to tutorial T4: Bouncing ball with dissipation (inelastic)

1 //Copyright (c) 2013-2023, 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 // Tutorial 4
27 
28 /*
29 ** This file is annotated with DoxyFile comments in order to show the code on
30 ** the documentation - This is not needed for your real drivers.
31 ** Please ignore these comments.
32 **
33 ** For full documentation of this code, go to http://docs.mercurydpm.org/Alpha/d0/db0/BeginnerTutorials.html#T4
34 */
35 
37 #include <Mercury3D.h>
38 #include <Walls/InfiniteWall.h>
39 
40 class Tutorial4 : public Mercury3D
41 {
42 public:
43 
44  void setupInitialConditions() override {
47  p0.setRadius(0.005);
48  p0.setPosition(Vec3D(0.5 * getXMax(), 0.5 * getYMax(), getZMax()));
49  p0.setVelocity(Vec3D(0.0, 0.0, 0.0));
51 
52  InfiniteWall w0;
54  w0.set(Vec3D(0.0, 0.0, -1.0), Vec3D(0.0, 0.0, getZMin()));
56  }
57 
58 };
59 
60 int main(int argc, char* argv[])
61 {
62 
63  // Problem setup
64  Tutorial4 problem;
65 
66  problem.setName("Tutorial4");
67  problem.setSystemDimensions(3);
68  problem.setGravity(Vec3D(0.0, 0.0, -9.81));
69  problem.setXMax(1.0);
70  problem.setYMax(1.0);
71  problem.setZMax(2.0);
72  problem.setTimeMax(5.0);
73 
75  // The normal spring stiffness and normal dissipation is computed and set as
76  // For collision time tc=0.005 and restitution coefficeint rc=0.88,
78  species.setDensity(2500.0); //sets the species type_0 density
79  species.setStiffness(258.5);//sets the spring stiffness.
80  species.setDissipation(0.0334); //sets the dissipation.
81  problem.speciesHandler.copyAndAddObject(species);
83 
84  problem.setSaveCount(10);
89 
90  problem.setXBallsAdditionalArguments("-solidf -v0");
91 
92  problem.setTimeStep(0.005 / 50.0); // (collision time)/50.0
93  problem.solve(argc, argv);
94 
95  return 0;
96 }
int main(int argc, char *argv[])
Definition: Tutorial4_BouncingBallInelastic.cpp:60
Definition: Tutorial4_BouncingBallInelastic.cpp:41
void setupInitialConditions() override
This function allows to set the initial conditions for our problem to be solved, by default particle ...
Definition: Tutorial4_BouncingBallInelastic.cpp:44

Return to tutorial T4: Bouncing ball with dissipation (inelastic)

Elastic collision - 2 particles (code)

Return to tutorial T5: Elastic collision (2 particles)

1 //Copyright (c) 2013-2023, 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 // Tutorial 5
27 
28 /*
29 ** This file is annotated with DoxyFile comments in order to show the code on
30 ** the documentation - This is not needed for your real drivers.
31 ** Please ignore these comments.
32 **
33 ** For full documentation of this code, go to http://docs.mercurydpm.org/Alpha/d0/db0/BeginnerTutorials.html#T5
34 */
35 
38 #include <Mercury3D.h>
40 
42 class Tutorial5 : public Mercury3D
43 {
44 public:
45 
46  void setupInitialConditions() override {
49 
50  p0.setRadius(0.005); //particle-1 radius
51  p0.setPosition(Vec3D(0.25 * getXMax(), 0.5 * getYMax(), 0.5 * getZMax()));
52  p0.setVelocity(Vec3D(0.25, 0.0, 0.0));
53  particleHandler.copyAndAddObject(p0); // 1st particle created
54 
55  p0.setRadius(0.005); // particle-2 radius
56  p0.setPosition(Vec3D(0.75 * getXMax(), 0.5 * getYMax(), 0.5 * getZMax()));
57  p0.setVelocity(Vec3D(-0.25, 0.0, 0.0));
58  particleHandler.copyAndAddObject(p0); // 2nd particle created
59  }
60 
61 };
63 
65 int main(int argc, char* argv[])
66 {
67 
68  // Problem setup
69  Tutorial5 problem;
70 
71  problem.setName("Tutorial5");
72  problem.setSystemDimensions(3);
73  problem.setGravity(Vec3D(0.0, 0.0, 0.0));
74  problem.setXMax(0.5);
75  problem.setYMax(0.25);
76  problem.setZMax(0.5);
77  problem.setTimeMax(2.0);
78 
80  // The normal spring stiffness and normal dissipation is computed and set as
81  // For collision time tc=0.005 and restitution coefficeint rc=1.0,
83  species.setDensity(2500.0); //sets the species type_0 density
84  species.setStiffness(258.5);//sets the spring stiffness.
85  species.setDissipation(0.0); //sets the dissipation.
86  problem.speciesHandler.copyAndAddObject(species);
88 
89  problem.setSaveCount(10);
94 
95  problem.setXBallsAdditionalArguments("-solidf -v0 -s .85");
96 
97  problem.setTimeStep(.005 / 50.0); // (collision time)/50.0
98  problem.solve(argc, argv);
99 
100  return 0;
101 }
int main(int argc, char *argv[])
[T5:class]
Definition: Tutorial5_ElasticCollision.cpp:65
[T5:headers]
Definition: Tutorial5_ElasticCollision.cpp:43
void setupInitialConditions() override
This function allows to set the initial conditions for our problem to be solved, by default particle ...
Definition: Tutorial5_ElasticCollision.cpp:46

Return to tutorial T5: Elastic collision (2 particles)

Elastic collisions with periodic boundaries (code)

Return to tutorial T6: Elastic collisions with periodic boundaries

1 //Copyright (c) 2013-2023, 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 // Tutorial 6
27 
28 /*
29 ** This file is annotated with DoxyFile comments in order to show the code on
30 ** the documentation - This is not needed for your real drivers.
31 ** Please ignore these comments.
32 **
33 ** For full documentation of this code, go to http://docs.mercurydpm.org/Alpha/d0/db0/BeginnerTutorials.html#T6
34 */
35 
38 #include <Mercury3D.h>
41 
43 class Tutorial6 : public Mercury3D
44 {
45 public:
46 
47  void setupInitialConditions() override {
50  p0.setRadius(0.005);//particle-1
51  p0.setPosition(Vec3D(0.25 * getXMax(), 0.5 * getYMax(), 0.5 * getZMax()));
52  p0.setVelocity(Vec3D(0.25, 0.0, 0.0));
54 
55  p0.setRadius(0.005);// particle-2
56  p0.setPosition(Vec3D(0.75 * getXMax(), 0.5 * getYMax(), 0.5 * getZMax()));
57  p0.setVelocity(Vec3D(-0.25, 0.0, 0.0));
59 
62  b0.set(Vec3D(1.0, 0.0, 0.0), getXMin(), getXMax());
65  }
66 
67 };
69 
70 int main(int argc, char* argv[])
71 {
72 
73  // Problem setup
74  Tutorial6 problem; // instantiate an object of class Tutorial 6
75 
76  problem.setName("Tutorial6");
77  problem.setSystemDimensions(3);
78  problem.setGravity(Vec3D(0.0, 0.0, 0.0));
79  problem.setXMax(0.5);
80  problem.setYMax(0.25);
81  problem.setZMax(0.5);
82  problem.setTimeMax(5.0);
83 
85  // The normal spring stiffness and normal dissipation is computed and set as
86  // For collision time tc=0.005 and restitution coefficeint rc=1.0,
88  species.setDensity(2500.0); //sets the species type_0 density
89  species.setStiffness(258.5);//sets the spring stiffness.
90  species.setDissipation(0.0); //sets the dissipation.
91  problem.speciesHandler.copyAndAddObject(species);
92 
94 
95  problem.setSaveCount(10);
100 
101  problem.setXBallsAdditionalArguments("-solidf -v0 -s .85");
102 
103  problem.setTimeStep(0.005 / 50.0);// (collision time)/50.0
104  problem.solve(argc, argv);
105 
106  return 0;
107 }
int main(int argc, char *argv[])
[T6:class]
Definition: Tutorial6_ElasticCollisionPeriodic.cpp:70
Mdouble getXMin() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMin() returns XMin.
Definition: DPMBase.h:619
BoundaryHandler boundaryHandler
An object of the class BoundaryHandler which concerns insertion and deletion of particles into or fro...
Definition: DPMBase.h:1452
Defines a pair of periodic walls. Inherits from BaseBoundary.
Definition: PeriodicBoundary.h:41
void set(Vec3D normal, Mdouble distanceLeft, Mdouble distanceRight)
Defines a PeriodicBoundary by its normal and positions.
Definition: PeriodicBoundary.cc:84
[T6:headers]
Definition: Tutorial6_ElasticCollisionPeriodic.cpp:44
void setupInitialConditions() override
This function allows to set the initial conditions for our problem to be solved, by default particle ...
Definition: Tutorial6_ElasticCollisionPeriodic.cpp:47

Return to tutorial T6: Elastic collisions with periodic boundaries

Motion of a particle in a two dimensional box (code)

Return to tutorial T7: Motion of a particle in a two dimensional (2D) box

1 //Copyright (c) 2013-2023, 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 // Tutorial 7
27 
28 /*
29 ** This file is annotated with DoxyFile comments in order to show the code on
30 ** the documentation - This is not needed for your real drivers.
31 ** Please ignore these comments.
32 **
33 ** For full documentation of this code, go to http://docs.mercurydpm.org/Alpha/d0/db0/BeginnerTutorials.html#T7
34 */
35 
38 #include <Mercury3D.h>
39 #include <Walls/InfiniteWall.h>
41 
43 class Tutorial7 : public Mercury3D
44 {
45 public:
46 
47  void setupInitialConditions() override {
50  p0.setRadius(0.005);
51  p0.setPosition(Vec3D(0.5 * getXMax(), 0.5 * getYMax(), 0.0));
52  p0.setVelocity(Vec3D(1.2, 1.3, 0.0));
54 
56  InfiniteWall w0;
57 
59  w0.set(Vec3D(1.0, 0.0, 0.0), Vec3D(getXMax(), 0.0, 0.0));
61 
62  w0.set(Vec3D(-1.0, 0.0, 0.0), Vec3D(getXMin(), 0.0, 0.0));
64 
65  w0.set(Vec3D(0.0, 1.0, 0.0), Vec3D(0.0, getYMax(), 0.0));
67 
68  w0.set(Vec3D(0.0, -1.0, 0.0), Vec3D(0.0, getYMin(), 0.0));
71  }
72 
73 };
75 
76 int main(int argc, char* argv[])
77 {
78  // Problem setup
79  Tutorial7 problem; // instantiate an object of class Tutorial 6
80 
81  problem.setName("Tutorial7");
82  problem.setSystemDimensions(2);
83  problem.setGravity(Vec3D(0.0, 0.0, 0.0));
84  problem.setXMax(1);
85  problem.setYMax(0.5);
86  problem.setZMax(1.0);
87  problem.setTimeMax(1.0);
88 
90  // The normal spring stiffness and normal dissipation is computed and set as
91  // For collision time tc=0.005 and restitution coefficeint rc=1.0,
93  species.setDensity(2500.0); //sets the species type_0 density
94  species.setStiffness(258.5);//sets the spring stiffness.
95  species.setDissipation(0.0); //sets the dissipation.
96  problem.speciesHandler.copyAndAddObject(species);
98 
99  problem.setSaveCount(10);
104 
106  problem.setParticlesWriteVTK(true);
107 
108  problem.setXBallsAdditionalArguments("-solidf -v0 -s .85");
109 
110  problem.setTimeStep(0.005 / 50.0);// (collision time)/50.0
111  problem.solve(argc, argv);
112 
113  return 0;
114 }
int main(int argc, char *argv[])
[T7:class]
Definition: Tutorial7_ParticleIn2DBox.cpp:76
Mdouble getYMin() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMin() returns YMin.
Definition: DPMBase.h:632
[T7:headers]
Definition: Tutorial7_ParticleIn2DBox.cpp:44
void setupInitialConditions() override
This function allows to set the initial conditions for our problem to be solved, by default particle ...
Definition: Tutorial7_ParticleIn2DBox.cpp:47

Return to tutorial T7: Motion of a particle in a two dimensional (2D) box

Motion of a particle in a box with an obstacle (code)

Return to tutorial T8: Motion of a particle in a box with an obstacle

1 //Copyright (c) 2013-2023, 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 // Tutorial 8
27 
28 /*
29 ** This file is annotated with DoxyFile comments in order to show the code on
30 ** the documentation - This is not needed for your real drivers.
31 ** Please ignore these comments.
32 **
33 ** For full documentation of this code, go to http://docs.mercurydpm.org/Alpha/d0/db0/BeginnerTutorials.html#T8
34 */
35 
38 #include <Mercury3D.h>
39 #include <Walls/InfiniteWall.h>
42 
44 class Tutorial8 : public Mercury3D
45 {
46 public:
47 
48  void setupInitialConditions() override {
51  p0.setRadius(0.005);
52  p0.setPosition(Vec3D(0.15 * getXMax(), 0.3335 * getYMax(), 0.0));
53  p0.setVelocity(Vec3D(1.2, 0.2, 0.0));
55 
57  InfiniteWall w0;
58 
60  w0.set(Vec3D(1.0, 0.0, 0.0), Vec3D(getXMax(), 0.0, 0.0));
62 
63  w0.set(Vec3D(-1.0, 0.0, 0.0), Vec3D(getXMin(), 0.0, 0.0));
65 
66  w0.set(Vec3D(0.0, 1.0, 0.0), Vec3D(0.0, getYMax(), 0.0));
68 
69  w0.set(Vec3D(0.0, -1.0, 0.0), Vec3D(0.0, getYMin(), 0.0));
72 
76 
77  w1.addObject(Vec3D(-1.0, 0.0, 0.0), Vec3D(0.75 * getXMax(), 0.0, 0.0));
78  w1.addObject(Vec3D(1.0, 0.0, 0.0), Vec3D(0.25 * getXMax(), 0.0, 0.0));
79  w1.addObject(Vec3D(0.0, -1.0, 0.0), Vec3D(0.0, 0.75 * getYMax(), 0.0));
80  w1.addObject(Vec3D(0.0, 1.0, 0.0), Vec3D(0.0, 0.25 * getYMax(), 0.0));
83  }
84 
85 };
87 
88 int main(int argc, char* argv[])
89 {
90 
91  // Problem setup
92  Tutorial8 problem; // instantiate an object of class Tutorial 8
93 
94  problem.setName("Tutorial8");
95  problem.setSystemDimensions(2);
96  problem.setGravity(Vec3D(0.0, 0.0, 0.0));
97  problem.setXMax(0.5);
98  problem.setYMax(0.5);
99  problem.setTimeMax(5.0);
100 
102  // The normal spring stiffness and normal dissipation is computed and set as
103  // For collision time tc=0.005 and restitution coefficeint rc=1.0,
105  species.setDensity(2500.0); //sets the species type_0 density
106  species.setStiffness(258.5);//sets the spring stiffness.
107  species.setDissipation(0.0); //sets the dissipation.
108  problem.speciesHandler.copyAndAddObject(species);
109 
111 
112  problem.setSaveCount(10);
117 
118  problem.setXBallsAdditionalArguments("-solidf -v0 -s .85");
119 
120  problem.setTimeStep(.005 / 50.0); // (collision time)/50.0
121  problem.solve(argc, argv);
122 
123  return 0;
124 }
int main(int argc, char *argv[])
[T8:class]
Definition: Tutorial8_ParticleIn2DBoxWithObstacle.cpp:88
A IntersectionOfWalls is convex polygon defined as an intersection of InfiniteWall's.
Definition: IntersectionOfWalls.h:59
void addObject(Vec3D normal, Vec3D point)
Adds a wall to the set of infinite walls, given a normal vector pointing into the wall (i....
Definition: IntersectionOfWalls.cc:138
void setSpecies(const ParticleSpecies *species)
sets species of subwalls as well
Definition: IntersectionOfWalls.cc:72
[T8:headers]
Definition: Tutorial8_ParticleIn2DBoxWithObstacle.cpp:45
void setupInitialConditions() override
This function allows to set the initial conditions for our problem to be solved, by default particle ...
Definition: Tutorial8_ParticleIn2DBoxWithObstacle.cpp:48

Return to tutorial T8: Motion of a particle in a box with an obstacle

Motion of a ball over an inclined plane (code)

Return to tutorial T9: Motion of a ball over an inclined plane (Sliding + Rolling)

1 //Copyright (c) 2013-2023, 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 // Tutorial 9
27 
28 /*
29 ** This file is annotated with DoxyFile comments in order to show the code on
30 ** the documentation - This is not needed for your real drivers.
31 ** Please ignore these comments.
32 **
33 ** For full documentation of this code, go to http://docs.mercurydpm.org/Alpha/d0/db0/BeginnerTutorials.html#T9
34 */
35 
38 #include <Mercury3D.h>
39 #include <Walls/InfiniteWall.h>
41 
43 class Tutorial9 : public Mercury3D
44 {
45 public:
46 
47  void setupInitialConditions() override {
49 
50  //sets the particle to species type-1
52  p0.setRadius(0.005);
53  p0.setPosition(Vec3D(0.05 * getXMax(), 0.01 * getYMax(), getZMin() + p0.getRadius()));
54  p0.setVelocity(Vec3D(0.0, 0.0, 0.0));
56 
57  //sets the particle to species type-2
59  p0.setRadius(0.005);
60  p0.setPosition(Vec3D(0.05 * getXMax(), 0.21 * getYMax(), getZMin() + p0.getRadius()));
61  p0.setVelocity(Vec3D(0.0, 0.0, 0.0));
63 
64  //sets the particle to species type-3
66  p0.setRadius(0.005);
67  p0.setPosition(Vec3D(0.05 * getXMax(), 0.41 * getYMax(), getZMin() + p0.getRadius()));
68  p0.setVelocity(Vec3D(0.0, 0.0, 0.0));
70 
72  InfiniteWall w0;
73 
75  w0.set(Vec3D(0.0, 0.0, -1.0), Vec3D(0.0, 0.0, getZMin()));
78  }
79 };
81 
83 int main(int argc, char* argv[])
84 {
85 
86  // Problem setup
87  Tutorial9 problem;//instantiate an object of class Tutorial 9
88 
89  double angle = constants::pi / 180.0 * 20.0;
90 
91  problem.setName("Tutorial9");
92  problem.setSystemDimensions(3);
93  problem.setGravity(Vec3D(sin(angle), 0.0, -cos(angle)) * 9.81);
94  problem.setXMax(0.3);
95  problem.setYMax(0.3);
96  problem.setZMax(0.05);
97  problem.setTimeMax(0.5);
98 
99  // The normal spring stiffness and normal dissipation is computed and set as
100  // For collision time tc=0.005 and restitution coefficeint rc=0.88,
101 
102  //Properties index 0
104 
105  species0.setDensity(2500.0);//sets the species type_0 density
106  species0.setStiffness(259.018);//sets the spring stiffness.
107  species0.setDissipation(0.0334);//sets the dissipation.
108  species0.setSlidingStiffness(2.0 / 7.0 * species0.getStiffness());
109  species0.setRollingStiffness(2.0 / 5.0 * species0.getStiffness());
110  species0.setSlidingFrictionCoefficient(0.0);
111  species0.setRollingFrictionCoefficient(0.0);
112  auto ptrToSp0=problem.speciesHandler.copyAndAddObject(species0);
113 
114  //Properties index 1
116 
117  species1.setDensity(2500.0);//sets the species type-1 density
118  species1.setStiffness(259.018);//sets the spring stiffness
119  species1.setDissipation(0.0334);//sets the dissipation
120  species1.setSlidingStiffness(2.0 / 7.0 * species1.getStiffness());
121  species1.setRollingStiffness(2.0 / 5.0 * species1.getStiffness());
122  species1.setSlidingFrictionCoefficient(0.5);
123  species1.setRollingFrictionCoefficient(0.0);
124  auto ptrToSp1=problem.speciesHandler.copyAndAddObject(species1);
125 
126  //Combination of properties index 0 and index 1
127  auto species01 = problem.speciesHandler.getMixedObject(ptrToSp0,ptrToSp1);
128 
129  species01->setStiffness(259.018);//sets the spring stiffness
130  species01->setDissipation(0.0334);//sets the dissipation
131  species01->setSlidingStiffness(2.0 / 7.0 * species01->getStiffness());
132  species01->setRollingStiffness(2.0 / 5.0 * species01->getStiffness());
133  species01->setSlidingFrictionCoefficient(0.5);
134  species01->setRollingFrictionCoefficient(0.0);
135 
136  //Properties index 2
138 
139  species2.setDensity(2500.0);//sets the species type-2 density
140  species2.setStiffness(258.5);//sets the spring stiffness
141  species2.setDissipation(0.0);//sets the dissipation
142  species2.setSlidingStiffness(2.0 / 7.0 * species2.getStiffness());
143  species2.setRollingStiffness(2.0 / 5.0 * species2.getStiffness());
144  species2.setSlidingFrictionCoefficient(0.5);
145  species2.setRollingFrictionCoefficient(0.5);
146  auto ptrToSp2 = problem.speciesHandler.copyAndAddObject(species2);
147 
148  //Combination of properties index 0 and index 2
149  auto species02 = problem.speciesHandler.getMixedObject(ptrToSp0, ptrToSp2);
150 
151  species02->setStiffness(259.018);//sets the stiffness
152  species02->setDissipation(0.0334);//sets the dissipation
153  species02->setSlidingStiffness(2.0 / 7.0 * species02->getStiffness());
154  species02->setRollingStiffness(2.0 / 5.0 * species02->getStiffness());
155  species02->setSlidingFrictionCoefficient(0.5);
156  species02->setRollingFrictionCoefficient(0.5);
157 
158  //Output
159  problem.setSaveCount(10);
164 
165  problem.setXBallsAdditionalArguments("-solidf -v0 -s 8");
166 
167  problem.setTimeStep(0.005 / 50.0);
168  problem.solve(argc, argv);
169 
170  return 0;
171 }
int main(int argc, char *argv[])
[T9:class]
Definition: Tutorial9_InclinedPlane.cpp:83
Mdouble getRadius() const
Returns the particle's radius.
Definition: BaseParticle.h:348
std::enable_if<!std::is_pointer< typename U::MixedSpeciesType >::value, typename U::MixedSpeciesType * >::type getMixedObject(const U *S, const U *T)
Definition: SpeciesHandler.h:74
[T9:headers]
Definition: Tutorial9_InclinedPlane.cpp:44
void setupInitialConditions() override
This function allows to set the initial conditions for our problem to be solved, by default particle ...
Definition: Tutorial9_InclinedPlane.cpp:47
const Mdouble pi
Definition: ExtendedMath.h:45
Mdouble cos(Mdouble x)
Definition: ExtendedMath.cc:64
Mdouble sin(Mdouble x)
Definition: ExtendedMath.cc:44

Return to tutorial T9: Motion of a ball over an inclined plane (Sliding + Rolling)

Axisymmetric walls inside a cylindrical domain (code)

Return to tutorial T11: Axisymmetric walls inside a cylindrical domain

1 //Copyright (c) 2013-2023, 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 //Tutorial 11 introduces the axisymmetrical walls. Two asymmetrical walls are created into a
27 //cylindrical boundary.
28 
30 #include "Mercury3D.h"
35 
37 class Tutorial11 : public Mercury3D
38 {
39 public:
41  Tutorial11(const Mdouble width, const Mdouble height){
42  logger(INFO, "Tutorial 11");
43  setName("Tutorial11");
50  setXBallsAdditionalArguments("-v0 -solidf");
51 
52  //specify body forces
53  setGravity(Vec3D(0.0, 0.0, -9.8));
54 
55  //set domain accordingly (domain boundaries are not walls!)
56  setXMin(0.0);
57  setXMax(width);
58  setYMin(0.0);
59  setYMax(width);
60  setZMin(0.0);
61  setZMax(height);
62  }
64 
66  void setupInitialConditions() override {
67  Vec3D mid = {
68  (getXMin() + getXMax()) / 2.0,
69  (getYMin() + getYMax()) / 2.0,
70  (getZMin() + getZMax()) / 2.0};
71  const Mdouble halfWidth = (getXMax() - getXMin()) / 2.0;
72 
74  //Cylinder
77  w1.setPosition(Vec3D(mid.X, mid.Y, 0));
78  w1.setAxis(Vec3D(0, 0, 1));
79  w1.addObject(Vec3D(1, 0, 0), Vec3D((getXMax() - getXMin()) / 2.0, 0, 0));
82 
84  //Cone
87  w2.setPosition(Vec3D(mid.X, mid.Y, 0));
88  w2.setAxis(Vec3D(0, 0, 1));
89  std::vector<Vec3D> points(3);
90  //define the neck as a prism through corners of your prismatic wall in clockwise direction
91  points[0] = Vec3D(halfWidth, 0.0, mid.Z + contractionHeight);
92  points[1] = Vec3D(halfWidth - contractionWidth, 0.0, mid.Z);
93  points[2] = Vec3D(halfWidth, 0.0, mid.Z - contractionHeight);
94  w2.createOpenPrism(points);
97 
99  //Flat surface
100  InfiniteWall w0;
102  w0.set(Vec3D(0, 0, -1), Vec3D(0, 0, mid.Z));
105 
107  const int N = 600; //maximum number of particles
110  for (Mdouble z = mid.Z + contractionHeight;
112  z += 2.0 * maxParticleRadius)
113  {
114  for (Mdouble r = halfWidth - maxParticleRadius; r > 0; r -= 1.999 * maxParticleRadius)
115  {
116  for (Mdouble c = 2.0 * maxParticleRadius; c <= 2 * constants::pi * r; c += 2.0 * maxParticleRadius)
117  {
119  p0.setPosition(Vec3D(mid.X + r * mathsFunc::sin(c / r),
120  mid.Y + r * mathsFunc::cos(c / r),
121  z + p0.getRadius()));
122  const Mdouble vz = random.getRandomNumber(-1, 0);
123  const Mdouble vx = random.getRandomNumber(-1, 1);
124  p0.setVelocity(Vec3D(vx,0.0,vz));
126  }
127  }
128  }
130  }
132 
134  //Initially, a wall is inserted in the neck of the hourglass to prevent particles flowing through.
135  //This wall is moved to form the base of the hourglass at time 0.9
136  void actionsAfterTimeStep() override {
137  if (getTime() < 0.9 && getTime() + getTimeStep() > 0.9)
138  {
139  logger(INFO, "Shifting bottom wall downward");
140  dynamic_cast<InfiniteWall*>(wallHandler.getLastObject())->set(Vec3D(0, 0, -1), Vec3D(0, 0, getZMin()));
141  }
142  }
144 
149 
150 };
152 
154 int main(int argc, char *argv[])
155 {
157  Mdouble width = 10e-2; // 10cm
158  Mdouble height = 60e-2; // 60cm
159 
160  //Point the object HG to class
161  Tutorial11 HG(width,height);
162 
163  //Specify particle radius:
164  //these parameters are needed in setupInitialConditions()
165  HG.minParticleRadius = 6e-3; // 6mm
166  HG.maxParticleRadius = 10e-3; //10mm
168 
170  //Specify the number of particles
171 
172  //specify how big the wedge of the contraction should be
173  const Mdouble contractionWidth = 2.5e-2; //2.5cm
174  const Mdouble contractionHeight = 5e-2; //5cm
175  HG.contractionWidth = contractionWidth;
176  HG.contractionHeight = contractionHeight;
178 
180  //make the species of the particle and wall
182  species.setDensity(2000);
183 
184  species.setStiffness(1e5);
185  species.setDissipation(0.63);
186  HG.speciesHandler.copyAndAddObject(species);
187 
189 
191  //test normal forces
192  const Mdouble minParticleMass = species.getDensity() * 4.0 / 3.0 * constants::pi * mathsFunc::cubic(HG.minParticleRadius);
193  //Calculates collision time for two copies of a particle of given dissipation_, k, effective mass
194  logger(INFO, "minParticleMass = %", minParticleMass);
195  //Calculates collision time for two copies of a particle of given dissipation_, k, effective mass
196  const Mdouble tc = species.getCollisionTime(minParticleMass);
197  logger(INFO, "tc = %", tc);
198  //Calculates restitution coefficient for two copies of given dissipation_, k, effective mass
199  const Mdouble r = species.getRestitutionCoefficient(minParticleMass);
200  logger(INFO, "restitution coefficient = %", r);
202 
204  //time integration parameters
205  HG.setTimeStep(tc / 10.0);
206  HG.setTimeMax(5.0);
207  HG.setSaveCount(500);
209 
211  HG.solve(argc, argv);
213  return 0;
214 }
double Mdouble
Definition: GeneralDefine.h:34
@ INFO
int main(int argc, char *argv[])
[T11:class]
Definition: Tutorial11_AxisymmetricWalls.cpp:154
Use AxisymmetricIntersectionOfWalls to Screw Screw::read Screw::read Screw::read define axisymmetric ...
Definition: AxisymmetricIntersectionOfWalls.h:126
void setAxis(Vec3D a)
Definition: AxisymmetricIntersectionOfWalls.cc:152
T * getLastObject()
Gets a pointer to the last Object in this BaseHandler.
Definition: BaseHandler.h:634
void setYMin(Mdouble newYMin)
Sets the value of YMin, the lower bound of the problem domain in the y-direction.
Definition: DPMBase.cc:1034
Mdouble getTimeStep() const
Returns the simulation time step.
Definition: DPMBase.cc:1250
Mdouble getTime() const
Returns the current simulation time.
Definition: DPMBase.cc:808
void setFileType(FileType fileType)
Sets File::fileType_ for all files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:459
void setZMin(Mdouble newZMin)
Sets the value of ZMin, the lower bound of the problem domain in the z-direction.
Definition: DPMBase.cc:1058
RNG random
This is a random generator, often used for setting up the initial conditions etc.....
Definition: DPMBase.h:1432
void setXMin(Mdouble newXMin)
Sets the value of XMin, the lower bound of the problem domain in the x-direction.
Definition: DPMBase.cc:1010
void createOpenPrism(std::vector< Vec3D > points, Vec3D prismAxis)
Creates an open prism which is a polygon between the points, except the first and last point,...
Definition: IntersectionOfWalls.cc:467
Mdouble getCollisionTime(Mdouble mass) const
Calculates collision time for two copies of a particle of given disp, k, mass.
Definition: LinearViscoelasticNormalSpecies.cc:137
Mdouble getRestitutionCoefficient(Mdouble mass) const
Calculates restitution coefficient for two copies of given disp, k, mass.
Definition: LinearViscoelasticNormalSpecies.cc:168
unsigned int getNumberOfObjects() const override
Returns the number of objects in the container. In parallel code this practice is forbidden to avoid ...
Definition: ParticleHandler.cc:1325
Mdouble getDensity() const
Allows density_ to be accessed.
Definition: ParticleSpecies.cc:118
Mdouble getRandomNumber()
This is a random generating routine can be used for initial positions.
Definition: RNG.cc:143
[T11:headers]
Definition: Tutorial11_AxisymmetricWalls.cpp:38
Tutorial11(const Mdouble width, const Mdouble height)
[T11:constructor]
Definition: Tutorial11_AxisymmetricWalls.cpp:41
Mdouble contractionHeight
Definition: Tutorial11_AxisymmetricWalls.cpp:146
Mdouble maxParticleRadius
Definition: Tutorial11_AxisymmetricWalls.cpp:148
void setupInitialConditions() override
[T11:constructor]
Definition: Tutorial11_AxisymmetricWalls.cpp:66
Mdouble minParticleRadius
Definition: Tutorial11_AxisymmetricWalls.cpp:147
void actionsAfterTimeStep() override
[T11:initialConditions]
Definition: Tutorial11_AxisymmetricWalls.cpp:136
Mdouble contractionWidth
[T11:functiontime]
Definition: Tutorial11_AxisymmetricWalls.cpp:145
Mdouble Y
Definition: Vector.h:66
Mdouble Z
Definition: Vector.h:66
Mdouble X
the vector components
Definition: Vector.h:66
T cubic(const T val)
calculates the cube of a number
Definition: ExtendedMath.h:115

Return to tutorial T11: Axisymmetric walls inside a cylindrical domain

Prismatic walls using points (code)

Return to tutorial T12: Creating objects by using Prisms

1 //Copyright (c) 2013-2023, 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 // Tutorial 12
27 
28 /*
29 ** This file is annotated with DoxyFile comments in order to show the code on
30 ** the documentation - This is not needed for your real drivers.
31 ** Please ignore these comments.
32 **
33 ** For full documentation of this code, go to http://docs.mercurydpm.org/Alpha/d0/db0/BeginnerTutorials.html#T8
34 */
35 
38 #include <Mercury3D.h>
39 #include <Walls/InfiniteWall.h>
42 
44 class Tutorial12 : public Mercury3D
45 {
46 public:
48  void setupInitialConditions() override {
52  p0.setRadius(0.005);
53  p0.setPosition(Vec3D(0.15 * getXMax(), 0.3335 * getYMax(), 0.0));
54  p0.setVelocity(Vec3D(1.2, 0.2, 0.0));
57 
59  // Creating outer walls
60  InfiniteWall w0;
61 
63  w0.set(Vec3D(1.0, 0.0, 0.0), Vec3D(getXMax(), 0.0, 0.0));
65 
66  w0.set(Vec3D(-1.0, 0.0, 0.0), Vec3D(getXMin(), 0.0, 0.0));
68 
69  w0.set(Vec3D(0.0, 1.0, 0.0), Vec3D(0.0, getYMax(), 0.0));
71 
72  w0.set(Vec3D(0.0, -1.0, 0.0), Vec3D(0.0, getYMin(), 0.0));
75 
77  // Defining the object in het center of the box
78  // Create an intersection of walls object w1
80  // Set the species of the wall
82  std::vector<Vec3D> Points(4);
83  // Define the vertices of the insert and ensure that points are in clockwise order
84  Points[0] = Vec3D(0.25 * getXMax(), -0.25 * getYMax(), 0.0);
85  Points[1] = Vec3D(-0.25 * getXMax(), -0.25 * getYMax(), 0.0);
86  Points[2] = Vec3D(-0.25 * getXMax(), 0.25 * getYMax(), 0.0);
87  Points[3] = Vec3D(0.25 * getXMax(), 0.25 * getYMax(), 0.0);
88  // Creating the object from the vector containing points
89  w1.createPrism(Points);
91  /* Define the angular velocity of the object (optional).
92  * Setting the angular velocity of the object results in rotation of the object around
93  * the origin (0.0,0.0,0.0). If the object is build such that the center of rotation of the object
94  * coincides with the origin the object will rotate around its own axis. */
96  w1.setAngularVelocity(Vec3D(0.0,0.0,1.0));
98  /* Define the translational velocity of the object (optional) */
100  w1.setVelocity(Vec3D(0.0,0.0,0.0));
102  /* Set the desired position of center of the object (optional).
103  * With this command you can position your object (with the set angular velocity)
104  * at a specific location in the domain.*/
106  w1.setPosition(Vec3D(0.5 * getXMax(),0.5 * getYMax(),0.0));
108  // Add the object to wall w1
110 
111  }
113 };
115 
116 int main(int argc, char* argv[])
117 {
119  // Problem setup
120  Tutorial12 problem; // instantiate an object of class Tutorial 12
121 
122  problem.setName("Tutorial12");
123  problem.setSystemDimensions(2);
124  problem.setGravity(Vec3D(0.0, 0.0, 0.0));
125  problem.setXMax(0.5);
126  problem.setYMax(0.5);
127  problem.setTimeMax(5.0);
128 
130  // The normal spring stiffness and normal dissipation is computed and set as
131  // For collision time tc=0.005 and restitution coefficeint rc=1.0,
133  species.setDensity(2500.0); //sets the species type_0 density
134  species.setStiffness(258.5);//sets the spring stiffness.
135  species.setDissipation(0.0); //sets the dissipation.
136  problem.speciesHandler.copyAndAddObject(species);
137 
139 
140  problem.setSaveCount(10);
145 
146  problem.setXBallsAdditionalArguments("-solidf -v0 -s .85");
147 
148  problem.setTimeStep(.005 / 50.0); // (collision time)/50.0
150 
152  problem.solve(argc, argv);
154 
155  return 0;
156 }
int main(int argc, char *argv[])
[T12:class]
Definition: Tutorial12_PrismWalls.cpp:116
void setAngularVelocity(const Vec3D &angularVelocity)
set the angular velocity of the BaseInteractble.
Definition: BaseInteractable.cc:360
void createPrism(std::vector< Vec3D > points, Vec3D prismAxis)
Creates an open prism which is a polygon between the points and extends infinitely in the PrismAxis d...
Definition: IntersectionOfWalls.cc:482
[T12:headers]
Definition: Tutorial12_PrismWalls.cpp:45
void setupInitialConditions() override
[T12:initialConditions]
Definition: Tutorial12_PrismWalls.cpp:48

Return to tutorial T12: Creating objects by using Prisms

Particles driven by a rotating coil (code)

Return to tutorial Particles driven by a rotating coil

Return to tutorial Particles driven by a rotating coil

Particles on an inclined chute (code)

Return to tutorial Particles on an inclined chute

#include <iostream>
#include "Chute.h"
// Creates a quasi-2D inclined plane with inflow conditions on the left boundary,
// and deletion of particles when they exit the domain on the right.
int main()
{
// Problem parameters
Chute problem;
problem.setName("ChuteDemo"); // data output file name
problem.setGravity({0,-1,0});
problem.setSaveCount(102); // number of time steps skipped between saves
Mdouble tc = 2.5e-3; // collision time
problem.setTimeStep(0.02 * tc); // actual time step
problem.setTimeMax(0.5); // maximum time
// NB: number of time steps saved to output files
// is timeMax/(timeStep*saveCount)
// Particle radii
problem.setFixedParticleRadius(0.001); // radius of fixed chute bottom particles
problem.setInflowParticleRadius(0.001); // radius of (monodisperse) inflow particles
// Particle species
LinearViscoelasticSpecies species; // initialise species
species.setHandler(&problem.speciesHandler); // assign problem species handler to species
species.setDensity(2000); // particle density
0.8, species.getMassFromRadius(problem.getInflowParticleRadius())); // material properties
problem.speciesHandler.copyAndAddObject(species); // assign species to problem species handler
// Chute properties
problem.setChuteAngle(30.0); // set angle of chute relative to horizontal
problem.setXMax(0.1); // chute length = 0.1
problem.setYMax(2.0 * problem.getInflowParticleRadius()); // chute width = 1 particle diameter
// Inflow properties
problem.setInflowHeight(0.1); // particle inflow between 0 <= Z <= 0.1
problem.setInflowVelocity(0.1); // particle inflow mean velocity
problem.setInflowVelocityVariance(0.02); // particle inflow velocity variance (in ratio of the mean velocity)
//Write paraview data
//problem.setParticlesWriteVTK(true);
//problem.wallHandler.setWriteVTK(true);
/*problem.setParticlesWriteVTK(true);
problem.wallHandler.setWriteVTK(true);*/
//solve
problem.solve();
} // the end
int main()
[ChuteDemo:include]
Definition: ChuteDemo.cpp:34
void setHandler(SpeciesHandler *handler)
Sets the pointer to the handler to which this species belongs.
Definition: BaseSpecies.cc:91
Creates chutes with different bottoms. Inherits from Mercury3D (-> MercuryBase -> DPMBase).
Definition: Chute.h:65
void setInflowParticleRadius(Mdouble inflowParticleRadius)
Sets the radius of the inflow particles to a single one (i.e. ensures a monodisperse inflow).
Definition: Chute.cc:848
void setInflowVelocityVariance(Mdouble inflowVelocityVariance)
Sets the inflow velocity variance.
Definition: Chute.cc:1010
void setInflowVelocity(Mdouble inflowVelocity)
Sets the average inflow velocity.
Definition: Chute.cc:983
Mdouble getInflowParticleRadius() const
Returns the average radius of inflow particles.
Definition: Chute.cc:929
void setChuteAngle(Mdouble chuteAngle)
Sets gravity vector according to chute angle (in degrees)
Definition: Chute.cc:768
void setInflowHeight(Mdouble inflowHeight)
Sets maximum inflow height (Z-direction)
Definition: Chute.cc:957
void setFixedParticleRadius(Mdouble fixedParticleRadius)
Sets the particle radius of the fixed particles which constitute the (rough) chute bottom.
Definition: Chute.cc:653
void setCollisionTimeAndRestitutionCoefficient(Mdouble tc, Mdouble eps, BaseParticle *p)
Sets k, disp such that it matches a given tc and eps for a collision of two copies of particle p.
Definition: LinearViscoelasticNormalSpecies.cc:212
Mdouble getMassFromRadius(Mdouble radius) const
Definition: ParticleSpecies.cc:123

Return to tutorial Particles on an inclined chute

Particles on a chute with a multilayered bottom (code)

Return to tutorial Particles on a chute with a multilayered bottom

Return to tutorial Particles on a chute with a multilayered bottom

Isotropic compression of a cuboidal REV (code)

Return to tutorial Isotropic compression of a cuboidal REV

1 //Copyright (c) 2013-2023, 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 <Species/Species.h>
27 #include <Mercury3D.h>
32 
39 class StressStrainControl : public Mercury3D
40 {
42 public:
43  //Create the class and passing the user inputs using the constructors
44  StressStrainControl(const Matrix3D& stressGoal, const Matrix3D& strainRate, const Matrix3D& gainFactor,
45  bool isStrainRateControlled)
46  : stressGoal_(stressGoal), strainRate_(strainRate), gainFactor_(gainFactor),
47  isStrainRateControlled_(isStrainRateControlled)
48  {
49  //Define the domain size
50  setMin(Vec3D(0, 0, 0));
51  setMax(Vec3D(1, 1, 1));
52  //Calculate the mass from smallest particle
53  double mass = 2000 * constants::pi * mathsFunc::cubic(2.0 * 0.08) / 6.0;
54  //Define the species for the particles
56  species.setDensity(2000);
57  species.setStiffnessAndRestitutionCoefficient(10000, 0.4, mass);
59  }
61 
63 private:
64  //Here we set up the system parameters, adding particles and define boundaries
65  void setupInitialConditions() override
66  {
67  //Set up the micro parameters.
68  double rhop = 2000; //particle density
69  double K1 = 10000; //particle stiffness
70  double en = 0.4; //restitution coefficient
71  double radius = 0.08; //particle radius
72  //Calculate the mass from smallest particle
73  double mass = rhop * constants::pi * mathsFunc::cubic(2.0 * radius) / 6.0;
74  //Calculate the contact duration
75  double tc = std::sqrt(mass / 2.0 / K1 * (mathsFunc::square(constants::pi) +
76  mathsFunc::square(log(en))));
77  setSystemDimensions(3); //set the 3d simulation
78  setTimeStep(tc / 50); //set the timestep based on the shortest contact duration
79  setGravity(Vec3D(0.0, 0.0, 0.0)); //set gravity in the system
80 
81  //Add particles
82  CubeInsertionBoundary insertion;
84  //Insert 96 particles in the subvolume = 0.8*0.8*0.8 = 0.512, if failed by 100 times, it stops
85  insertion.set(&particle, 100, 0.8 * getMin(), 0.8 * getMax(), Vec3D(0, 0, 0), Vec3D(0, 0, 0));
86  insertion.setInitialVolume(1.0);
87  insertion.checkBoundaryBeforeTimeStep(this);
88  logger(INFO,"Inserted % particles",particleHandler.getSize());
89 
90  //Delete all existing boundaries
92  //Set up the deformation mode using the boundaries that are based on user's input
94  boundary.setHandler(&boundaryHandler);
97 
98 
99  }
101 
103  //initialize the private variables for passing the user's inputs in the constructor
109 };
111 
113 //Here we define all the control parameters and solve the problem
114 int main(int argc UNUSED, char* argv[] UNUSED)
115 {
116  //We want strainrate control, so here we set the target Stress to free, all to zero
117  Matrix3D stressGoal;
118  stressGoal.XX = 0.0;
119  stressGoal.YY = 0.0;
120  stressGoal.ZZ = 0.0;
121  stressGoal.XY = 0.0;
122 
123  //Here we set the isotropic strainrate tensor, negative sign means compression
124  Matrix3D strainRate;
125  strainRate.XX = -0.02;
126  strainRate.YY = -0.02;
127  strainRate.ZZ = -0.02;
128  strainRate.XY = 0.0;
129 
130  //This is default gainFactor, if you choose to use stress control, you might want to tune this one
131  Matrix3D gainFactor;
132  gainFactor.XY = 0.0001;
133  gainFactor.XX = 0.0001;
134  gainFactor.YY = 0.0001;
135  gainFactor.ZZ = 0.0001;
136 
137  //This is by default set to true, so particles are controlled by affine movement.
138  //If set it to false, then the particles will only follow the boundary movement.
139  bool isStrainRateControlled = true;
140 
141  //Define the object and problem to solve
142  StressStrainControl dpm(stressGoal, strainRate, gainFactor, isStrainRateControlled);
143 
144  //Set name
145  dpm.setName("Tutorial_IsotropicCompression");
146  //Set output and time stepping properties
147  dpm.setTimeMax(10);
148  //Set the SaveCount, i.e. 100 timesteps saving one snapshot
149  dpm.setSaveCount(100);
150  //Currently all the normal file outputs are switched off, simply switch it on by replacing NO_FILE to ONE_FILE
151 // dpm.dataFile.setFileType(FileType::NO_FILE);
152 // dpm.restartFile.setFileType(FileType::NO_FILE);
153 // dpm.fStatFile.setFileType(FileType::NO_FILE);
154 // dpm.eneFile.setFileType(FileType::NO_FILE);
155  //Set output the particle information in VTK for ParaView Visualisation
156  dpm.setParticlesWriteVTK(true);
157  //Because of periodic boundary, out put wall files is not necessary in this case
158  //dpm.wallHandler.setWriteVTK(true);
159  //Solve the problem
160  dpm.solve();
161 }
#define UNUSED
Definition: GeneralDefine.h:39
int main(int argc UNUSED, char *argv[] UNUSED)
[REV_ISO:class]
Definition: REVIsotropicCompressionDemo.cpp:114
void setHandler(BoundaryHandler *handler)
Sets the boundary's BoundaryHandler.
Definition: BaseBoundary.cc:134
virtual void clear()
Empties the whole BaseHandler by removing all Objects and setting all other variables to 0.
Definition: BaseHandler.h:528
unsigned int getSize() const
Gets the size of the particleHandler (including mpi and periodic particles)
Definition: BaseHandler.h:655
It's an insertion boundary which has cuboidal shape (yes, 'CuboidalInsertionBoundary' would have been...
Definition: CubeInsertionBoundary.h:42
void set(BaseParticle *particleToCopy, unsigned int maxFailed, Vec3D posMin, Vec3D posMax, Vec3D velMin={0, 0, 0}, Vec3D velMax={0, 0, 0})
Sets the properties of the InsertionBoundary for mutliple different particle types.
Definition: CubeInsertionBoundary.cc:107
Vec3D getMax() const
Definition: DPMBase.h:670
void setMin(const Vec3D &min)
Sets the minimum coordinates of the problem domain.
Definition: DPMBase.cc:1118
Vec3D getMin() const
Definition: DPMBase.h:664
void setMax(const Vec3D &max)
Sets the maximum coordinates of the problem domain.
Definition: DPMBase.cc:1082
void checkBoundaryBeforeTimeStep(DPMBase *md) override
Fills the boundary with particles.
Definition: InsertionBoundary.cc:184
void setInitialVolume(Mdouble initialVolume)
Gets the Volume which should be inserted by the insertion routine.
Definition: InsertionBoundary.cc:643
void setStiffnessAndRestitutionCoefficient(Mdouble k_, Mdouble eps, Mdouble mass)
Sets k, disp such that it matches a given tc and eps for a collision of two copies of P.
Definition: LinearViscoelasticNormalSpecies.cc:186
Implementation of a 3D matrix.
Definition: Matrix.h:38
Mdouble XY
Definition: Matrix.h:43
Mdouble YY
Definition: Matrix.h:43
Mdouble ZZ
Definition: Matrix.h:43
Mdouble XX
all nine matrix elements
Definition: Matrix.h:43
A cuboid box consists of periodic boundaries that can be strain/stress controlled and achieve differe...
Definition: StressStrainControlBoundary.h:55
void set(const Matrix3D &stressGoal, const Matrix3D &strainRate, const Matrix3D &gainFactor, bool isStrainRateControlled)
Sets all boundary inputs at once and determines which deformation mode it is, then combine the right ...
Definition: StressStrainControlBoundary.cc:310
[REV_ISO:headers]
Definition: REVIsotropicCompressionDemo.cpp:40
StressStrainControl(const Matrix3D &stressGoal, const Matrix3D &strainRate, const Matrix3D &gainFactor, bool isStrainRateControlled)
[REV_ISO:construct]
Definition: REVIsotropicCompressionDemo.cpp:44
bool isStrainRateControlled_
Definition: REVIsotropicCompressionDemo.cpp:107
Matrix3D strainRate_
Definition: REVIsotropicCompressionDemo.cpp:105
Matrix3D gainFactor_
Definition: REVIsotropicCompressionDemo.cpp:106
Matrix3D stressGoal_
[REV_ISO:setIni]
Definition: REVIsotropicCompressionDemo.cpp:104
void setupInitialConditions() override
[REV_ISO:construct]
Definition: REVIsotropicCompressionDemo.cpp:65
Mdouble log(Mdouble Power)
Definition: ExtendedMath.cc:104
T square(const T val)
squares a number
Definition: ExtendedMath.h:106

Return to tutorial Isotropic compression of a cuboidal REV

Pure shear (constant volume) of a cuboidal REV (code)

Return to tutorial Pure shear (constant volume) of a cuboidal REV

1 //Copyright (c) 2013-2023, 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 <Species/Species.h>
27 #include <Mercury3D.h>
32 
40 class StressStrainControl : public Mercury3D
41 {
43 public:
44  //Create the class and passing the user inputs using the constructors
45  StressStrainControl(const Matrix3D& stressGoal, const Matrix3D& strainRate, const Matrix3D& gainFactor,
46  bool isStrainRateControlled)
47  : stressGoal_(stressGoal), strainRate_(strainRate), gainFactor_(gainFactor),
48  isStrainRateControlled_(isStrainRateControlled)
49  {
50  //Define the domain size
51  setMin(Vec3D(0, 0, 0));
52  setMax(Vec3D(1, 1, 1));
53  //Calculate the mass from smallest particle
54  double mass = 2000 * constants::pi * mathsFunc::cubic(2.0 * 0.08) / 6.0;
55  //Define the species for the particles
57  species.setDensity(2000);
58  species.setStiffnessAndRestitutionCoefficient(10000, 0.4, mass);
60  }
62 
64 private:
65  //Here we set up the system parameters, adding particles and define boundaries
66  void setupInitialConditions() override
67  {
68  //Set up the micro parameters.
69  double rhop = 2000; //particle density
70  double K1 = 10000; //particle stiffness
71  double en = 0.4; //restitution coefficient
72  double radius = 0.05; //particle radius
73  //Calculate the mass from smallest particle
74  double mass = rhop * constants::pi * mathsFunc::cubic(2.0 * radius) / 6.0;
75  //Calculate the contact duration
76  double tc = std::sqrt(mass / 2.0 / K1 * (mathsFunc::square(constants::pi) +
77  mathsFunc::square(log(en))));
78  setSystemDimensions(3); //set the 3d simulation
79  setTimeStep(tc / 50); //set the timestep based on the shortest contact duration
80  setGravity(Vec3D(0.0, 0.0, 0.0)); //set gravity in the system
81 
82  //Add particles
83  CubeInsertionBoundary insertion;
85  //Insert 96 particles in the subvolume = 1.0*1.0*1.0 = 1.0, if failed by 100 times, it stops
86  insertion.set(&particle, 100, getMin(), getMax(), Vec3D(0, 0, 0), Vec3D(0, 0, 0));
87  insertion.setInitialVolume(1.0);
88  insertion.checkBoundaryBeforeTimeStep(this);
89  logger(INFO,"Inserted % particles",particleHandler.getSize());
90 
91  //Set up the deformation mode using the boundaries that are based on user's input
92  boundaryHandler.clear(); // Delete all exist boundaries
94  boundary.setHandler(&boundaryHandler);
97 
98 
99  }
101 
103  //Initialize the private variables for passing the user's inputs in the constructor
109 };
111 
113 //Here we define all the control parameters and solve the problem
114 int main(int argc UNUSED, char* argv[] UNUSED)
115 {
116  //We want strainrate control, so here we set the target Stress to free, all to zero
117  Matrix3D stressGoal;
118  stressGoal.XX = 0.0;
119  stressGoal.YY = 0.0;
120  stressGoal.ZZ = 0.0;
121  stressGoal.XY = 0.0;
122 
123  //Here we set the pure shear strainrate tensor, negative sign means compression
124  Matrix3D strainRate;
125  strainRate.XX = 0.4;
126  strainRate.YY = -0.4;
127  strainRate.ZZ = 0.0;
128  strainRate.XY = 0.0;
129 
130  //This is default gainFactor, if you choose to use stress control, you might want to tune this one
131  Matrix3D gainFactor;
132  gainFactor.XY = 0.0001;
133  gainFactor.XX = 0.0001;
134  gainFactor.YY = 0.0001;
135  gainFactor.ZZ = 0.0001;
136 
137  //This is by default set to true, so particles are controlled by affine movement.
138  //If set it to false, then the particles will only follow the boundary movement.
139  bool isStrainRateControlled = true;
140 
141  //Define the object and problem to solve
142  StressStrainControl dpm(stressGoal, strainRate, gainFactor, isStrainRateControlled);
143 
144  //Set name
145  dpm.setName("Tutorial_PureShear");
146  //Set output and time stepping properties
147  dpm.setTimeMax(1);
148  //Set the SaveCount, i.e. 100 timesteps saving one snapshot
149  dpm.setSaveCount(10);
150  //Currently all the normal file outputs are switched off, simply switch it on by replacing NO_FILE to ONE_FILE
151  dpm.dataFile.setFileType(FileType::NO_FILE);
152  dpm.restartFile.setFileType(FileType::NO_FILE);
153  dpm.fStatFile.setFileType(FileType::NO_FILE);
154  dpm.eneFile.setFileType(FileType::NO_FILE);
155  //Set output the particle information in VTK for ParaView Visualisation
156  dpm.setParticlesWriteVTK(true);
157  //Because of periodic boundary, out put wall files is not necessary in this case
158  //dpm.wallHandler.setWriteVTK(true);
159  //Solve the problem
160  dpm.solve();
161 }
int main(int argc UNUSED, char *argv[] UNUSED)
[REV_PUR:class]
Definition: REVPureShearDemo.cpp:114

Return to tutorial Pure shear (constant volume) of a cuboidal REV

Simple shear (constant stress) of a cuboidal REV (code)

Return to tutorial Simple shear (constant stress) of a cuboidal REV

1 //Copyright (c) 2013-2023, 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 <Species/Species.h>
27 #include <Mercury3D.h>
32 
41 class StressStrainControl : public Mercury3D
42 {
44 public:
45  //Create the class and passing the user inputs using the constructors
46  StressStrainControl(const Matrix3D& stressGoal, const Matrix3D& strainRate, const Matrix3D& gainFactor,
47  bool isStrainRateControlled)
48  : stressGoal_(stressGoal), strainRate_(strainRate), gainFactor_(gainFactor),
49  isStrainRateControlled_(isStrainRateControlled)
50  {
51  //Define the domain size
52  setMin(Vec3D(0, 0, 0));
53  setMax(Vec3D(1, 1, 1));
54  //Calculate the mass from smallest particle
55  double mass = 2000 * constants::pi * mathsFunc::cubic(2.0 * 0.05) / 6.0;
56  //Define the species for the particles
58  species.setDensity(2000);
59  species.setStiffnessAndRestitutionCoefficient(10000, 0.4, mass);
61  }
63 
65 private:
66  //Here we set up the system parameters, adding particles and define boundaries
67  void setupInitialConditions() override
68  {
69  //Set up the micro parameters.
70  double rhop = 2000; //particle density
71  double K1 = 10000; //particle stiffness
72  double en = 0.4; //restitution coefficient
73  double radius = 0.05; //particle radius
74  //Calculate the mass from smallest particle
75  double mass = rhop * constants::pi * mathsFunc::cubic(2.0 * radius) / 6.0;
76  //Calculate the contact duration
77  double tc = std::sqrt(mass / 2.0 / K1 * (mathsFunc::square(constants::pi) +
78  mathsFunc::square(log(en))));
79  setSystemDimensions(3); //set the 3d simulation
80  setTimeStep(tc / 50); //set the timestep based on the shortest contact duration
81  setGravity(Vec3D(0.0, 0.0, 0.0)); //set gravity in the system
82 
83  //Add particles
84  CubeInsertionBoundary insertion;
86  //Insert 96 particles in the subvolume = 1.0*1.0*1.0 = 1.0, if failed by 100 times, it stops
87  insertion.set(&particle, 100, getMin(), getMax(), Vec3D(0, 0, 0), Vec3D(0, 0, 0));
88  insertion.setInitialVolume(1.0);
89  insertion.checkBoundaryBeforeTimeStep(this);
90  logger(INFO,"Inserted % particles",particleHandler.getSize());
91 
92  //Set up the deformation mode using the boundaries that are based on user's input
93  boundaryHandler.clear(); // Delete all exist boundaries
95  boundary.setHandler(&boundaryHandler);
98 
99 
100  }
102 
104  //Initialize the private variables for passing the user's inputs in the constructor
110 };
112 
114 //Here we define all the control parameters and solve the problem
115 int main(int argc UNUSED, char* argv[] UNUSED)
116 {
117  //Here we want to set stress in y direction to constant, 100 is just an example,
118  //if you would like to keep the volume constant, then everything here should be set to zero
119  Matrix3D stressGoal;
120  stressGoal.XX = 0.0;
121  stressGoal.YY = 100.0;
122  stressGoal.ZZ = 0.0;
123  stressGoal.XY = 0.0;
124 
125  //Here we set the simple shear strainrate tensor, negative sign means compression
126  Matrix3D strainRate;
127  strainRate.XX = 0.0;
128  strainRate.YY = 0.0;
129  strainRate.ZZ = 0.0;
130  strainRate.XY = 1.0;
131 
132  //This is default gainFactor, if you choose to use stress control, you might want to tune this one
133  Matrix3D gainFactor;
134  gainFactor.XY = 0.0001;
135  gainFactor.XX = 0.0001;
136  gainFactor.YY = 0.0001;
137  gainFactor.ZZ = 0.0001;
138 
139  //This is by default set to true, so particles are controlled by affine movement.
140  //If set it to false, then the particles will only follow the boundary movement.
141  bool isStrainRateControlled = true;
142 
143  //Define the object and problem to solve
144  StressStrainControl dpm(stressGoal, strainRate, gainFactor, isStrainRateControlled);
145 
146  //Set name
147  dpm.setName("Tutorial_SimpleShear");
148  //Set output and time stepping properties
149  dpm.setTimeMax(10);
150  //Set the SaveCount, i.e. 100 timesteps saving one snapshot
151  dpm.setSaveCount(100);
152  //Currently all the normal file outputs are switched off, simply switch it on by replacing NO_FILE to ONE_FILE
153  dpm.dataFile.setFileType(FileType::NO_FILE);
154  dpm.restartFile.setFileType(FileType::NO_FILE);
155  dpm.fStatFile.setFileType(FileType::NO_FILE);
156  dpm.eneFile.setFileType(FileType::NO_FILE);
157  //Set output the particle information in VTK for ParaView Visualisation
158  dpm.setParticlesWriteVTK(true);
159  //Because of periodic boundary, out put wall files is not necessary in this case
160  //dpm.wallHandler.setWriteVTK(true);
161  //Solve the problem
162  dpm.solve();
163 }
int main(int argc UNUSED, char *argv[] UNUSED)
[REV_SIM:class]
Definition: REVSimpleShearDemo.cpp:115

Return to tutorial Simple shear (constant stress) of a cuboidal REV