MercuryDPM  Beta
 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.setRadius(0.05); // sets particle radius
52  p0.setPosition(Vec3D(0.1*getXMax(),0.1*getYMax(),0.1*getZMax())); // sets particle position
53  p0.setVelocity(Vec3D(0.5,0.1,0.1));
54  particleHandler.copyAndAddObject(p0);
56  }
57 };
59 
61 int main(int argc, char *argv[])
62 {
63  // Problem setup
64  Tutorial1 problem;
65 
67  problem.setName("Tutorial1");
68  problem.setSystemDimensions(3);
69  problem.setGravity(Vec3D(0.0,0.0,0.0));
70  problem.setXMax(1.0);
71  problem.setYMax(1.0);
72  problem.setZMax(1.0);
73  problem.setTimeMax(2.0);
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,
79  auto species = problem.speciesHandler.copyAndAddObject(LinearViscoelasticSpecies());
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
84 
86  problem.setSaveCount(10);
87  problem.dataFile.setFileType(FileType::ONE_FILE);
88  problem.restartFile.setFileType(FileType::ONE_FILE);
89  problem.fStatFile.setFileType(FileType::NO_FILE);
90  problem.eneFile.setFileType(FileType::NO_FILE);
91  std::cout << problem.dataFile.getCounter() << std::endl;
93 
95  problem.setXBallsAdditionalArguments("-solidf -v0");
97 
99  problem.setTimeStep(.005/50.0); // (collision time)/50.0
100  problem.solve(argc, argv);
102  return 0;
103 }
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:259
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:231
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_
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:245
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:833

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.setRadius(0.05);
46  p0.setPosition(Vec3D(0.5*getXMax(),0.5*getYMax(),getZMax()));
47  p0.setVelocity(Vec3D(0.0,0.0,0.0));
48  particleHandler.copyAndAddObject(p0);
49  }
50 
51 };
52 
53 int main(int argc, char *argv[])
54 {
55 
56  // Problem setup
57  Tutorial2 problem;
58 
59  problem.setName("Tutorial2");
60  problem.setSystemDimensions(3);
61  problem.setGravity(Vec3D(0.0,0.0,-9.81));
62  problem.setXMax(1.0);
63  problem.setYMax(1.0);
64  problem.setZMax(5.0);
65  problem.setTimeMax(1.5);
66 
68  // The normal spring stiffness and normal dissipation is computed and set as
69  // For collision time tc=0.005 and restitution coefficeint rc=1.0,
70  auto species = problem.speciesHandler.copyAndAddObject(LinearViscoelasticSpecies());
71  species->setDensity(2500.0); // sets the species type-0 density
72  species->setStiffness(258.5);// sets the spring stiffness
73  species->setDissipation(0.0);// sets the dissipation
75 
76  problem.setSaveCount(10);
77  problem.dataFile.setFileType(FileType::ONE_FILE);
78  problem.restartFile.setFileType(FileType::ONE_FILE);
79  problem.fStatFile.setFileType(FileType::NO_FILE);
80  problem.eneFile.setFileType(FileType::NO_FILE);
81 
82  problem.setXBallsAdditionalArguments("-solidf -v0");
83 
84  problem.setTimeStep(.005/50.0);// (collision time)/50.0
85  problem.solve(argc, argv);
86 
87  return 0;
88 }
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:259
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:231
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_
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:245
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:833

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.setRadius(0.005);
50  p0.setPosition(Vec3D(0.5*getXMax(),0.5*getYMax(),getZMax()));
51  p0.setVelocity(Vec3D(0.0,0.0,0.0));
52  particleHandler.copyAndAddObject(p0);
53 
55  InfiniteWall w0;
56  w0.set(Vec3D(0.0,0.0,-1.0),Vec3D(0, 0, getZMin()));
57  wallHandler.copyAndAddObject(w0);
59  }
60 
61 };
63 
64 int main(int argc, char *argv[])
65 {
66 
67  // Problem setup
68  Tutorial3 problem;
69 
70  problem.setName("Tutorial3");
71  problem.setSystemDimensions(3);
72  problem.setGravity(Vec3D(0.0,0.0,-9.81));
73  problem.setXMax(1.0);
74  problem.setYMax(1.0);
75  problem.setZMax(2.0);
76  problem.setTimeMax(5.0);
77 
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,
81  auto species = problem.speciesHandler.copyAndAddObject(LinearViscoelasticSpecies());
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
86 
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 
93  problem.setXBallsAdditionalArguments("-solidf -v0");
94 
95  problem.setTimeStep(0.005/50.0); // (collision time)/50.0
96  problem.solve(argc, argv);
97 
98  return 0;
99 }
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:259
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:231
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_
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:245
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:70
Mdouble getZMin() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMin() returns ZMin...
Definition: DPMBase.cc:252
This is a class defining walls.
Definition: InfiniteWall.h:43
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:833

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.setRadius(0.005);
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  InfiniteWall w0;
52  w0.set(Vec3D(0.0,0.0,-1.0),Vec3D(0.0,0.0,getZMin()));
53  wallHandler.copyAndAddObject(w0);
54  }
55 
56 };
57 
58 int main(int argc, char *argv[])
59 {
60 
61  // Problem setup
62  Tutorial4 problem;
63 
64  problem.setName("Tutorial4");
65  problem.setSystemDimensions(3);
66  problem.setGravity(Vec3D(0.0,0.0,-9.81));
67  problem.setXMax(1.0);
68  problem.setYMax(1.0);
69  problem.setZMax(2.0);
70  problem.setTimeMax(5.0);
71 
73  // The normal spring stiffness and normal dissipation is computed and set as
74  // For collision time tc=0.005 and restitution coefficeint rc=0.88,
75  auto species = problem.speciesHandler.copyAndAddObject(LinearViscoelasticSpecies());
76  species->setDensity(2500.0); // sets the species type-0 density
77  species->setStiffness(259.0159);// sets the spring stiffness
78  species->setDissipation(0.0334);// sets the dissipation
80 
81  problem.setSaveCount(10);
82  problem.dataFile.setFileType(FileType::ONE_FILE);
83  problem.restartFile.setFileType(FileType::ONE_FILE);
84  problem.fStatFile.setFileType(FileType::NO_FILE);
85  problem.eneFile.setFileType(FileType::NO_FILE);
86 
87  problem.setXBallsAdditionalArguments("-solidf -v0");
88 
89  problem.setTimeStep(0.005/50.0); // (collision time)/50.0
90  problem.solve(argc, argv);
91 
92  return 0;
93 }
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:259
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:231
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_
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:245
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:70
Mdouble getZMin() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMin() returns ZMin...
Definition: DPMBase.cc:252
This is a class defining walls.
Definition: InfiniteWall.h:43
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:833

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 
49  p0.setRadius(0.005); //particle-1 radius
50  p0.setPosition(Vec3D(0.25*getXMax(),0.5*getYMax(),0.5*getZMax()));
51  p0.setVelocity(Vec3D(0.25,0.0,0.0));
52  particleHandler.copyAndAddObject(p0); // 1st particle created
53 
54  p0.setRadius(0.005); // particle-2 radius
55  p0.setPosition(Vec3D(0.75*getXMax(),0.5*getYMax(),0.5*getZMax()));
56  p0.setVelocity(Vec3D(-0.25,0.0,0.0));
57  particleHandler.copyAndAddObject(p0); // 2nd particle created
58  }
59 
60 };
62 
64 int main(int argc, char *argv[])
65 {
66 
67  // Problem setup
68  Tutorial5 problem;
69 
70  problem.setName("Tutorial5");
71  problem.setSystemDimensions(3);
72  problem.setGravity(Vec3D(0.0,0.0,0.0));
73  problem.setXMax(0.5);
74  problem.setYMax(0.25);
75  problem.setZMax(0.5);
76  problem.setTimeMax(2.0);
77 
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,
81  auto species = problem.speciesHandler.copyAndAddObject(LinearViscoelasticSpecies());
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
86 
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 
93  problem.setXBallsAdditionalArguments("-solidf -v0 -s .85");
94 
95  problem.setTimeStep(.005/50.0); // (collision time)/50.0
96  problem.solve(argc, argv);
97 
98  return 0;
99 }
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:259
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:231
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_
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:245
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:833

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.setRadius(0.005);//particle-1
50  p0.setPosition(Vec3D(0.25*getXMax(),0.5*getYMax(),0.5*getZMax()));
51  p0.setVelocity(Vec3D(0.25,0.0,0.0));
52  particleHandler.copyAndAddObject(p0);
53 
54  p0.setRadius(0.005);// particle-2
55  p0.setPosition(Vec3D(0.75*getXMax(),0.5*getYMax(),0.5*getZMax()));
56  p0.setVelocity(Vec3D(-0.25,0.0,0.0));
57  particleHandler.copyAndAddObject(p0);
58 
61  b0.set(Vec3D(1.0,0.0,0.0),getXMin(),getXMax());
62  boundaryHandler.copyAndAddObject(b0);
64  }
65 
66 };
68 
69 int main(int argc, char *argv[])
70 {
71 
72  // Problem setup
73  Tutorial6 problem; // instantiate an object of class Tutorial 6
74 
75  problem.setName("Tutorial6");
76  problem.setSystemDimensions(3);
77  problem.setGravity(Vec3D(0.0,0.0,0.0));
78  problem.setXMax(0.5);
79  problem.setYMax(0.25);
80  problem.setZMax(0.5);
81  problem.setTimeMax(5.0);
82 
84  // The normal spring stiffness and normal dissipation is computed and set as
85  // For collision time tc=0.005 and restitution coefficeint rc=1.0,
86  auto species = problem.speciesHandler.copyAndAddObject(LinearViscoelasticSpecies());
87  species->setDensity(2500.0); // sets the species type-0 density
88  species->setStiffness(258.5);// sets the spring stiffness
89  species->setDissipation(0.0);// sets the dissipation
91 
92  problem.setSaveCount(10);
93  problem.dataFile.setFileType(FileType::ONE_FILE);
94  problem.restartFile.setFileType(FileType::ONE_FILE);
95  problem.fStatFile.setFileType(FileType::NO_FILE);
96  problem.eneFile.setFileType(FileType::NO_FILE);
97 
98  problem.setXBallsAdditionalArguments("-solidf -v0 -s .85");
99 
100  problem.setTimeStep(0.005/50.0);// (collision time)/50.0
101  problem.solve(argc, argv);
102 
103  return 0;
104 }
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:259
Mdouble getXMin() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMin() returns XMin...
Definition: DPMBase.cc:224
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:231
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_
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:245
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:833

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.setRadius(0.005);
50  p0.setPosition(Vec3D(0.5*getXMax(),0.5*getYMax(),0.0));
51  p0.setVelocity(Vec3D(1.2,1.3,0.0));
52  particleHandler.copyAndAddObject(p0);
53 
55  InfiniteWall w0;
56 
57  w0.set(Vec3D(1.0,0.0,0.0),Vec3D(getXMax(),0.0,0.0));
58  wallHandler.copyAndAddObject(w0);
59 
60  w0.set(Vec3D(-1.0,0.0,0.0),Vec3D(getXMin(),0.0,0.0));
61  wallHandler.copyAndAddObject(w0);
62 
63  w0.set(Vec3D(0.0,1.0,0.0),Vec3D(0.0,getYMax(),0.0));
64  wallHandler.copyAndAddObject(w0);
65 
66  w0.set(Vec3D(0.0,-1.0,0.0),Vec3D(0.0,getYMin(),0.0));
67  wallHandler.copyAndAddObject(w0);
69  }
70 
71 };
73 
74 int main(int argc, char *argv[])
75 {
76  // Problem setup
77  Tutorial7 problem; // instantiate an object of class Tutorial 6
78 
79  problem.setName("Tutorial7");
80  problem.setSystemDimensions(2);
81  problem.setGravity(Vec3D(0.0,0.0,0.0));
82  problem.setXMax(1);
83  problem.setYMax(0.5);
84  problem.setTimeMax(5.0);
85 
87  // The normal spring stiffness and normal dissipation is computed and set as
88  // For collision time tc=0.005 and restitution coefficeint rc=1.0,
89  auto species = problem.speciesHandler.copyAndAddObject(LinearViscoelasticSpecies());
90  species->setDensity(2500.0); // sets the species type-0 density
91  species->setStiffness(258.5);// sets the spring stiffness
92  species->setDissipation(0.0);// sets the dissipation
94 
95  problem.setSaveCount(10);
96  problem.dataFile.setFileType(FileType::ONE_FILE);
97  problem.restartFile.setFileType(FileType::ONE_FILE);
98  problem.fStatFile.setFileType(FileType::NO_FILE);
99  problem.eneFile.setFileType(FileType::NO_FILE);
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 }
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:224
Mdouble getYMin() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMin() returns YMin...
Definition: DPMBase.cc:238
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:231
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_
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:245
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:70
This is a class defining walls.
Definition: InfiniteWall.h:43
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:833

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.setRadius(0.005);
51  p0.setPosition(Vec3D(0.15*getXMax(),0.3335*getYMax(),0.0));
52  p0.setVelocity(Vec3D(1.2,0.2,0.0));
53  particleHandler.copyAndAddObject(p0);
54 
56  InfiniteWall w0;
57 
58  w0.set(Vec3D(1.0,0.0,0.0),Vec3D(getXMax(), 0.0, 0.0));
59  wallHandler.copyAndAddObject(w0);
60 
61  w0.set(Vec3D(-1.0,0.0,0.0),Vec3D(getXMin(), 0.0, 0.0));
62  wallHandler.copyAndAddObject(w0);
63 
64  w0.set(Vec3D(0.0,1.0,0.0),Vec3D(0.0, getYMax(), 0.0));
65  wallHandler.copyAndAddObject(w0);
66 
67  w0.set(Vec3D(0.0,-1.0,0.0),Vec3D(0.0, getYMin(), 0.0));
68  wallHandler.copyAndAddObject(w0);
70 
73  w1.addObject(Vec3D(-1.0,0.0,0.0),Vec3D(0.75*getXMax(),0.0,0.0));
74  w1.addObject(Vec3D(1.0,0.0,0.0),Vec3D(0.25*getXMax(),0.0,0.0));
75  w1.addObject(Vec3D(0.0,-1.0,0.0),Vec3D(0.0,0.75*getYMax(),0.0));
76  w1.addObject(Vec3D(0.0,1.0,0.0),Vec3D(0.0,0.25*getYMax(),0.0));
77  wallHandler.copyAndAddObject(w1);
79  }
80 
81 };
83 
84 int main(int argc, char *argv[])
85 {
86 
87  // Problem setup
88  Tutorial8 problem; // instantiate an object of class Tutorial 8
89 
90  problem.setName("Tutorial8");
91  problem.setSystemDimensions(2);
92  problem.setGravity(Vec3D(0.0,0.0,0.0));
93  problem.setXMax(0.5);
94  problem.setYMax(0.5);
95  problem.setTimeMax(5.0);
96 
98  // The normal spring stiffness and normal dissipation is computed and set as
99  // For collision time tc=0.005 and restitution coefficeint rc=1.0,
100  auto species = problem.speciesHandler.copyAndAddObject(LinearViscoelasticSpecies());
101  species->setDensity(2500.0); // sets the species type-0 density
102  species->setStiffness(258.5);// sets the spring stiffness
103  species->setDissipation(0.0);// sets the dissipation
105 
106  problem.setSaveCount(10);
107  problem.dataFile.setFileType(FileType::ONE_FILE);
108  problem.restartFile.setFileType(FileType::ONE_FILE);
109  problem.fStatFile.setFileType(FileType::NO_FILE);
110  problem.eneFile.setFileType(FileType::NO_FILE);
111 
112  problem.setXBallsAdditionalArguments("-solidf -v0 -s .85");
113 
114  problem.setTimeStep(.005/50.0); // (collision time)/50.0
115  problem.solve(argc, argv);
116 
117  return 0;
118 }
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:224
Mdouble getYMin() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMin() returns YMin...
Definition: DPMBase.cc:238
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:231
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_
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:245
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:70
This is a class defining walls.
Definition: InfiniteWall.h:43
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:833

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.setIndSpecies(0); // sets the particle to be as species type-1
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  p0.setIndSpecies(1); // sets the particle to species type-2
57  p0.setRadius(0.005);
58  p0.setPosition(Vec3D(0.05*getXMax(),0.21*getYMax(),getZMin()+p0.getRadius()));
59  p0.setVelocity(Vec3D(0.0,0.0,0.0));
60  particleHandler.copyAndAddObject(p0);
61 
62  p0.setIndSpecies(2); // sets the particle to species type-3
63  p0.setRadius(0.005);
64  p0.setPosition(Vec3D(0.05*getXMax(),0.41*getYMax(),getZMin()+p0.getRadius()));
65  p0.setVelocity(Vec3D(0.0,0.0,0.0));
66  particleHandler.copyAndAddObject(p0);
67 
68 
70  InfiniteWall w0;
71 
72  w0.set(Vec3D(0.0,0.0,-1.0),Vec3D(0.0,0.0,getZMin()));
73  wallHandler.copyAndAddObject(w0);
75 
76  }
77 
78 };
80 
82 int main(int argc, char *argv[])
83 {
84 
85  // Problem setup
86  Tutorial9 problem; // instantiate an object of class Tutorial 9
87 
88  double angle = constants::pi/180.0*20.0;
89 
90  problem.setName("Tutorial9");
91  problem.setSystemDimensions(3);
92  problem.setGravity(Vec3D(sin(angle),0.0,-cos(angle))*9.81);
93  problem.setXMax(0.3);
94  problem.setYMax(0.3);
95  problem.setZMax(0.05);
96  problem.setTimeMax(0.5);
97 
98  auto species0 = problem.speciesHandler.copyAndAddObject(LinearViscoelasticFrictionSpecies());
99  auto species1 = problem.speciesHandler.copyAndAddObject(LinearViscoelasticFrictionSpecies());
100  auto species2 = problem.speciesHandler.copyAndAddObject(LinearViscoelasticFrictionSpecies());
101  auto species01 = problem.speciesHandler.getMixedObject(species0, species1);
102  auto species02 = problem.speciesHandler.getMixedObject(species0, species2);
103 
104  // The normal spring stiffness and normal dissipation is computed and set as
105  // For collision time tc=0.005 and restitution coefficeint rc=0.88,
106 
107  species0->setDensity(2500.0); // sets the species type-0 density
108  species0->setStiffness(259.018);// sets the spring stiffness
109  species0->setSlidingStiffness(2.0/7.0*species0->getStiffness());
110  species0->setRollingStiffness(2.0/5.0*species0->getStiffness());
111  species0->setDissipation(0.0334);// sets the dissipation
112  species0->setSlidingFrictionCoefficient(0.0);
113  species0->setRollingFrictionCoefficient(0.0);
114 
115  species1->setDensity(2500.0); // sets the species type-1 density
116  species1->setStiffness(259.018);// sets the spring stiffness
117  species1->setDissipation(0.0334);// sets the dissipation
118  species1->setSlidingStiffness(2.0/7.0*species1->getStiffness());
119  species1->setRollingStiffness(2.0/5.0*species1->getStiffness());
120  species1->setSlidingFrictionCoefficient(0.5);
121  species1->setRollingFrictionCoefficient(0.0);
122 
123  species01->setStiffness(259.018);
124  species01->setDissipation(0.0334);// sets the dissipation
125  species01->setSlidingStiffness(2.0/7.0*species01->getStiffness());
126  species01->setRollingStiffness(2.0/5.0*species01->getStiffness());
127  species01->setSlidingFrictionCoefficient(0.5);
128  species01->setRollingFrictionCoefficient(0.0);
129 
130  species2->setDensity(2500.0); // sets the species type-2 density
131  species2->setStiffness(258.5);// sets the spring stiffness
132  species2->setDissipation(0.0);// sets the dissipation
133  species2->setSlidingStiffness(2.0/7.0*species2->getStiffness());
134  species2->setRollingStiffness(2.0/5.0*species2->getStiffness());
135  species2->setSlidingFrictionCoefficient(0.5);
136  species2->setRollingFrictionCoefficient(0.5);
137 
138  species02->setStiffness(259.018);
139  species02->setDissipation(0.0334);// sets the dissipation
140  species02->setSlidingStiffness(2.0/7.0*species02->getStiffness());
141  species02->setRollingStiffness(2.0/5.0*species02->getStiffness());
142  species02->setSlidingFrictionCoefficient(0.5);
143  species02->setRollingFrictionCoefficient(0.5);
144 
145  problem.setSaveCount(10);
146  problem.dataFile.setFileType(FileType::ONE_FILE);
147  problem.restartFile.setFileType(FileType::ONE_FILE);
148  problem.fStatFile.setFileType(FileType::ONE_FILE);
149  problem.eneFile.setFileType(FileType::NO_FILE);
150 
151  problem.setXBallsAdditionalArguments("-solidf -v0 -s 8 -p 10 -rottheta .2 -noborder 4 -cube -o 100 -w 600 -h 300");
152 
153  problem.setTimeStep(0.005/50.0);
154  problem.solve(argc, argv);
155 
156  return 0;
157 }
void setVelocity(const Vec3D &velocity)
set the velocity of the BaseInteractable.
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 getXMax() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMax() returns XMax...
Definition: DPMBase.cc:231
file will not be created/read
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_
MERCURY_DEPRECATED void setIndSpecies(unsigned int indSpecies)
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:245
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:70
Mdouble getZMin() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMin() returns ZMin...
Definition: DPMBase.cc:252
This is a class defining walls.
Definition: InfiniteWall.h:43
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:833

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:
// gravity, particle radius
setGravity(Vec3D(0.0, -9.8, 0.0));
particleRadius = 0.2;
// set problem geometry
setXMax(1.0);
setYMax(5.0);
setZMax(2.0);
setXMin(-1.0);
setYMin(-1.0);
species = speciesHandler.copyAndAddObject(LinearViscoelasticSpecies());
species->setDensity(1000);
species->setCollisionTimeAndRestitutionCoefficient(0.05, 0.8, pow(particleRadius, 3) * constants::pi * 4.0 / 3.0 * 1000);
frontWall = wallHandler.copyAndAddObject(InfiniteWall());
frontWall->set(Vec3D(-1, 0, 0), Vec3D(getXMin(), 0, 0));
backWall = wallHandler.copyAndAddObject(InfiniteWall());
backWall->set(Vec3D(1, 0, 0), Vec3D(getXMax(), 0, 0));
bottomWall = wallHandler.copyAndAddObject(InfiniteWall());
bottomWall->set(Vec3D(0, -1, 0), Vec3D(0, getYMin(), 0));
topWall = wallHandler.copyAndAddObject(InfiniteWall());
topWall->set(Vec3D(0, 1, 0), Vec3D(0, getYMax(), 0));
leftWall = wallHandler.copyAndAddObject(InfiniteWall());
leftWall->set(Vec3D(0, 0, -1), Vec3D(0, 0, getZMin()));
rightWall = wallHandler.copyAndAddObject(InfiniteWallWithHole());
rightWall->set(Vec3D(0, 0, 1), getZMax(), 1.0);
// creation of the coil and setting of its properties
coil = wallHandler.copyAndAddObject(Coil());
// 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(species);
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).
int Nx = static_cast<int> (std::floor((getXMax() - getXMin()) / (2.1 * particleRadius)));
int Ny = static_cast<int> (std::floor((getYMax() - getYMin()) / (2.1 * particleRadius)));
int Nz = static_cast<int> (std::floor((getZMax() - getZMin()) / (2.1 * particleRadius)));
Mdouble distance;
Vec3D normal;
// Place particles
for (int i = 0; i < Nx; i++)
for (int j = 0; j < Ny; j++)
for (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)) {
particleHandler.copyAndAddObject(p0);
} else {
//std::cout<<p0.getPosition()<<std::endl;
}
}
}
if (getTime() > 1)
coil->move_time(getTimeStep());
}
public:
double particleRadius;
Coil* coil;
InfiniteWall* frontWall;
InfiniteWall* backWall;
InfiniteWall* topWall;
InfiniteWall* bottomWall;
InfiniteWall* leftWall;
};
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(2.0);
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

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