MercuryDPM  Alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Codes for tutorials

Particle motion in outer space (code)

Return to tutorial T1: Particle motion in outer space

1 //Copyright (c) 2013-2014, The MercuryDPM Developers Team. All rights reserved.
2 //For the list of developers, see <http://www.MercuryDPM.org/Team>.
3 //
4 //Redistribution and use in source and binary forms, with or without
5 //modification, are permitted provided that the following conditions are met:
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above copyright
9 // notice, this list of conditions and the following disclaimer in the
10 // documentation and/or other materials provided with the distribution.
11 // * Neither the name MercuryDPM nor the
12 // names of its contributors may be used to endorse or promote products
13 // derived from this software without specific prior written permission.
14 //
15 //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 //ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 //WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 //DISCLAIMED. IN NO EVENT SHALL THE MERCURYDPM DEVELOPERS TEAM BE LIABLE FOR ANY
19 //DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 //(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 //LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 //ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 //(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 
26 // 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 
35 #include <Species/Species.h>
37 #include <Mercury3D.h>
38 #include <Particles/BaseParticle.h>
40 
42 class Tutorial1 : public Mercury3D
43 {
44 
45  public:
46 
48  {
50  BaseParticle p0;
51  p0.setSpecies(speciesHandler.getObject(0));
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));
55  particleHandler.copyAndAddObject(p0);
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  // The normal spring stiffness and normal dissipation is computed and set as
79  // For collision time tc=0.005 and restitution coefficeint rc=1.0,
80  auto species = problem.speciesHandler.copyAndAddObject(LinearViscoelasticSpecies());
81  species->setDensity(2500.0); // sets the species type-0 density
82  species->setStiffness(258.5);// sets the spring stiffness
83  species->setDissipation(0.0);// sets the dissipation
85 
87  problem.setSaveCount(10);
88  problem.dataFile.setFileType(FileType::ONE_FILE);
89  problem.restartFile.setFileType(FileType::ONE_FILE);
90  problem.fStatFile.setFileType(FileType::NO_FILE);
91  problem.eneFile.setFileType(FileType::NO_FILE);
92  std::cout << problem.dataFile.getCounter() << std::endl;
94 
96  problem.setXBallsAdditionalArguments("-solidf -v0");
98 
100  problem.setTimeStep(.005/50.0); // (collision time)/50.0
101  problem.solve(argc, argv);
103  return 0;
104 }
void setVelocity(const Vec3D &velocity)
set the velocity of the BaseInteractable.
Mdouble getZMax() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMax() returns ZMax...
Definition: DPMBase.cc:319
void setSpecies(const ParticleSpecies *species)
void setRadius(const Mdouble radius)
Sets the particle's radius_ (and adjusts the mass_ accordingly, based on the particle's species) ...
Mdouble getXMax() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMax() returns XMax...
Definition: DPMBase.cc:287
file will not be created/read
This adds on the hierarchical grid code for 3D problems.
Definition: Mercury3D.h:35
all data will be written into/ read from a single file called name_
void setDensity(Mdouble density)
Allows density_ to be changed.
Species< LinearViscoelasticNormalSpecies > LinearViscoelasticSpecies
Mdouble getYMax() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMax() returns XMax...
Definition: DPMBase.cc:303
void setPosition(const Vec3D &position)
Sets the position of this BaseInteractable.
int main(int argc, char **argv)
Definition: data2pvd.cpp:50
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:45
virtual void setupInitialConditions()
This function allows to set the initial conditions for our problem to be solved, by default particle ...
Definition: DPMBase.cc:966

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-2014, The MercuryDPM Developers Team. All rights reserved.
2 //For the list of developers, see <http://www.MercuryDPM.org/Team>.
3 //
4 //Redistribution and use in source and binary forms, with or without
5 //modification, are permitted provided that the following conditions are met:
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above copyright
9 // notice, this list of conditions and the following disclaimer in the
10 // documentation and/or other materials provided with the distribution.
11 // * Neither the name MercuryDPM nor the
12 // names of its contributors may be used to endorse or promote products
13 // derived from this software without specific prior written permission.
14 //
15 //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 //ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 //WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 //DISCLAIMED. IN NO EVENT SHALL THE MERCURYDPM DEVELOPERS TEAM BE LIABLE FOR ANY
19 //DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 //(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 //LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 //ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 //(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 
26 // 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 
35 #include <Mercury3D.h>
36 #include <Particles/BaseParticle.h>
37 
38 class Tutorial2 : public Mercury3D
39 {
40  public:
41 
43  {
44  BaseParticle p0;
45  p0.setSpecies(speciesHandler.getObject(0));
46  p0.setRadius(0.05);
47  p0.setPosition(Vec3D(0.5*getXMax(),0.5*getYMax(),getZMax()));
48  p0.setVelocity(Vec3D(0.0,0.0,0.0));
49  particleHandler.copyAndAddObject(p0);
50  }
51 
52 };
53 
54 int main(int argc, char *argv[])
55 {
56 
57  // Problem setup
58  Tutorial2 problem;
59 
60  problem.setName("Tutorial2");
61  problem.setSystemDimensions(3);
62  problem.setGravity(Vec3D(0.0,0.0,-9.81));
63  problem.setXMax(1.0);
64  problem.setYMax(1.0);
65  problem.setZMax(5.0);
66  problem.setTimeMax(1.5);
67 
69  // The normal spring stiffness and normal dissipation is computed and set as
70  // For collision time tc=0.005 and restitution coefficeint rc=1.0,
71  auto species = problem.speciesHandler.copyAndAddObject(LinearViscoelasticSpecies());
72  species->setDensity(2500.0); // sets the species type-0 density
73  species->setStiffness(258.5);// sets the spring stiffness
74  species->setDissipation(0.0);// sets the dissipation
76 
77  problem.setSaveCount(10);
78  problem.dataFile.setFileType(FileType::ONE_FILE);
79  problem.restartFile.setFileType(FileType::ONE_FILE);
80  problem.fStatFile.setFileType(FileType::NO_FILE);
81  problem.eneFile.setFileType(FileType::NO_FILE);
82 
83  problem.setXBallsAdditionalArguments("-solidf -v0");
84 
85  problem.setTimeStep(.005/50.0);// (collision time)/50.0
86  problem.solve(argc, argv);
87 
88  return 0;
89 }
void setVelocity(const Vec3D &velocity)
set the velocity of the BaseInteractable.
Mdouble getZMax() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMax() returns ZMax...
Definition: DPMBase.cc:319
void setSpecies(const ParticleSpecies *species)
void setRadius(const Mdouble radius)
Sets the particle's radius_ (and adjusts the mass_ accordingly, based on the particle's species) ...
Mdouble getXMax() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMax() returns XMax...
Definition: DPMBase.cc:287
file will not be created/read
This adds on the hierarchical grid code for 3D problems.
Definition: Mercury3D.h:35
all data will be written into/ read from a single file called name_
void setDensity(Mdouble density)
Allows density_ to be changed.
Species< LinearViscoelasticNormalSpecies > LinearViscoelasticSpecies
Mdouble getYMax() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMax() returns XMax...
Definition: DPMBase.cc:303
void setPosition(const Vec3D &position)
Sets the position of this BaseInteractable.
int main(int argc, char **argv)
Definition: data2pvd.cpp:50
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:45
virtual void setupInitialConditions()
This function allows to set the initial conditions for our problem to be solved, by default particle ...
Definition: DPMBase.cc:966

