BaseCluster.h
Go to the documentation of this file.
1 //Copyright (c) 2013-2023, 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 #ifndef BaseCluster_H
27 #define BaseCluster_H
28 
29 #endif //BaseCluster_H
30 
31 #include <Mercury3D.h>
33 
34 
35 #ifdef MERCURYDPM_USE_MPI
36 #include <mpi.h>
37 #include <MpiDataClass.h>
38 #include <MpiContainer.h>
39 #endif
40 
48 #ifndef BaseCluster_h
49 #define BaseCluster_h
50 class BaseCluster : public Mercury3D
51 {
52 public:
53 
54 /*
55  * ----------------------------------------------------------------------
56  * FUNCTIONS: setters and getters
57  * ----------------------------------------------------------------------
58  */
59 
63  BaseCluster();
64 
68  ~BaseCluster() final;
69 
73  Vec3D getPosition() const;
74 
78  void setPosition(Vec3D p);
79 
84 
89 
95  Mdouble getRadiusParticle() const;
96 
100  void setRadiusParticle(Mdouble rP);
101 
106 
111 
115  int getNumberOfParticles() const;
116 
120  void setNumberOfParticles(int nP);
121 
126  void setRadiusCluster(Mdouble rCR);
127 
132 
136  unsigned int getClusterId() const;
137 
141  void setClusterId(unsigned int iC);
142 
147 
152 
157 
162 
168 
174 
179 
184 
189  Vec3D getVelocity();
190 
195  void setVelocity(Vec3D v);
196 
201  bool isCdatOutputOn() const;
202 
206  void doCdatOutput(bool iCOO);
207 
211  bool isOverlOutputOn() const;
212 
216  void doOverlOutput(bool iOOO);
217 
221  bool isAmatOutputOn() const;
222 
227  void doAmatOutput(bool iAOO);
228 
232  bool isIntStrucOutputOn() const;
233 
238  void doIntStrucOutput(bool iISOO);
239 
243  bool isVtkOutputOn() const;
244 
248  void doVtkOutput(bool iVOO);
249 
253  bool isRestartOutputOn() const;
254 
259 
263  bool isFStatOutputOn() const;
264 
268  void doFStatOutput(bool isfStatOutputOn);
269 
273  bool isEneOutputOn() const;
274 
278  void doEneOutput(bool isEneOutputOn);
279 
284 
289 
290 /*
291  * ----------------------------------------------------------------------
292  * FUNCTIONS: overridden mercury3D functions
293  * ----------------------------------------------------------------------
294  */
295 
296 
300  void setupInitialConditions() override;
301 
306  void actionsAfterTimeStep() override;
307 
312  void actionsAfterSolve() override;
313 
317  void write(std::ostream& os, bool writeAllParticles) const override;
318 
322  void read(std::istream& is, ReadOptions opt = ReadOptions::ReadAll) override;
323 
328  void actionsOnRestart() override;
329 
333  void printTime() const override;
334 
335 private:
336  /*
337  * ----------------------------------------------------------------------
338  * FUNCTIONS: functions inside setupInitialConditions
339  * ----------------------------------------------------------------------
340  */
341 
345  void setRadii();
346 
350  void setSpecies();
351 
355  void setDomainLimits();
356 
360  void calculateTimeStep();
361 
365  void insertParticles();
366 
370  void makeCdatFile();
371 
375  void makeOverlFile();
376 
381  bool particleInsertionSuccessful(int n);
382 
383 
384 
385  /*
386  * ----------------------------------------------------------------------
387  * FUNCTIONS: functions inside actionsAfterTimeStep
388  * ----------------------------------------------------------------------
389  */
390 
394  void makeDataAnalysis();
395 
399  void writeToCdatFile();
400 
404  void writeToOverlFile();
405 
409  void applyCentralForce();
410 
414  void increaseForce();
415 
419  void dampVelocities();
420 
424  void decreaseForce();
425 
429  void dampForce();
430 
434  void createAdjacencyMatrix();
435 
439  void makeAmatFile();
440 
444  void writeAmatFile();
445 
450 
454  void makeGnuplotFile();
455 
460 
461 
462 
463  /*
464  * ----------------------------------------------------------------------
465  * VARIABLES: accessed by the user with setters and getters
466  * ----------------------------------------------------------------------
467  */
468 
469  //POSITION
470  //\brief Position where the cluster is inserted after creation.
472 
473  // TIME
474  //\brief Ratio between collision time and time step: should be at least 50.
476  // \brief Energy ratio threshold under wich the simulation can be considered static and so can be stopped.
478 
479  // PARTiCleS
480  //\brief Radius basing on which all radii will be computed.
482  // \brief Bool that saves whether or not the user has set the radius of the single particle composing the cluster.
483  bool setRadiusParticle_ = false;
484  //\brief Size dispersity of particles: must be between >= than 1.
486  //\brief Total number of particles.
488  // \brief Bool that saves whether or not the user has set the number of particles
489  bool setNumberOfParticles_ = false;
490 
491  // CLUSTER
492  //\brief Total number of particles.
493  unsigned int idCluster_;
494  //\brief Desired radius of the cluster.
496  // \brief Bool that saves whether or not the user has set the cluster radius
497  bool setRadiusCluster_ = false;
498  //\brief Velocity of the cluster after creation
500  //\brief mean cluster radius after creation.
502 
503  // CENTRAL FORCE
504  //\brief Value of damping modulus for velocity.
506 
507  // DATA ANALYSIS
508  // \brief Number of points used for computing internal structure.
510 
511  // SPECIES
512  //\brief particle species.
514 
515 
516  // File
517  //\brief bool used to define whether or not cluster data output must be created.
519  //\brief bool used to define whether or not overlap data output must be created.
521  //\brief bool used to define whether or not adjacency matrix output must be created.
523  //\brief bool used to define whether or not cluster internal structure output must be created.
525  //\brief bool used to define whether or not vtk output must be created.
527  //\brief bool used to define whether or not vtk output must be created.
529  //\brief bool used to define whether or not vtk output must be created.
531  //\brief bool used to define whether or not vtk output must be created.
533 
534 
535  /*
536  * ----------------------------------------------------------------------
537  * VARIABLES: never accessed by the user
538  * ----------------------------------------------------------------------
539  */
540 
541 
542  // PARTICLES
543  //\brief vector in which all radii will be stored after calculation.
544  std::vector<Mdouble> radii_;
545  //smallest radius
547  //\brief mass of the particle which has radius radiusParticle.
549  //\brief total volume of all particles.
551 
552  // GEOMETRY
553  //\brief size of the cubic domain.
555  //\brief center of mass.
557 
558  // CONTACT RELATED
559  //\brief adjacency matrix.
560  std::vector< std::vector<int> > adjacencyMatrix_;
561  //\brief mean coordination number.
563  //\brief maximum relative overlap.
565  //\brief mean relative overlap.
567  //\brief minimum relative overlap.
569  //\brief number of total intra-cluster bonds.
571 
572  // OUTPUT
573  //\brief cluster data file.
574  std::ofstream cdatFile_;
575  //\brief cluster overlap file.
576  std::ofstream overlFile_;
577  //\brief gnuplot file.
578  std::ofstream gnuplotFile_;
579  //\brief adjacency matrix file.
580  std::ofstream amatFile_;
581  //\brief internal structure file.
582  std::ofstream intStructFile_;
583  //\brief output time of files and print time.
585 
586  // DATA ANALYSIS
587  //\brief radius with which solid fraction is computed
589  //\brief solid fraction computed with the total particle volume and radiusForSolidFraction_.
591  //\brief solid fraction computed with internal structure analysis.
593 
594  // TIME
595  // stage of the simulation: 1 compression, 2 decompression, 3 relaxation, 4 simulation ended.
596  int stage_;
597  //\brief time flag used for the stages duration.
599  //\brief final time.
601 
602  // CENTRAL FORCE
603  //\brief maximum force modulus applied on particles (this value is then multiplied by distance from force center).
605  //\brief force modulus applied on particles at a certain simulation time.
607  //\brief time interval on which force is tuned (increased or decreased).
609  //\brief time interval on which velocity is tuned (increased or decreased).
611  //\brief time duration of force tuning (i.e. duration of compression and decompression stages).
613  //\brief maximum possible time duration of dissipation (i.e. duration of dissipation if energy ratio
614  // tollerance not reached).
616  //\brief Value of damping modulus for forceFactor.
618 
619 };
620 #endif
const unsigned n
Definition: CG3DPackingUnitTest.cpp:32
Definition: BaseCluster.h:51
Mdouble getRadiusParticle() const
This returns the value of particles' radius if there's no dispersity in size. In case of dispersity !...
Definition: BaseCluster.cc:88
bool isCdatOutputOn_
Definition: BaseCluster.h:518
void makeCdatFile()
Creates the cluster data output file.
Definition: BaseCluster.cc:1137
void setRadiusParticle(Mdouble rP)
This sets the value of particles' radius if there's no dispersity in size.
Definition: BaseCluster.cc:97
Mdouble meanRelativeOverlap_
Definition: BaseCluster.h:566
bool setRadiusCluster_
Definition: BaseCluster.h:497
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
std::vector< std::vector< int > > adjacencyMatrix_
Definition: BaseCluster.h:560
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
std::ofstream overlFile_
Definition: BaseCluster.h:576
bool isRestartOutputOn_
Definition: BaseCluster.h:528
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
int nInternalStructurePoints_
Definition: BaseCluster.h:509
bool isFStatOutputOn_
Definition: BaseCluster.h:530
Mdouble energyRatioTolerance_
Definition: BaseCluster.h:477
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 createAdjacencyMatrix()
This calculates the adjacency matrix of the cluster.
Definition: BaseCluster.cc:1540
void decreaseForce()
This linearly decreases values of forceModulus (stage = 2).
Definition: BaseCluster.cc:1522
bool isVtkOutputOn() const
This returns the bool variable that defines whether the cluster vtk output is written or not.
Definition: BaseCluster.cc:327
Mdouble massParticle_
Definition: BaseCluster.h:548
Mdouble minRelativeOverlap_
Definition: BaseCluster.h:568
void makeDataAnalysis()
This functions computes some important cluster information needed by the program.
Definition: BaseCluster.cc:1256
void setSpecies()
Sets species of particles.
Definition: BaseCluster.cc:1003
void setParticleSpecies(LinearPlasticViscoelasticFrictionSpecies *particleSpecies)
This sets the species of the particle.
Definition: BaseCluster.cc:250
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
int nIntraClusterBonds_
Definition: BaseCluster.h:570
void applyCentralForce()
This applies force on each particle.
Definition: BaseCluster.cc:1481
unsigned int idCluster_
Definition: BaseCluster.h:493
Vec3D centerOfMass_
Definition: BaseCluster.h:556
bool isIntStrucOutputOn_
Definition: BaseCluster.h:524
void writeToCdatFile()
This writes on the cluster data output file.
Definition: BaseCluster.cc:1371
int getNumberOfParticles() const
This returns the value of the number of particles in the cluster.
Definition: BaseCluster.cc:126
void write(std::ostream &os, bool writeAllParticles) const override
Overrides DPMBase write(): in this all variables needed by the program for restarting are written.
Definition: BaseCluster.cc:792
Mdouble forceModulus_
Definition: BaseCluster.h:606
void read(std::istream &is, ReadOptions opt=ReadOptions::ReadAll) override
Overrides DPMBase read(): in this all variables needed by the program for restarting are read.
Definition: BaseCluster.cc:839
Mdouble forceTuningDuration_
Definition: BaseCluster.h:612
Mdouble forceTuningInterval_
Definition: BaseCluster.h:608
bool isOverlOutputOn_
Definition: BaseCluster.h:520
Mdouble getFinalMassFraction()
This gets the final value obtained for the mass fraction;.
Definition: BaseCluster.cc:165
Mdouble getEnergyRatioTolerance() const
This returns the value of the value of the energy ratio threshold under which the process can be cons...
Definition: BaseCluster.cc:226
void increaseForce()
This linearly increases the value of forceModulus (stage = 1).
Definition: BaseCluster.cc:1500
Mdouble t0_
Definition: BaseCluster.h:598
std::ofstream cdatFile_
Definition: BaseCluster.h:574
std::ofstream gnuplotFile_
Definition: BaseCluster.h:578
void actionsOnRestart() override
Overrides DPMBase actionsOnRestart(): in this all variables needed by the program for restarting are ...
Definition: BaseCluster.cc:885
void setRadiusCluster(Mdouble rCR)
This sets the desired value of the cluster radius (there is no getter of this value,...
Definition: BaseCluster.cc:149
Mdouble getAverageOverlap()
this returns the average overlap.
Definition: BaseCluster.cc:390
Mdouble meanCoordinationNumber_
Definition: BaseCluster.h:562
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 setVelocity(Vec3D v)
This sets the value of velocity after creation.
Definition: BaseCluster.cc:264
Mdouble sizeDispersityParticle_
Definition: BaseCluster.h:485
Mdouble solidFraction_
Definition: BaseCluster.h:590
void setNumberOfParticles(int nP)
This sets the value of the number of particles in the cluster.
Definition: BaseCluster.cc:134
void setupInitialConditions() override
Overrides DPMBase setupInitialConditions(): in this initial conditions for the problem are set.
Definition: BaseCluster.cc:425
bool setNumberOfParticles_
Definition: BaseCluster.h:489
bool setRadiusParticle_
Definition: BaseCluster.h:483
bool isEneOutputOn_
Definition: BaseCluster.h:532
LinearPlasticViscoelasticFrictionSpecies * getParticleSpecies() const
This returns the species of the particle.
Definition: BaseCluster.cc:243
bool isAmatOutputOn() const
This returns the bool variable that defines whether the cluster adjacency matrix output is written or...
Definition: BaseCluster.cc:299
void actionsAfterSolve() override
Overrides DPMBase actionsAfterSolve(): in this cluster data file and cluster overlap file are closed ...
Definition: BaseCluster.cc:734
void dampVelocities()
This damps values of each particle velocity (stage = 1, stage = 2, stage = 3).
Definition: BaseCluster.cc:1509
bool isFStatOutputOn() const
This returns the bool variable that defines whether the cluster fStat output is written or not.
Definition: BaseCluster.cc:355
void setRadii()
Sets all radii according to particleRadius and sizeDispersityParticle.
Definition: BaseCluster.cc:984
Mdouble clusterTimeMax_
Definition: BaseCluster.h:600
Mdouble boxSize_
Definition: BaseCluster.h:554
void setDomainLimits()
Sets domain limits.
Definition: BaseCluster.cc:1045
std::vector< Mdouble > radii_
Definition: BaseCluster.h:544
void setVelocityDampingModulus(Mdouble vDM)
This sets the value of the velocity damping modulus.
Definition: BaseCluster.cc:200
Mdouble maxRelativeOverlap_
Definition: BaseCluster.h:564
Vec3D getPosition() const
This returns the value of position_, which is the position in which the cluster will be inserted.
Definition: BaseCluster.cc:52
void makeOverlFile()
Creates the cluster overlap output file.
Definition: BaseCluster.cc:1180
Mdouble collisionTimeOverTimeStep_
Definition: BaseCluster.h:475
Mdouble getVelocityDampingModulus() const
This returns the value of the velocity damping modulus.
Definition: BaseCluster.cc:192
bool isAmatOutputOn_
Definition: BaseCluster.h:522
Mdouble radiusParticle_
Definition: BaseCluster.h:481
Mdouble solidFractionIntStruct_
Definition: BaseCluster.h:592
std::ofstream intStructFile_
Definition: BaseCluster.h:582
bool isIntStrucOutputOn() const
This returns the bool variable that defines whether the cluster internal structure output is written ...
Definition: BaseCluster.cc:313
void printTime() const override
Overrides DPMBase printTime(): this way variables of interest are shown.
Definition: BaseCluster.cc:945
bool isCdatOutputOn() const
This returns the bool variable that defines whether the cluster data output (which is NOT the mercury...
Definition: BaseCluster.cc:271
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
Mdouble dissipationDuration_
Definition: BaseCluster.h:615
Mdouble getSizeDispersityParticle() const
This returns the value of particles' dispersity in size.
Definition: BaseCluster.cc:109
Mdouble totalParticleVolume_
Definition: BaseCluster.h:550
void writeAmatFile()
This writes on the adjacency matrix file.
Definition: BaseCluster.cc:1577
bool isEneOutputOn() const
This returns the bool variable that defines whether the cluster ene output is written or not.
Definition: BaseCluster.cc:369
Vec3D getVelocity()
This gets the value of velocity after creation.
Definition: BaseCluster.cc:257
void setSizeDispersityParticle(Mdouble sDP)
This sets the value of particles' dispersity in size.
Definition: BaseCluster.cc:117
bool isRestartOutputOn() const
This returns the bool variable that defines whether the cluster restart output is written or not.
Definition: BaseCluster.cc:341
Mdouble getMeanClusterRadius()
this returns meanClusterRadius (radius of an ideal perfectly spherical cluster, there's no setter).
Definition: BaseCluster.cc:383
Mdouble velocityDampingInterval_
Definition: BaseCluster.h:610
Mdouble smallestRadius_
Definition: BaseCluster.h:546
BaseCluster()
Default constructor.
Definition: BaseCluster.cc:31
void calculateTimeStep()
Calculates the time step.
Definition: BaseCluster.cc:1060
void actionsAfterTimeStep() override
Overrides DPMBase actionsAfterTimeStep(): in this compression and decompression are computed,...
Definition: BaseCluster.cc:622
Mdouble radiusCluster_
Definition: BaseCluster.h:495
LinearPlasticViscoelasticFrictionSpecies * particleSpecies_
Definition: BaseCluster.h:513
Vec3D clusterVelocity_
Definition: BaseCluster.h:499
int stage_
Definition: BaseCluster.h:596
unsigned int getClusterId() const
This returns the value of the cluster ID.
Definition: BaseCluster.cc:175
void writeToOverlFile()
This writes on the cluster overlap output file.
Definition: BaseCluster.cc:1438
void insertParticles()
Inserts particles inside the domain.
Definition: BaseCluster.cc:1078
Mdouble velocityDampingModulus_
Definition: BaseCluster.h:505
void doAmatOutput(bool iAOO)
This sets the bool variable that defines whether the cluster adjacency matrix output will be written ...
Definition: BaseCluster.cc:306
void setNumberOfInternalStructurePoints(int gL)
This sets the value of the number of particles used to compute the internal structure.
Definition: BaseCluster.cc:217
Mdouble meanClusterRadius_
Definition: BaseCluster.h:501
void makeIntenalStructureFile()
This creates the file needed for writing down datas from computeInternalStructure().
Definition: BaseCluster.cc:1720
~BaseCluster() final
Default destructor.
Definition: BaseCluster.cc:38
Mdouble fileOutputTimeInterval_
Definition: BaseCluster.h:584
void makeGnuplotFile()
This creates the gnuplot file needed for printing force vs overlaps values.
Definition: BaseCluster.cc:1689
std::ofstream amatFile_
Definition: BaseCluster.h:580
void setClusterId(unsigned int iC)
This sets the value of the cluster ID.
Definition: BaseCluster.cc:183
void computeInternalStructure()
This computes the internal structure of the cluster.
Definition: BaseCluster.cc:1603
Mdouble maximumForceModulus_
Definition: BaseCluster.h:604
bool particleInsertionSuccessful(int n)
This function tries to insert the n-th particle (returns true if it manage to do that)....
Definition: BaseCluster.cc:1199
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 makeAmatFile()
This creates the adjacency matrix file.
Definition: BaseCluster.cc:1563
bool isOverlOutputOn() const
This returns the bool variable that defines whether the cluster overlap output is written or not.
Definition: BaseCluster.cc:285
Mdouble getCollisionTimeOverTimeStep() const
This returns the value of the ratio between collision time and time step.
Definition: BaseCluster.cc:68
void setCollisionTimeOverTimeStep(Mdouble cTOTS)
This sets the collisionTimeOverTimeStep number (which is the ratio between collision time and time st...
Definition: BaseCluster.cc:76
Vec3D position_
Definition: BaseCluster.h:471
Mdouble forceDampingModulus_
Definition: BaseCluster.h:617
Mdouble radiusForSolidFraction_
Definition: BaseCluster.h:588
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
int nParticles_
Definition: BaseCluster.h:487
bool isVtkOutputOn_
Definition: BaseCluster.h:526
void dampForce()
This damps values of forceModulus (stage = 3).
Definition: BaseCluster.cc:1530
int getNumberOfInternalStructurePoints() const
This returns the value of the number of particles used to compute internal structure.
Definition: BaseCluster.cc:209
ReadOptions
Definition: DPMBase.h:254
This adds on the hierarchical grid code for 3D problems.
Definition: Mercury3D.h:37
Contains material and contact force properties.
Definition: Species.h:35
Definition: Vector.h:51