MercuryDPM  Trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
BidisperseCubeInsertionBoundary.cc
Go to the documentation of this file.
1 //Copyright (c) 2013-2020, 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 
27 
29 {
30  particleToCopyA_ = nullptr;
31  particleToCopyB_ = nullptr;
32  probA_ = 0;
33 }
34 
36 {
39  probA_ = other.probA_;
40 }
41 
47 {
48  delete particleToCopyA_;
49  delete particleToCopyB_;
50 }
51 
57 {
58 #ifdef DEBUG_CONSTRUCTOR
59  std::cout << "BidisperseCubeInsertionBoundary::copy() const finished" << std::endl;
60 #endif
61  return new BidisperseCubeInsertionBoundary(*this);
62 }
63 
64 
65 void BidisperseCubeInsertionBoundary::set(BaseParticle* particleToCopyA, BaseParticle* particleToCopyB, double probA,
66  int maxFailed, Vec3D posMin, Vec3D posMax, Vec3D velMin, Vec3D velMax)
67 {
68  particleToCopyA_ = particleToCopyA;
69  particleToCopyB_ = particleToCopyB;
70  probA_ = probA;
71  CubeInsertionBoundary::set(particleToCopyA, maxFailed,
72  posMin, posMax, velMin, velMax, 0, 0);
73 }
74 
76 {
77  return particleToCopyA_;
78 }
79 
81 {
82  return particleToCopyB_;
83 }
84 
89 {
90  double check = random.getRandomNumber(0, 1);
91  BaseParticle* P = (check < probA_) ? particleToCopyA_->copy()
93  Vec3D pos, vel;
94  pos.X = random.getRandomNumber(posMin_.X, posMax_.X);
95  pos.Y = random.getRandomNumber(posMin_.Y, posMax_.Y);
96  pos.Z = random.getRandomNumber(posMin_.Z, posMax_.Z);
97  vel.X = random.getRandomNumber(velMin_.X, velMax_.X);
98  vel.Y = random.getRandomNumber(velMin_.Y, velMax_.Y);
99  vel.Z = random.getRandomNumber(velMin_.Z, velMax_.Z);
100  P->setPosition(pos);
101  P->setVelocity(vel);
102  return P;
103 }
104 
110 {
112  std::string dummy;
113  is >> dummy >> probA_;
114 }
115 
120 void BidisperseCubeInsertionBoundary::write(std::ostream& os) const
121 {
123  os << " probA " << probA_;
124 }
125 
131 {
132  return "BidisperseCubeInsertionBoundary";
133 }
134 
Mdouble X
the vector components
Definition: Vector.h:65
Vec3D posMin_
Minimal and maximal positions defining the boundary's boundaries, and minimum and maximum velocity of...
void setVelocity(const Vec3D &velocity)
set the velocity of the BaseInteractable.
BidisperseCubeInsertionBoundary * copy() const override
Creates a copy on the heap and returns a pointer.
BaseParticle * getParticleToCopyA() const
Get the particles that need to be copied.
void check(double real, double ideal, double error, std::string errorMessage)
Definition: Helpers.cc:898
Mdouble getRandomNumber()
This is a random generating routine can be used for initial positions.
Definition: RNG.cc:143
std::string getName() const override
Returns the name of the object.
virtual BaseParticle * copy() const =0
Particle copy method. It calls to copy constructor of this Particle, useful for polymorfism.
BaseParticle * generateParticle(RNG &random) override
Generates a particle with random position, radius and velocity.
~BidisperseCubeInsertionBoundary() override
Destructor: default destructor.
Like a CubeInsertionBoundary but the particles generated are one of two types.
This is a class that generates random numbers i.e. named the Random Number Generator (RNG)...
Definition: RNG.h:52
void set(BaseParticle *particleToCopy, unsigned int maxFailed, Vec3D posMin, Vec3D posMax, Vec3D velMin, Vec3D velMax, double radMin, double radMax)
Sets the properties of the CubeInsertionBoundary.
void write(std::ostream &os) const override
writes boundary properties to ostream
Mdouble Y
Definition: Vector.h:65
void setPosition(const Vec3D &position)
Sets the position of this BaseInteractable.
void read(std::istream &is) override
reads boundary properties from istream
BidisperseCubeInsertionBoundary()
Constructor; sets everything to 0.
void read(std::istream &is) override
reads boundary properties from istream
Definition: Vector.h:49
Mdouble Z
Definition: Vector.h:65
void write(std::ostream &os) const override
writes boundary properties to ostream
void set(BaseParticle *particleToCopyA, BaseParticle *particleToCopyB, double probA, int maxFailed, Vec3D posMin, Vec3D posMax, Vec3D velMin, Vec3D velMax)
Sets the properties of this bidisperse cuboidal insertion boundary.