MercuryDPM  Trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FixedClusterInsertionBoundary.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 
32 {
33  logger(DEBUG, "RandomClusterInsertionBoundary::RandomClusterInsertionBoundary() finished");
34 }
35 
41 
42  logger(DEBUG, "RandomClusterInsertionBoundary::RandomClusterInsertionBoundary() finished");
43 }
44 
49 = default;
50 
56 {
57 #ifdef DEBUG_CONSTRUCTOR
58  std::cout << "BaseClusterInsertionBoundary::copy() const finished" << std::endl;
59 #endif
60  return new FixedClusterInsertionBoundary(*this);
61 }
62 
74  std::vector<Vec3D> positions, std::vector<Mdouble> radii,
75  Vec3D velMin, Vec3D velMax, Mdouble rMicroParticle)
76 {
77  setParticleToCopy(particleToCopy);
78 
79  setPositionsAndRadii(positions, radii);
80  setVelocityRange(velMin, velMax);
81 
82  setRadiusMicroParticle(rMicroParticle);
83 }
84 
86 void FixedClusterInsertionBoundary::setPositionsAndRadii(std::vector<Vec3D> clusterPositions, std::vector<Mdouble> clusterRadii)
87 {
88  if (clusterPositions.size() != clusterRadii.size())
89  logger(ERROR, "clusterPositions and clusterRadii have different size."
90  " clusterPositions.size() = %, clusterRadii.size() = %.",
91  clusterPositions.size(), clusterRadii.size());
92  else if (clusterPositions.empty())
93  logger(ERROR, "clusterPositions is empty."
94  " clusterPositions.size() = %.", clusterPositions.size() );
95  else if (clusterRadii.empty())
96  logger(ERROR, "clusterRadii is empty."
97  " clusterRadii.size() = %.", clusterRadii.size());
98  else
99  {
100  clusterPositions_ = clusterPositions;
101  clusterRadii_ = clusterRadii;
102  }
103 }
104 
108 {
109  logger(VERBOSE, "In FixedClusterInsertionBoundary::checkBoundaryBeforeTimeStep\n");
110 
111  if (!isActivated_)
112  return;
113 
114  /* Each time step, the InsertionBoundary attempts to fill up a region with
115  * clusters.
116  *
117  * It first calls generateParticle() to get a randomised particle, subject
118  * to a specified distribution over sizes and species. (The basic class
119  * supports size dispersity only but PolydisperseInsertionBoundary will
120  * support species dispersity.)
121  * Then it repeatedly calls placeParticle(), which gives the cluster a
122  * random location (and possibly velocity) in a specified,
123  * geometry-dependent bound. Each time, it checks whether the new cluster
124  * would have an interaction with another cluster or a wall.
125  *
126  * If it manages to do that within maxFailed_ tries, then:
127  * * the new cluster is created and inserted,
128  * * the failure counter is reset, and
129  * the processes is repeated with a new generateParticle().
130  *
131  * Otherwise, the processes terminates for this time step.
132  * */
133 
134  for (std::vector<Mdouble>::const_iterator i = clusterRadii_.begin(); i != clusterRadii_.end(); ++i) {
135 
136 
137  auto p0 = generateParticle(md->random);
138 
139  placeParticle(p0, md->random);
140 
141 
142  BaseCluster cluster;
143  if(getRandomised())
144  cluster.random.randomise();
150  cluster.doCdatOutput(isCdatOutputOn_);
152  cluster.doAmatOutput(isAmatOutputOn_);
154  cluster.doVtkOutput(isVtkOutputOn_);
157  cluster.doEneOutput(isEneOutputOn_);
159  //Here, differently from RandomClusterInsertionBoundary the only possibility is to set radiusCluster and
160  // radiusParticle.
163  cluster.setRadiusCluster(p0->getRadius());
164  cluster.setPosition(p0->getPosition());
165  cluster.setVelocity(p0->getVelocity());
166  cluster.setParticleSpecies(
167  dynamic_cast<LinearPlasticViscoelasticFrictionSpecies*>(
168  md->speciesHandler.getObject(p0->getIndSpecies())));
169  cluster.solve();
170 
171  md->importParticlesAs( cluster.particleHandler, cluster.interactionHandler, p0->getSpecies() );
172 
173  // Number of cluster inserted
175  // Total number of particles inserted
177  // This is the total mass composed by every single particle (not cluster!) inserted
179  // This is the total volume composed by every single particle (not cluster!) inserted
181  logger(VERBOSE, "Successfully inserted cluster %/%.", nClusterInserted_, clusterRadii_.size());
182 
183  delete p0;
184  }
185 
186 }
187 
190 {
191  if(getRandomised())
192  random.randomise();
193  Vec3D pos, vel;
195  vel.X = random.getRandomNumber(velMin_.X, velMax_.X);
196  vel.Y = random.getRandomNumber(velMin_.Y, velMax_.Y);
197  vel.Z = random.getRandomNumber(velMin_.Z, velMax_.Z);
198  p->setPosition(pos);
199  p->setVelocity(vel);
200 }
201 
204 {
207  return P;
208 }
209 
215 {
216  return "FixedClusterInsertionBoundary";
217 }
Mdouble getVolume() const
void setCollisionTimeOverTimeStep(Mdouble cTOTS)
This sets the collisionTimeOverTimeStep number (which is the ratio between collision time and time st...
Definition: BaseCluster.cc:76
void solve()
The work horse of the code.
Definition: DPMBase.cc:3968
The DPMBase header includes quite a few header files, defining all the handlers, which are essential...
Definition: DPMBase.h:72
Mdouble X
the vector components
Definition: Vector.h:65
void setVelocity(const Vec3D &velocity)
set the velocity of the BaseInteractable.
unsigned int getSize() const
Gets the size of the particleHandler (including mpi and periodic particles)
Definition: BaseHandler.h:655
void setNumberOfInternalStructurePoints(int gL)
This sets the value of the number of particles used to compute the internal structure.
Definition: BaseCluster.cc:217
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
double Mdouble
Definition: GeneralDefine.h:34
virtual void setRadius(Mdouble radius)
Sets the particle's radius_ (and adjusts the mass_ accordingly, based on the particle's species) ...
void doOverlOutput(bool iOOO)
This sets the bool variable that defines whether the cluster overlap output will be written or not...
Definition: BaseCluster.cc:292
void placeParticle(BaseParticle *p, RNG &random) final
Places particles according to vector clusterPositions_ and sets a random velocity, if required.
void doIntStrucOutput(bool iISOO)
This sets the bool variable that defines whether the cluster internal structure output will be writte...
Definition: BaseCluster.cc:320
void doAmatOutput(bool iAOO)
This sets the bool variable that defines whether the cluster adjacency matrix output will be written ...
Definition: BaseCluster.cc:306
FixedClusterInsertionBoundary()
Constructor: inherits from BaseClusterInsertionBoundary constructor.
void doEneOutput(bool isEneOutputOn)
This sets the bool variable that defines whether the cluster ene output will be written or not...
Definition: BaseCluster.cc:376
void setPositionsAndRadii(std::vector< Vec3D > clusterPositions, std::vector< Mdouble > clusterRadii)
this sets positions and radii of the desired clusters.
const std::complex< Mdouble > i
Definition: ExtendedMath.h:50
void checkBoundaryBeforeTimeStep(DPMBase *md) final
inserts cluster: differently from RandomClusterInsertionBoundary, here no check for interaction is co...
void setSizeDispersityParticle(Mdouble sDP)
This sets the value of particles' dispersity in size.
Definition: BaseCluster.cc:117
Mdouble getRandomNumber()
This is a random generating routine can be used for initial positions.
Definition: RNG.cc:143
bool getRandomised()
this returns a bool which indicates if the process is randomised (true) or not (false).
Mdouble getMass() const
virtual BaseParticle * copy() const =0
Particle copy method. It calls to copy constructor of this Particle, useful for polymorfism.
void doCdatOutput(bool iCOO)
This sets the bool variable that defines whether the cluster data output will be written or not...
Definition: BaseCluster.cc:278
void randomise()
sets the random variables such that they differ for each run
Definition: RNG.cc:98
void setParticleToCopy(BaseParticle *particleToCopy)
Sets the particle that will be inserted through the insertion boundary.
void setVelocity(Vec3D v)
This sets the value of velocity after creation.
Definition: BaseCluster.cc:264
This is a class that generates random numbers i.e. named the Random Number Generator (RNG)...
Definition: RNG.h:52
void setRadiusMicroParticle(Mdouble rMP)
this sets the radius of the micro particle composing the cluster.
void set(BaseParticle *particleToCopy, std::vector< Vec3D > positions, std::vector< Mdouble > radii, Vec3D velMin, Vec3D velMax, Mdouble rMicroParticle)
Sets the properties of the ClusterInsertionBoundary.
unsigned getNextGroupId()
Should be called each time you assign a groupId. Returns the value of nextGroupId_ and increases next...
Definition: BaseHandler.h:293
Mdouble volumeInserted_
Total volume of particles inserted.
void setVelocityDampingModulus(Mdouble vDM)
This sets the value of the velocity damping modulus.
Definition: BaseCluster.cc:200
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1329
T * getObject(const unsigned int id)
Gets a pointer to the Object at the specified index in the BaseHandler.
Definition: BaseHandler.h:613
void doVtkOutput(bool iVOO)
This sets the bool variable that defines whether the cluster vtk output will be written or not...
Definition: BaseCluster.cc:334
BaseParticle * getParticleToCopy() const
Gets the particle that will be inserted through the insertion boundary.
void doFStatOutput(bool isfStatOutputOn)
This sets the bool variable that defines whether the cluster fStat output will be written or not...
Definition: BaseCluster.cc:362
void setVelocityRange(Vec3D velMin, Vec3D velMax)
Sets the velocity range of the ClusterInsertionBoundary.
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. LinearViscoelasticSpecies, etc.
Definition: DPMBase.h:1319
InteractionHandler interactionHandler
An object of the class InteractionHandler.
Definition: DPMBase.h:1359
Mdouble Y
Definition: Vector.h:65
RNG random
This is a random generator, often used for setting up the initial conditions etc...
Definition: DPMBase.h:1324
void setPosition(const Vec3D &position)
Sets the position of this BaseInteractable.
BaseParticle * generateParticle(RNG &random) final
Sets cluster radii according to vector clusterRadii_.
~FixedClusterInsertionBoundary() override
Destructor: default destructor.
void setParticleSpecies(LinearPlasticViscoelasticFrictionSpecies *particleSpecies)
This sets the species of the particle.
Definition: BaseCluster.cc:250
void importParticlesAs(ParticleHandler &particleHandler, InteractionHandler &interactionHandler, const ParticleSpecies *species)
Copies particles, interactions assigning species from a local simulation to a global one...
Definition: DPMBase.cc:4737
void setEnergyRatioTolerance(Mdouble eRT)
This sets the value of the value of the energy ratio threshold under which the process can be conside...
Definition: BaseCluster.cc:234
void doRestartOutput(bool isRestartOutputOn)
This sets the bool variable that defines whether the cluster restart output will be written or not...
Definition: BaseCluster.cc:348
unsigned int numberOfParticlesInserted_
Number of particles that are already inserted.
std::string getName() const override
Returns the name of the object.
Definition: Vector.h:49
void setRadiusParticle(Mdouble rP)
This sets the value of particles' radius if there's no dispersity in size.
Definition: BaseCluster.cc:97
FixedClusterInsertionBoundary * copy() const override
Creates a copy on the heap and returns a pointer.
Mdouble Z
Definition: Vector.h:65
Mdouble massInserted_
Total mass of particles inserted.
void setPosition(Vec3D p)
This sets the value of position_, which is the position in which the cluster will be inserted...
Definition: BaseCluster.cc:60
void setClusterId(unsigned int iC)
This sets the value of the cluster ID.
Definition: BaseCluster.cc:183
void setRadiusCluster(Mdouble rCR)
This sets the desired value of the cluster radius (there is no getter of this value, but there is a getter of the actual mean cluster radius obtained, getMeanClusterRadius)
Definition: BaseCluster.cc:149
bool isActivated_
The InsertionBoundary is activated by default. If the InsertionBoundary is deactivated, then it introduces no particles (useful for trying to maintain a certain insertion rate).