Return to tutorial T2: Particle motion on earth

Bouncing ball - elastic (code)

Return to tutorial T3: Bouncing ball (elastic)

1 //Copyright (c) 2013-2014, The MercuryDPM Developers Team. All rights reserved.
2 //For the list of developers, see <http://www.MercuryDPM.org/Team>.
3 //
4 //Redistribution and use in source and binary forms, with or without
5 //modification, are permitted provided that the following conditions are met:
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above copyright
9 // notice, this list of conditions and the following disclaimer in the
10 // documentation and/or other materials provided with the distribution.
11 // * Neither the name MercuryDPM nor the
12 // names of its contributors may be used to endorse or promote products
13 // derived from this software without specific prior written permission.
14 //
15 //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 //ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 //WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 //DISCLAIMED. IN NO EVENT SHALL THE MERCURYDPM DEVELOPERS TEAM BE LIABLE FOR ANY
19 //DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 //(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 //LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 //ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 //(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 
26 // 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 
36 #include <Mercury3D.h>
37 #include <Particles/BaseParticle.h>
38 #include <Walls/InfiniteWall.h>
40 
42 class Tutorial3 : public Mercury3D
43 {
44  public:
45 
47  {
48  BaseParticle p0;
49  p0.setSpecies(speciesHandler.getObject(0));
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));
53  particleHandler.copyAndAddObject(p0);
54 
56  InfiniteWall w0;
57  w0.setSpecies(speciesHandler.getObject(0));
58  w0.set(Vec3D(0.0,0.0,-1.0),Vec3D(0, 0, getZMin()));
59  wallHandler.copyAndAddObject(w0);
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,
83  auto species = problem.speciesHandler.copyAndAddObject(LinearViscoelasticSpecies());
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
88 
89  problem.setSaveCount(10);
90  problem.dataFile.setFileType(FileType::ONE_FILE);
91  problem.restartFile.setFileType(FileType::ONE_FILE);
92  problem.fStatFile.setFileType(FileType::NO_FILE);
93  problem.eneFile.setFileType(FileType::NO_FILE);
94 
95  problem.setXBallsAdditionalArguments("-solidf -v0");
96 
97  problem.setTimeStep(0.005/50.0); // (collision time)/50.0
98  problem.solve(argc, argv);
99 
100  return 0;
101 }
void setVelocity(const Vec3D &velocity)
set the velocity of the BaseInteractable.
Mdouble getZMax() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMax() returns ZMax...
Definition: DPMBase.cc:319
void setSpecies(const ParticleSpecies *species)
void setRadius(const Mdouble radius)
Sets the particle's radius_ (and adjusts the mass_ accordingly, based on the particle's species) ...
Mdouble getXMax() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMax() returns XMax...
Definition: DPMBase.cc:287
file will not be created/read
This adds on the hierarchical grid code for 3D problems.
Definition: Mercury3D.h:35
all data will be written into/ read from a single file called name_
void setDensity(Mdouble density)
Allows density_ to be changed.
Species< LinearViscoelasticNormalSpecies > LinearViscoelasticSpecies
Mdouble getYMax() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMax() returns XMax...
Definition: DPMBase.cc:303
void setPosition(const Vec3D &position)
Sets the position of this BaseInteractable.
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:79
Mdouble getZMin() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMin() returns ZMin...
Definition: DPMBase.cc:311
This is a class defining walls.
Definition: InfiniteWall.h:47
int main(int argc, char **argv)
Definition: data2pvd.cpp:50
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:45
virtual void setupInitialConditions()
This function allows to set the initial conditions for our problem to be solved, by default particle ...
Definition: DPMBase.cc:966
void setSpecies(const ParticleSpecies *species)
Define the species of this wall.
Definition: BaseWall.cc:113

Return to tutorial T3: Bouncing ball (elastic)

Bouncing ball - inelastic (code)

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

