MercuryDPM  Trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HopperInsertionBoundary.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 #include "Particles/BaseParticle.h"
28 #include "Math/RNG.h"
29 
35 {
36  yMin_ = 0.0;
37  yMax_ = 0.0;
38  chuteAngle_ = 0.0;
40  isHopperCentred__ = true;
41  hopperDim_ = 0;
42  hopperAngle_ = 0.0;
43  hopperLength_ = 0.0;
44  hopperExitLength_ = 0.0;
45  hopperHeight_ = 0.0;
46  lift_ = 0.0;
47  fillPercent_ = 0.0;
48 }
49 
54  : InsertionBoundary(other)
55 {
56  yMin_ = other.yMin_;
57  yMax_ = other.yMax_;
58  chuteAngle_ = other.chuteAngle_;
61  hopperDim_ = other.hopperDim_;
62  hopperAngle_ = other.hopperAngle_;
66  lift_ = other.lift_;
67  fillPercent_ = other.fillPercent_;
68 }
69 
75 {
76 #ifdef DEBUG_CONSTRUCTOR
77  std::cout << "HopperInsertionBoundary::copy() const finished" << std::endl;
78 #endif
79  return new HopperInsertionBoundary(*this);
80 }
81 
119 void HopperInsertionBoundary::set(BaseParticle* particleToCopy, unsigned int maxFailed, double yMin,
120  double yMax, double radMin, double radMax, double chuteAngle,
121  double fixedParticleRadius,
122  bool isHopperCentred_, int hopperDim, double hopperAngle, double hopperLength,
123  double hopperExitLength, double hopperHeight, double lift, double fillPercent)
124 {
125  setParticleToCopy(particleToCopy);
126  setMaxFailed(maxFailed);
127  yMin_ = yMin;
128  yMax_ = yMax;
129  radMin_ = radMin;
130  radMax_ = radMax;
131  chuteAngle_ = chuteAngle;
132  fixedParticleRadius_ = fixedParticleRadius;
133  isHopperCentred__ = isHopperCentred_;
134  hopperDim_ = hopperDim;
135  hopperAngle_ = hopperAngle;
136  hopperLength_ = hopperLength;
137  hopperExitLength_ = hopperExitLength;
138  hopperHeight_ = hopperHeight;
139  lift_ = lift;
140  fillPercent_ = fillPercent;
141 }
142 
177 {
178  //Define an orthogonal coordinate system this is useful in the hopper, see
179  //diagram in html documentation for details.
180  static Mdouble s = mathsFunc::sin(chuteAngle_);
181  static Mdouble c = mathsFunc::cos(chuteAngle_);
182  static Mdouble Hc = mathsFunc::cos(hopperAngle_);
183  static Mdouble Ht = mathsFunc::sin(hopperAngle_) / Hc; //tangent
184  static Vec3D AB = Vec3D(c, 0.0, s);
185  static Vec3D AC = Vec3D(-s, 0.0, c);
186  static Vec3D AD = Vec3D(0.0, 1.0, 0.0);
187 
188  //Point A is located in the centre of the hopper.
189  static Vec3D A = Vec3D(isHopperCentred__ ? 40 : 0.0,
190  (yMax_ - yMin_) / 2.0,
191  s * (-0.5 * (hopperLength_ - hopperExitLength_)) + c * hopperHeight_)
192  + AB * 0.5 * hopperLength_
193  + AC * (-0.5 * hopperLength_ / Ht);
194 
195  Mdouble gamma = random.getRandomNumber((100.0 - fillPercent_) / 100.0, 1.0);
196  //std::cout<<"gamma="<<gamma<<"fillPercent="<<fillPercent_<<std::endl;
197 
198  Mdouble delta;
199 
200  if (hopperDim_ == 1)
201  {
209  delta = random.getRandomNumber(-0.5, 0.5) * (yMax_ - yMin_ - 2.0 * p->getRadius());
215 
216  }
217  else
218  {
227  delta = (random.getRandomNumber(-1.0, 1.0) * (0.5 * gamma * hopperLength_ - p->getRadius() / Hc));
228  }
229  //std::cout<<A<<" "<<AC<<" "<<AB<<" "<<AD<<" "<<Hc<<" "<<Ht<<"gamma="<<gamma<<" "<<hopperLength_<<" "<<delta<<std::endl;
230  p->setPosition(A
231  + AC * (gamma * 0.5 * hopperLength_ / Ht)
232  + AB * (random.getRandomNumber(-1.0, 1.0) * (0.5 * gamma * hopperLength_ - p->getRadius() / Hc))
233  + AD * delta);
234 
235  p->move(Vec3D(0.0, 0.0, lift_));
236  p->setVelocity(Vec3D(0.0, 0.0, 0.0));
237 }
238 
243 void HopperInsertionBoundary::read(std::istream& is)
244 {
246  std::string dummy;
247  is >> dummy >> yMin_
248  >> dummy >> yMax_
249  >> dummy >> radMin_
250  >> dummy >> radMax_
251  >> dummy >> chuteAngle_
252  >> dummy >> fixedParticleRadius_
253  >> dummy >> isHopperCentred__
254  >> dummy >> hopperDim_
255  >> dummy >> hopperAngle_
256  >> dummy >> hopperLength_
257  >> dummy >> hopperExitLength_
258  >> dummy >> hopperHeight_
259  >> dummy >> lift_
260  >> dummy >> fillPercent_;
261 }
262 
267 void HopperInsertionBoundary::oldRead(std::istream& is)
268 {
269  int maxFailed;
270  std::string dummy;
271  is >> dummy >> maxFailed
272  >> dummy >> yMin_
273  >> dummy >> yMax_
274  >> dummy >> radMin_
275  >> dummy >> radMax_
276  >> dummy >> chuteAngle_
277  >> dummy >> fixedParticleRadius_
278  >> dummy >> isHopperCentred__
279  >> dummy >> hopperDim_
280  >> dummy >> hopperAngle_
281  >> dummy >> hopperLength_
282  >> dummy >> hopperExitLength_
283  >> dummy >> hopperHeight_
284  >> dummy >> lift_
285  >> dummy >> fillPercent_;
286  setMaxFailed(maxFailed);
287 }
288 
293 void HopperInsertionBoundary::write(std::ostream& os) const
294 {
296  os << " yMin " << yMin_
297  << " yMax " << yMax_
298  << " radMin " << radMin_
299  << " radMax " << radMax_
300  << " chuteAngle " << chuteAngle_
301  << " fixedParticleRadius " << fixedParticleRadius_
302  << " isHopperCentred_ " << isHopperCentred__
303  << " hopperDim " << hopperDim_
304  << " hopperAngle " << hopperAngle_
305  << " hopperLength " << hopperLength_
306  << " hopperExitLength " << hopperExitLength_
307  << " hopperHeight " << hopperHeight_
308  << " lift " << lift_
309  << " fillPercent " << fillPercent_;
310 }
311 
317 {
318  return "HopperInsertionBoundary";
319 }
320 
double hopperExitLength_
The horizontal (AB-direction) width at the square exit of the hopper.
void setVelocity(const Vec3D &velocity)
set the velocity of the BaseInteractable.
double Mdouble
Definition: GeneralDefine.h:34
MERCURY_DEPRECATED void oldRead(std::istream &is)
deprecated version of CubeInsertionBoundary::read().
double hopperHeight_
The vertical (AC-direction) height of the hopper, measured from the top of the hopper to the start of...
Mdouble radMin_
Minimum and maximum radii of the generated particles.
double hopperLength_
The horizontal (AB-direction) width at the top of the hopper.
void setMaxFailed(unsigned int maxFailed)
Sets the number of times that the wall may fail to insert a particle.
Mdouble getRandomNumber()
This is a random generating routine can be used for initial positions.
Definition: RNG.cc:143
int hopperDim_
Either 1 or 2. If 1, the insertion boundary has vertical walls in the y extrema. This is used e...
Boundary structure for boundaries used for insertion of particles.
Mdouble cos(Mdouble x)
Definition: ExtendedMath.cc:64
void setParticleToCopy(BaseParticle *particleToCopy)
Sets the particle that will be inserted through the insertion boundary.
std::string getName() const override
Returns the name of the object.
This is a class that generates random numbers i.e. named the Random Number Generator (RNG)...
Definition: RNG.h:52
HopperInsertionBoundary()
Default constructor. Sets all properties to 0.
Mdouble sin(Mdouble x)
Definition: ExtendedMath.cc:44
double hopperAngle_
Angle of the hopper as compared to the vertical plane.
void write(std::ostream &os) const override
writes boundary properties to ostream
void write(std::ostream &os) const override
Writes the boundary's id_ and maxFailed_.
void set(BaseParticle *particleToCopy, unsigned int maxFailed, double yMin, double yMax, double radMin, double radMax, double chuteAngle, double fixedParticleRadius, bool isHopperCentred_, int hopperDim, double hopperAngle, double hopperLength, double hopperExitLength, double hopperHeight, double lift, double fillPercent)
Sets all boundary properties at once.
Mdouble getRadius() const
Returns the particle's radius.
Definition: BaseParticle.h:345
double chuteAngle_
Angle of the chute as compared to the horizontal plane.
void setPosition(const Vec3D &position)
Sets the position of this BaseInteractable.
void read(std::istream &is) override
reads boundary properties from istream
Inherits from InsertionBoundary Some images are useful to better understand the structure of both the...
Mdouble gamma(Mdouble gamma_in)
This is the gamma function returns the true value for the half integer value.
Definition: Vector.h:49
virtual void move(const Vec3D &move)
Moves this BaseInteractable by adding an amount to the position.
void placeParticle(BaseParticle *p, RNG &random) override
This places an inflow particle in the top 50% of the hopper i.e. between gamma=0.5 and gamma=1...
double yMin_
The minimum and maximum y-positions of the particle for a hopper with vertical walls in the y-directi...
double fillPercent_
Percentage of the height of the insertion boundary up to which it should be filled. The part to be filled reaches from the top of the hopper down to {fillPercent * (top - 'position A')}.
HopperInsertionBoundary * copy() const override
copy method, returns a pointer to a copy.
void read(std::istream &is) override
Reads the boundary's id_ and maxFailed_.