1 //Copyright (c) 2013-2014, The MercuryDPM Developers Team. All rights reserved.
2 //For the list of developers, see <http://www.MercuryDPM.org/Team>.
3 //
4 //Redistribution and use in source and binary forms, with or without
5 //modification, are permitted provided that the following conditions are met:
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above copyright
9 // notice, this list of conditions and the following disclaimer in the
10 // documentation and/or other materials provided with the distribution.
11 // * Neither the name MercuryDPM nor the
12 // names of its contributors may be used to endorse or promote products
13 // derived from this software without specific prior written permission.
14 //
15 //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 //ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 //WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 //DISCLAIMED. IN NO EVENT SHALL THE MERCURYDPM DEVELOPERS TEAM BE LIABLE FOR ANY
19 //DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 //(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 //LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 //ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 //(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 
26 // 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 
35 #include <Mercury3D.h>
36 #include <Particles/BaseParticle.h>
37 #include <Walls/InfiniteWall.h>
38 
39 class Tutorial4 : public Mercury3D
40 {
41  public:
42 
44  {
45  BaseParticle p0;
46  p0.setSpecies(speciesHandler.getObject(0));
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));
50  particleHandler.copyAndAddObject(p0);
51 
52  InfiniteWall w0;
53  w0.setSpecies(speciesHandler.getObject(0));
54  w0.set(Vec3D(0.0,0.0,-1.0),Vec3D(0.0,0.0,getZMin()));
55  wallHandler.copyAndAddObject(w0);
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,
77  auto species = problem.speciesHandler.copyAndAddObject(LinearViscoelasticSpecies());
78  species->setDensity(2500.0); // sets the species type-0 density
79  species->setStiffness(259.0159);// sets the spring stiffness
80  species->setDissipation(0.0334);// sets the dissipation
82 
83  problem.setSaveCount(10);
84  problem.dataFile.setFileType(FileType::ONE_FILE);
85  problem.restartFile.setFileType(FileType::ONE_FILE);
86  problem.fStatFile.setFileType(FileType::NO_FILE);
87  problem.eneFile.setFileType(FileType::NO_FILE);
88 
89  problem.setXBallsAdditionalArguments("-solidf -v0");
90 
91  problem.setTimeStep(0.005/50.0); // (collision time)/50.0
92  problem.solve(argc, argv);
93 
94  return 0;
95 }
void setVelocity(const Vec3D &velocity)
set the velocity of the BaseInteractable.
Mdouble getZMax() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMax() returns ZMax...
Definition: DPMBase.cc:319
void setSpecies(const ParticleSpecies *species)
void setRadius(const Mdouble radius)
Sets the particle's radius_ (and adjusts the mass_ accordingly, based on the particle's species) ...
Mdouble getXMax() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMax() returns XMax...
Definition: DPMBase.cc:287
file will not be created/read
This adds on the hierarchical grid code for 3D problems.
Definition: Mercury3D.h:35
all data will be written into/ read from a single file called name_
void setDensity(Mdouble density)
Allows density_ to be changed.
Species< LinearViscoelasticNormalSpecies > LinearViscoelasticSpecies
Mdouble getYMax() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMax() returns XMax...
Definition: DPMBase.cc:303
void setPosition(const Vec3D &position)
Sets the position of this BaseInteractable.
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:79
Mdouble getZMin() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMin() returns ZMin...
Definition: DPMBase.cc:311
This is a class defining walls.
Definition: InfiniteWall.h:47
int main(int argc, char **argv)
Definition: data2pvd.cpp:50
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:45
virtual void setupInitialConditions()
This function allows to set the initial conditions for our problem to be solved, by default particle ...
Definition: DPMBase.cc:966
void setSpecies(const ParticleSpecies *species)
Define the species of this wall.
Definition: BaseWall.cc:113

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-2014, The MercuryDPM Developers Team. All rights reserved.
2 //For the list of developers, see <http://www.MercuryDPM.org/Team>.
3 //
4 //Redistribution and use in source and binary forms, with or without
5 //modification, are permitted provided that the following conditions are met:
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above copyright
9 // notice, this list of conditions and the following disclaimer in the
10 // documentation and/or other materials provided with the distribution.
11 // * Neither the name MercuryDPM nor the
12 // names of its contributors may be used to endorse or promote products
13 // derived from this software without specific prior written permission.
14 //
15 //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 //ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 //WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 //DISCLAIMED. IN NO EVENT SHALL THE MERCURYDPM DEVELOPERS TEAM BE LIABLE FOR ANY
19 //DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 //(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 //LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 //ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 //(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 
26 // 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 
36 #include <Mercury3D.h>
37 #include <Particles/BaseParticle.h>
39 
41 class Tutorial5 : public Mercury3D
42 {
43  public:
44 
46  {
47  BaseParticle p0;
48  p0.setSpecies(speciesHandler.getObject(0));
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,
82  auto species = problem.speciesHandler.copyAndAddObject(LinearViscoelasticSpecies());
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
87 
88  problem.setSaveCount(10);
89  problem.dataFile.setFileType(FileType::ONE_FILE);
90  problem.restartFile.setFileType(FileType::ONE_FILE);
91  problem.fStatFile.setFileType(FileType::NO_FILE);
92  problem.eneFile.setFileType(FileType::NO_FILE);
93 
94  problem.setXBallsAdditionalArguments("-solidf -v0 -s .85");
95 
96  problem.setTimeStep(.005/50.0); // (collision time)/50.0
97  problem.solve(argc, argv);
98 
99  return 0;
100 }
void setVelocity(const Vec3D &velocity)
set the velocity of the BaseInteractable.
Mdouble getZMax() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMax() returns ZMax...
Definition: DPMBase.cc:319
void setSpecies(const ParticleSpecies *species)
void setRadius(const Mdouble radius)
Sets the particle's radius_ (and adjusts the mass_ accordingly, based on the particle's species) ...
Mdouble getXMax() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMax() returns XMax...
Definition: DPMBase.cc:287
file will not be created/read
This adds on the hierarchical grid code for 3D problems.
Definition: Mercury3D.h:35
all data will be written into/ read from a single file called name_
void setDensity(Mdouble density)
Allows density_ to be changed.
Species< LinearViscoelasticNormalSpecies > LinearViscoelasticSpecies
Mdouble getYMax() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMax() returns XMax...
Definition: DPMBase.cc:303
void setPosition(const Vec3D &position)
Sets the position of this BaseInteractable.
int main(int argc, char **argv)
Definition: data2pvd.cpp:50
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:45
virtual void setupInitialConditions()
This function allows to set the initial conditions for our problem to be solved, by default particle ...
Definition: DPMBase.cc:966

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-2014, The MercuryDPM Developers Team. All rights reserved.
2 //For the list of developers, see <http://www.MercuryDPM.org/Team>.
3 //
4 //Redistribution and use in source and binary forms, with or without
5 //modification, are permitted provided that the following conditions are met:
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above copyright
9 // notice, this list of conditions and the following disclaimer in the
10 // documentation and/or other materials provided with the distribution.
11 // * Neither the name MercuryDPM nor the
12 // names of its contributors may be used to endorse or promote products
13 // derived from this software without specific prior written permission.
14 //
15 //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 //ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 //WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 //DISCLAIMED. IN NO EVENT SHALL THE MERCURYDPM DEVELOPERS TEAM BE LIABLE FOR ANY
19 //DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 //(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 //LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 //ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 //(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 
26 // 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 
36 #include <Mercury3D.h>
37 #include <Particles/BaseParticle.h>
40 
42 class Tutorial6 : public Mercury3D
43 {
44  public:
45 
47  {
48  BaseParticle p0;
49  p0.setSpecies(speciesHandler.getObject(0));
50  p0.setRadius(0.5);//particle-1
51  p0.setPosition(Vec3D(0.25*getXMax(),0.5*getYMax(),0.75*getZMax()));
52  p0.setVelocity(Vec3D(0.5,0.0,-0.3));
53  particleHandler.copyAndAddObject(p0);
54 
55  p0.setRadius(0.6);// particle-2
56  p0.setPosition(Vec3D(0.75*getXMax(),0.5*getYMax(),0.5*getZMax()));
57  p0.setVelocity(Vec3D(-0.5,0.0,0.3));
58  particleHandler.copyAndAddObject(p0);
59 
62  b0.set(Vec3D(1.0,0.0,0.0),getXMin(),getXMax());
63  boundaryHandler.copyAndAddObject(b0);
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(5.0);
80  problem.setYMax(2.5);
81  problem.setZMax(5.0);
82  problem.setTimeMax(10.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,
87  auto species = problem.speciesHandler.copyAndAddObject(LinearViscoelasticSpecies());
88  species->setDensity(2500.0); // sets the species type-0 density
89  species->setStiffness(200000);// sets the spring stiffness
90  species->setDissipation(0.2);// sets the dissipation
92 
93  problem.setSaveCount(100);
94  problem.dataFile.setFileType(FileType::ONE_FILE);
95  problem.restartFile.setFileType(FileType::ONE_FILE);
96  problem.fStatFile.setFileType(FileType::NO_FILE);
97  problem.eneFile.setFileType(FileType::NO_FILE);
98 
99  problem.setXBallsAdditionalArguments("-solidf -v0");
100 
101  problem.setTimeStep(0.005/50.0);// (collision time)/50.0
102  problem.solve(argc, argv);
103 
104  return 0;
105 }
void set(Vec3D normal, Mdouble distanceLeft, Mdouble distanceRight)
Defines a periodic wall.
void setVelocity(const Vec3D &velocity)
set the velocity of the BaseInteractable.
Mdouble getZMax() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMax() returns ZMax...
Definition: DPMBase.cc:319
Mdouble getXMin() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMin() returns XMin...
Definition: DPMBase.cc:279
void setSpecies(const ParticleSpecies *species)
void setRadius(const Mdouble radius)
Sets the particle's radius_ (and adjusts the mass_ accordingly, based on the particle's species) ...
Defines a pair of periodic walls. Inherits from BaseBoundary.
Mdouble getXMax() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMax() returns XMax...
Definition: DPMBase.cc:287
file will not be created/read
This adds on the hierarchical grid code for 3D problems.
Definition: Mercury3D.h:35
all data will be written into/ read from a single file called name_
void setDensity(Mdouble density)
Allows density_ to be changed.
Species< LinearViscoelasticNormalSpecies > LinearViscoelasticSpecies
Mdouble getYMax() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMax() returns XMax...
Definition: DPMBase.cc:303
void setPosition(const Vec3D &position)
Sets the position of this BaseInteractable.
int main(int argc, char **argv)
Definition: data2pvd.cpp:50
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:45
virtual void setupInitialConditions()
This function allows to set the initial conditions for our problem to be solved, by default particle ...
Definition: DPMBase.cc:966

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-2014, The MercuryDPM Developers Team. All rights reserved.
2 //For the list of developers, see <http://www.MercuryDPM.org/Team>.
3 //
4 //Redistribution and use in source and binary forms, with or without
5 //modification, are permitted provided that the following conditions are met:
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above copyright
9 // notice, this list of conditions and the following disclaimer in the
10 // documentation and/or other materials provided with the distribution.
11 // * Neither the name MercuryDPM nor the
12 // names of its contributors may be used to endorse or promote products
13 // derived from this software without specific prior written permission.
14 //
15 //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 //ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 //WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 //DISCLAIMED. IN NO EVENT SHALL THE MERCURYDPM DEVELOPERS TEAM BE LIABLE FOR ANY
19 //DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 //(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 //LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 //ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 //(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 
26 // 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 
36 #include <Mercury3D.h>
37 #include <Particles/BaseParticle.h>
38 #include <Walls/InfiniteWall.h>
40 
42 class Tutorial7 : public Mercury3D
43 {
44  public:
45 
47  {
48  BaseParticle p0;
49  p0.setSpecies(speciesHandler.getObject(0));
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));
53  particleHandler.copyAndAddObject(p0);
54 
56  InfiniteWall w0;
57 
58  w0.setSpecies(speciesHandler.getObject(0));
59  w0.set(Vec3D(1.0,0.0,0.0),Vec3D(getXMax(),0.0,0.0));
60  wallHandler.copyAndAddObject(w0);
61 
62  w0.set(Vec3D(-1.0,0.0,0.0),Vec3D(getXMin(),0.0,0.0));
63  wallHandler.copyAndAddObject(w0);
64 
65  w0.set(Vec3D(0.0,1.0,0.0),Vec3D(0.0,getYMax(),0.0));
66  wallHandler.copyAndAddObject(w0);
67 
68  w0.set(Vec3D(0.0,-1.0,0.0),Vec3D(0.0,getYMin(),0.0));
69  wallHandler.copyAndAddObject(w0);
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,
92  auto species = problem.speciesHandler.copyAndAddObject(LinearViscoelasticSpecies());
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
97 
98  problem.setSaveCount(10);
99  problem.dataFile.setFileType(FileType::ONE_FILE);
100  problem.restartFile.setFileType(FileType::ONE_FILE);
101  problem.fStatFile.setFileType(FileType::NO_FILE);
102  problem.eneFile.setFileType(FileType::NO_FILE);
103 
104  problem.setWallsWriteVTK(FileType::ONE_FILE);
105  problem.setParticlesWriteVTK(true);
106 
107  problem.setXBallsAdditionalArguments("-solidf -v0 -s .85");
108 
109  problem.setTimeStep(0.005/50.0);// (collision time)/50.0
110  problem.solve(argc, argv);
111 
112  return 0;
113 }
void setVelocity(const Vec3D &velocity)
set the velocity of the BaseInteractable.
Mdouble getXMin() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMin() returns XMin...
Definition: DPMBase.cc:279
Mdouble getYMin() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMin() returns YMin...
Definition: DPMBase.cc:295
void setSpecies(const ParticleSpecies *species)
void setRadius(const Mdouble radius)
Sets the particle's radius_ (and adjusts the mass_ accordingly, based on the particle's species) ...
Mdouble getXMax() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMax() returns XMax...
Definition: DPMBase.cc:287
file will not be created/read
This adds on the hierarchical grid code for 3D problems.
Definition: Mercury3D.h:35
all data will be written into/ read from a single file called name_
void setDensity(Mdouble density)
Allows density_ to be changed.
Species< LinearViscoelasticNormalSpecies > LinearViscoelasticSpecies
Mdouble getYMax() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMax() returns XMax...
Definition: DPMBase.cc:303
void setPosition(const Vec3D &position)
Sets the position of this BaseInteractable.
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:79
This is a class defining walls.
Definition: InfiniteWall.h:47
int main(int argc, char **argv)
Definition: data2pvd.cpp:50
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:45
virtual void setupInitialConditions()
This function allows to set the initial conditions for our problem to be solved, by default particle ...
Definition: DPMBase.cc:966
void setSpecies(const ParticleSpecies *species)
Define the species of this wall.
Definition: BaseWall.cc:113

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-2014, The MercuryDPM Developers Team. All rights reserved.
2 //For the list of developers, see <http://www.MercuryDPM.org/Team>.
3 //
4 //Redistribution and use in source and binary forms, with or without
5 //modification, are permitted provided that the following conditions are met:
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above copyright
9 // notice, this list of conditions and the following disclaimer in the
10 // documentation and/or other materials provided with the distribution.
11 // * Neither the name MercuryDPM nor the
12 // names of its contributors may be used to endorse or promote products
13 // derived from this software without specific prior written permission.
14 //
15 //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 //ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 //WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 //DISCLAIMED. IN NO EVENT SHALL THE MERCURYDPM DEVELOPERS TEAM BE LIABLE FOR ANY
19 //DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 //(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 //LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 //ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 //(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 
26 // 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 
36 #include <Mercury3D.h>
37 #include <Particles/BaseParticle.h>
38 #include <Walls/InfiniteWall.h>
41 
43 class Tutorial8 : public Mercury3D
44 {
45  public:
46 
48  {
49  BaseParticle p0;
50  p0.setSpecies(speciesHandler.getObject(0));
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));
54  particleHandler.copyAndAddObject(p0);
55 
57  InfiniteWall w0;
58 
59  w0.setSpecies(speciesHandler.getObject(0));
60  w0.set(Vec3D(1.0,0.0,0.0),Vec3D(getXMax(), 0.0, 0.0));
61  wallHandler.copyAndAddObject(w0);
62 
63  w0.set(Vec3D(-1.0,0.0,0.0),Vec3D(getXMin(), 0.0, 0.0));
64  wallHandler.copyAndAddObject(w0);
65 
66  w0.set(Vec3D(0.0,1.0,0.0),Vec3D(0.0, getYMax(), 0.0));
67  wallHandler.copyAndAddObject(w0);
68 
69  w0.set(Vec3D(0.0,-1.0,0.0),Vec3D(0.0, getYMin(), 0.0));
70  wallHandler.copyAndAddObject(w0);
72 
75  w1.addObject(Vec3D(-1.0,0.0,0.0),Vec3D(0.75*getXMax(),0.0,0.0));
76  w1.addObject(Vec3D(1.0,0.0,0.0),Vec3D(0.25*getXMax(),0.0,0.0));
77  w1.addObject(Vec3D(0.0,-1.0,0.0),Vec3D(0.0,0.75*getYMax(),0.0));
78  w1.addObject(Vec3D(0.0,1.0,0.0),Vec3D(0.0,0.25*getYMax(),0.0));
79  wallHandler.copyAndAddObject(w1);
81  }
82 
83 };
85 
86 int main(int argc, char *argv[])
87 {
88 
89  // Problem setup
90  Tutorial8 problem; // instantiate an object of class Tutorial 8
91 
92  problem.setName("Tutorial8");
93  problem.setSystemDimensions(2);
94  problem.setGravity(Vec3D(0.0,0.0,0.0));
95  problem.setXMax(0.5);
96  problem.setYMax(0.5);
97  problem.setTimeMax(5.0);
98 
100  // The normal spring stiffness and normal dissipation is computed and set as
101  // For collision time tc=0.005 and restitution coefficeint rc=1.0,
102  auto species = problem.speciesHandler.copyAndAddObject(LinearViscoelasticSpecies());
103  species->setDensity(2500.0); // sets the species type-0 density
104  species->setStiffness(258.5);// sets the spring stiffness
105  species->setDissipation(0.0);// sets the dissipation
107 
108  problem.setSaveCount(10);
109  problem.dataFile.setFileType(FileType::ONE_FILE);
110  problem.restartFile.setFileType(FileType::ONE_FILE);
111  problem.fStatFile.setFileType(FileType::NO_FILE);
112  problem.eneFile.setFileType(FileType::NO_FILE);
113 
114  problem.setXBallsAdditionalArguments("-solidf -v0 -s .85");
115 
116  problem.setTimeStep(.005/50.0); // (collision time)/50.0
117  problem.solve(argc, argv);
118 
119  return 0;
120 }
void setVelocity(const Vec3D &velocity)
set the velocity of the BaseInteractable.
A IntersectionOfWalls is convex polygon defined as an intersection of InfiniteWall's.
Mdouble getXMin() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMin() returns XMin...
Definition: DPMBase.cc:279
Mdouble getYMin() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMin() returns YMin...
Definition: DPMBase.cc:295
void setSpecies(const ParticleSpecies *species)
void addObject(Vec3D normal, Vec3D point)
Adds a wall to the set of infinite walls, given an outward normal vector s.t. normal*x=normal*point.
void setRadius(const Mdouble radius)
Sets the particle's radius_ (and adjusts the mass_ accordingly, based on the particle's species) ...
Mdouble getXMax() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMax() returns XMax...
Definition: DPMBase.cc:287
file will not be created/read
This adds on the hierarchical grid code for 3D problems.
Definition: Mercury3D.h:35
all data will be written into/ read from a single file called name_
void setDensity(Mdouble density)
Allows density_ to be changed.
Species< LinearViscoelasticNormalSpecies > LinearViscoelasticSpecies
Mdouble getYMax() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMax() returns XMax...
Definition: DPMBase.cc:303
void setPosition(const Vec3D &position)
Sets the position of this BaseInteractable.
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:79
This is a class defining walls.
Definition: InfiniteWall.h:47
int main(int argc, char **argv)
Definition: data2pvd.cpp:50
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:45
virtual void setupInitialConditions()
This function allows to set the initial conditions for our problem to be solved, by default particle ...
Definition: DPMBase.cc:966
void setSpecies(const ParticleSpecies *species)
Define the species of this wall.
Definition: BaseWall.cc:113

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-2014, The MercuryDPM Developers Team. All rights reserved.
2 //For the list of developers, see <http://www.MercuryDPM.org/Team>.
3 //
4 //Redistribution and use in source and binary forms, with or without
5 //modification, are permitted provided that the following conditions are met:
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above copyright
9 // notice, this list of conditions and the following disclaimer in the
10 // documentation and/or other materials provided with the distribution.
11 // * Neither the name MercuryDPM nor the
12 // names of its contributors may be used to endorse or promote products
13 // derived from this software without specific prior written permission.
14 //
15 //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 //ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 //WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 //DISCLAIMED. IN NO EVENT SHALL THE MERCURYDPM DEVELOPERS TEAM BE LIABLE FOR ANY
19 //DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 //(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 //LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 //ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 //(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 
26 // 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 
36 #include <Mercury3D.h>
37 #include <Particles/BaseParticle.h>
38 #include <Walls/InfiniteWall.h>
40 
42 class Tutorial9 : public Mercury3D
43 {
44  public:
45 
47  {
48  BaseParticle p0;
49 
50  p0.setSpecies(speciesHandler.getObject(0));
51  p0.setRadius(0.005);
52  p0.setPosition(Vec3D(0.05*getXMax(),0.01*getYMax(),getZMin()+p0.getRadius()));
53  p0.setVelocity(Vec3D(0.0,0.0,0.0));
54  particleHandler.copyAndAddObject(p0);
55 
56  // sets the particle to species type-2
57  p0.setSpecies(speciesHandler.getObject(1));
58  p0.setRadius(0.005);
59  p0.setPosition(Vec3D(0.05*getXMax(),0.21*getYMax(),getZMin()+p0.getRadius()));
60  p0.setVelocity(Vec3D(0.0,0.0,0.0));
61  particleHandler.copyAndAddObject(p0);
62 
63  // sets the particle to species type-3
64  p0.setSpecies(speciesHandler.getObject(2));
65  p0.setRadius(0.005);
66  p0.setPosition(Vec3D(0.05*getXMax(),0.41*getYMax(),getZMin()+p0.getRadius()));
67  p0.setVelocity(Vec3D(0.0,0.0,0.0));
68  particleHandler.copyAndAddObject(p0);
69 
70 
72  InfiniteWall w0;
73 
74  w0.setSpecies(speciesHandler.getObject(0));
75  w0.set(Vec3D(0.0,0.0,-1.0),Vec3D(0.0,0.0,getZMin()));
76  wallHandler.copyAndAddObject(w0);
78 
79  }
80 
81 };
83 
85 int main(int argc, char *argv[])
86 {
87 
88  // Problem setup
89  Tutorial9 problem; // instantiate an object of class Tutorial 9
90 
91  double angle = constants::pi/180.0*20.0;
92 
93  problem.setName("Tutorial9");
94  problem.setSystemDimensions(3);
95  problem.setGravity(Vec3D(sin(angle),0.0,-cos(angle))*9.81);
96  problem.setXMax(0.3);
97  problem.setYMax(0.3);
98  problem.setZMax(0.05);
99  problem.setTimeMax(0.5);
100 
101  auto species0 = problem.speciesHandler.copyAndAddObject(LinearViscoelasticFrictionSpecies());
102  auto species1 = problem.speciesHandler.copyAndAddObject(LinearViscoelasticFrictionSpecies());
103  auto species2 = problem.speciesHandler.copyAndAddObject(LinearViscoelasticFrictionSpecies());
104  auto species01 = problem.speciesHandler.getMixedObject(species0, species1);
105  auto species02 = problem.speciesHandler.getMixedObject(species0, species2);
106 
107  // The normal spring stiffness and normal dissipation is computed and set as
108  // For collision time tc=0.005 and restitution coefficeint rc=0.88,
109 
110  species0->setDensity(2500.0); // sets the species type-0 density
111  species0->setStiffness(259.018);// sets the spring stiffness
112  species0->setSlidingStiffness(2.0/7.0*species0->getStiffness());
113  species0->setRollingStiffness(2.0/5.0*species0->getStiffness());
114  species0->setDissipation(0.0334);// sets the dissipation
115  species0->setSlidingFrictionCoefficient(0.0);
116  species0->setRollingFrictionCoefficient(0.0);
117 
118  species1->setDensity(2500.0); // sets the species type-1 density
119  species1->setStiffness(259.018);// sets the spring stiffness
120  species1->setDissipation(0.0334);// sets the dissipation
121  species1->setSlidingStiffness(2.0/7.0*species1->getStiffness());
122  species1->setRollingStiffness(2.0/5.0*species1->getStiffness());
123  species1->setSlidingFrictionCoefficient(0.5);
124  species1->setRollingFrictionCoefficient(0.0);
125 
126  species01->setStiffness(259.018);
127  species01->setDissipation(0.0334);// sets the dissipation
128  species01->setSlidingStiffness(2.0/7.0*species01->getStiffness());
129  species01->setRollingStiffness(2.0/5.0*species01->getStiffness());
130  species01->setSlidingFrictionCoefficient(0.5);
131  species01->setRollingFrictionCoefficient(0.0);
132 
133  species2->setDensity(2500.0); // sets the species type-2 density
134  species2->setStiffness(258.5);// sets the spring stiffness
135  species2->setDissipation(0.0);// sets the dissipation
136  species2->setSlidingStiffness(2.0/7.0*species2->getStiffness());
137  species2->setRollingStiffness(2.0/5.0*species2->getStiffness());
138  species2->setSlidingFrictionCoefficient(0.5);
139  species2->setRollingFrictionCoefficient(0.5);
140 
141  species02->setStiffness(259.018);
142  species02->setDissipation(0.0334);// sets the dissipation
143  species02->setSlidingStiffness(2.0/7.0*species02->getStiffness());
144  species02->setRollingStiffness(2.0/5.0*species02->getStiffness());
145  species02->setSlidingFrictionCoefficient(0.5);
146  species02->setRollingFrictionCoefficient(0.5);
147 
148  problem.setSaveCount(10);
149  problem.dataFile.setFileType(FileType::ONE_FILE);
150  problem.restartFile.setFileType(FileType::ONE_FILE);
151  problem.fStatFile.setFileType(FileType::ONE_FILE);
152  problem.eneFile.setFileType(FileType::NO_FILE);
153 
154  problem.setXBallsAdditionalArguments("-solidf -v0 -s 8 -p 10 -rottheta .2 -noborder 4 -cube -o 100 -w 600 -h 300");
155 
156  problem.setTimeStep(0.005/50.0);
157  problem.solve(argc, argv);
158 
159  return 0;
160 }
void setVelocity(const Vec3D &velocity)
set the velocity of the BaseInteractable.
void setSpecies(const ParticleSpecies *species)
Species< LinearViscoelasticNormalSpecies, FrictionSpecies > LinearViscoelasticFrictionSpecies
void setRadius(const Mdouble radius)
Sets the particle's radius_ (and adjusts the mass_ accordingly, based on the particle's species) ...
Mdouble cos(Mdouble x)
Definition: ExtendedMath.cc:60
Mdouble getXMax() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMax() returns XMax...
Definition: DPMBase.cc:287
file will not be created/read
Mdouble sin(Mdouble x)
Definition: ExtendedMath.cc:42
const Mdouble pi
Definition: ExtendedMath.h:42
This adds on the hierarchical grid code for 3D problems.
Definition: Mercury3D.h:35
all data will be written into/ read from a single file called name_
Mdouble getRadius() const
Returns the particle's radius_.
Mdouble getYMax() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMax() returns XMax...
Definition: DPMBase.cc:303
void setPosition(const Vec3D &position)
Sets the position of this BaseInteractable.
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:79
Mdouble getZMin() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMin() returns ZMin...
Definition: DPMBase.cc:311
This is a class defining walls.
Definition: InfiniteWall.h:47
int main(int argc, char **argv)
Definition: data2pvd.cpp:50
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:45
virtual void setupInitialConditions()
This function allows to set the initial conditions for our problem to be solved, by default particle ...
Definition: DPMBase.cc:966
void setSpecies(const ParticleSpecies *species)
Define the species of this wall.
Definition: BaseWall.cc:113

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

Particles driven by a rotating coil (code)

Return to tutorial Particles driven by a rotating coil

#include "Mercury3D.h"
#include "Walls/Coil.h"
class CoilSelfTest : public Mercury3D
{
private:
void setupInitialConditions() override
{
// gravity, particle radius
setGravity(Vec3D(0.0, -9.8, 0.0));
const double particleRadius = 0.2;
// set problem geometry
setXMax(1.0);
setYMax(5.0);
setZMax(2.0);
setXMin(-1.0);
setYMin(-1.0);
species.setDensity(1000);
const double tc = 0.05;
const double restitutionCoefficient = 0.8;
const double particleMass = pow(particleRadius, 3) * constants::pi * 4.0 / 3.0 * species.getDensity();
species.setCollisionTimeAndRestitutionCoefficient(tc, restitutionCoefficient, particleMass);
speciesHandler.copyAndAddObject(species);
w.setSpecies(speciesHandler.getObject(0));
//front wall
w.set(Vec3D(-1, 0, 0), Vec3D(getXMin(), 0, 0));
wallHandler.copyAndAddObject(w);
//back wall
w.set(Vec3D(1, 0, 0), Vec3D(getXMax(), 0, 0));
wallHandler.copyAndAddObject(w);
//bottom wall
w.set(Vec3D(0, -1, 0), Vec3D(0, getYMin(), 0));
wallHandler.copyAndAddObject(w);
//top wall
w.set(Vec3D(0, 1, 0), Vec3D(0, getYMax(), 0));
wallHandler.copyAndAddObject(w);
//left wall
w.set(Vec3D(0, 0, -1), Vec3D(0, 0, getZMin()));
wallHandler.copyAndAddObject(w);
//right wall
rightWall.setSpecies(speciesHandler.getObject(0));
rightWall.set(Vec3D(0, 0, 1), getZMax(), 1.0);
wallHandler.copyAndAddObject(rightWall);
// creation of the coil and setting of its properties
coil = wallHandler.copyAndAddObject(Coil());
coil->setSpecies(speciesHandler.getObject(0));
// the syntax to set the coil geometry is as follows:
// set(Start position, Length, Radius, Number of turns, Rotation speed, Thickness)
coil->set(Vec3D(0, 0, 0), 1.0, 1.0 - particleRadius, 2.0, -1.0, 0.5 * particleRadius);
particleHandler.clear();
p0.setSpecies(speciesHandler.getObject(0));
p0.setVelocity(Vec3D(0.0, 0.0, 0.0));
p0.setRadius(particleRadius);
/*
//Single test case
double distance;
Vec3D normal;
p0.setPosition(Vec3D(1.0,0.0,0.0));
if(coil->getDistance_and_normal(p0, distance, normal))
std::cout<<"Collision, distance screw="<<distance<<std::endl;
else
std::cout<<"No collision, distance screw="<<distance<<std::endl;
*/
// Nx*Ny*Nz particles are created and placed on evenly spaced positions in
// the domain [xMin_,xMax_]*[yMin_,yMax_]*[zMin_,zMax_] (unless their position
// is already occupied by the coil).
const unsigned int Nx = static_cast<unsigned int> (std::floor((getXMax() - getXMin()) / (2.1 * particleRadius)));
const unsigned int Ny = static_cast<unsigned int> (std::floor((getYMax() - getYMin()) / (2.1 * particleRadius)));
const unsigned int Nz = static_cast<unsigned int> (std::floor((getZMax() - getZMin()) / (2.1 * particleRadius)));
Mdouble distance;
Vec3D normal;
// Place particles
for (unsigned int i = 0; i < Nx; i++)
{
for (unsigned int j = 0; j < Ny; j++)
{
for (unsigned int k = 0; k < Nz; k++)
{
p0.setPosition(Vec3D(getXMin() + (getXMax() - getXMin()) * (0.5 + i) / Nx,
getYMin() + (getYMax() - getYMin()) * (0.5 + j) / Ny,
getZMin() + (getZMax() - getZMin()) * (0.5 + k) / Nz));
if (!coil->getDistanceAndNormal(p0, distance, normal)) //if there is no collision with the coil
{
particleHandler.copyAndAddObject(p0);
}
else
{
logger(DEBUG, "particle at position % could not be inserted", p0.getPosition());
}
}
}
}
}
void actionsBeforeTimeStep() override
{
if (getTime() > 1)
{
coil->move_time(getTimeStep());
}
}
public:
// ! [CST:datamembers]
Coil* coil;
};
int main(int argc UNUSED, char* argv[] UNUSED)
{
// create CoilSelfTest object
CoilSelfTest problem;
// set some basic problem properties
problem.setName("CoilSelfTest");
problem.setSystemDimensions(3);
problem.setTimeStep(0.02 * 0.05);
problem.setTimeMax(0.5);
problem.setSaveCount(helpers::getSaveCountFromNumberOfSavesAndTimeMaxAndTimestep(1000, problem.getTimeMax(),
problem.getTimeStep()));
// actually solving the problem
problem.solve();
}
// the end
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.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
species.setCollisionTimeAndRestitutionCoefficient( tc,
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)
//solve
problem.solve();
} // the end
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