BaseCluster.h
Go to the documentation of this file.
1 // This file is part of the MercuryDPM project (https://www.mercurydpm.org).
2 // Copyright (c), The MercuryDPM Developers Team. All rights reserved.
3 // License: BSD 3-Clause License; see the LICENSE file in the root directory.
4 
5 #ifndef BaseCluster_H
6 #define BaseCluster_H
7 
8 #endif //BaseCluster_H
9 
10 #include <Mercury3D.h>
12 
13 
14 #ifdef MERCURYDPM_USE_MPI
15 #include <mpi.h>
16 #include <MpiDataClass.h>
17 #include <MpiContainer.h>
18 #endif
19 
27 #ifndef BaseCluster_h
28 #define BaseCluster_h
29 class BaseCluster : public Mercury3D
30 {
31 public:
32 
33 /*
34  * ----------------------------------------------------------------------
35  * FUNCTIONS: setters and getters
36  * ----------------------------------------------------------------------
37  */
38 
42  BaseCluster();
43 
47  ~BaseCluster() final;
48 
52  Vec3D getPosition() const;
53 
57  void setPosition(Vec3D p);
58 
63 
68 
74  Mdouble getRadiusParticle() const;
75 
79  void setRadiusParticle(Mdouble rP);
80 
85 
90 
94  int getNumberOfParticles() const;
95 
99  void setNumberOfParticles(int nP);
100 
105  void setRadiusCluster(Mdouble rCR);
106 
111 
115  unsigned int getClusterId() const;
116 
120  void setClusterId(unsigned int iC);
121 
126 
131 
136 
141 
147 
153 
158 
163 
168  Vec3D getVelocity();
169 
174  void setVelocity(Vec3D v);
175 
180  bool isCdatOutputOn() const;
181 
185  void doCdatOutput(bool iCOO);
186 
190  bool isOverlOutputOn() const;
191 
195  void doOverlOutput(bool iOOO);
196 
200  bool isAmatOutputOn() const;
201 
206  void doAmatOutput(bool iAOO);
207 
211  bool isIntStrucOutputOn() const;
212 
217  void doIntStrucOutput(bool iISOO);
218 
222  bool isVtkOutputOn() const;
223 
227  void doVtkOutput(bool iVOO);
228 
232  bool isRestartOutputOn() const;
233 
238 
242  bool isFStatOutputOn() const;
243 
247  void doFStatOutput(bool isfStatOutputOn);
248 
252  bool isEneOutputOn() const;
253 
257  void doEneOutput(bool isEneOutputOn);
258 
263 
268 
269 /*
270  * ----------------------------------------------------------------------
271  * FUNCTIONS: overridden mercury3D functions
272  * ----------------------------------------------------------------------
273  */
274 
275 
279  void setupInitialConditions() override;
280 
285  void actionsAfterTimeStep() override;
286 
291  void actionsAfterSolve() override;
292 
296  void write(std::ostream& os, bool writeAllParticles) const override;
297 
301  void read(std::istream& is, ReadOptions opt = ReadOptions::ReadAll) override;
302 
307  void actionsOnRestart() override;
308 
312  void printTime() const override;
313 
314 private:
315  /*
316  * ----------------------------------------------------------------------
317  * FUNCTIONS: functions inside setupInitialConditions
318  * ----------------------------------------------------------------------
319  */
320 
324  void setRadii();
325 
329  void setSpecies();
330 
334  void setDomainLimits();
335 
339  void calculateTimeStep();
340 
344  void insertParticles();
345 
349  void makeCdatFile();
350 
354  void makeOverlFile();
355 
360  bool particleInsertionSuccessful(int n);
361 
362 
363 
364  /*
365  * ----------------------------------------------------------------------
366  * FUNCTIONS: functions inside actionsAfterTimeStep
367  * ----------------------------------------------------------------------
368  */
369 
373  void makeDataAnalysis();
374 
378  void writeToCdatFile();
379 
383  void writeToOverlFile();
384 
388  void applyCentralForce();
389 
393  void increaseForce();
394 
398  void dampVelocities();
399 
403  void decreaseForce();
404 
408  void dampForce();
409 
413  void createAdjacencyMatrix();
414 
418  void makeAmatFile();
419 
423  void writeAmatFile();
424 
429 
433  void makeGnuplotFile();
434 
439 
440 
441 
442  /*
443  * ----------------------------------------------------------------------
444  * VARIABLES: accessed by the user with setters and getters
445  * ----------------------------------------------------------------------
446  */
447 
448  //POSITION
449  //\brief Position where the cluster is inserted after creation.
451 
452  // TIME
453  //\brief Ratio between collision time and time step: should be at least 50.
455  // \brief Energy ratio threshold under wich the simulation can be considered static and so can be stopped.
457 
458  // PARTiCleS
459  //\brief Radius basing on which all radii will be computed.
461  // \brief Bool that saves whether or not the user has set the radius of the single particle composing the cluster.
462  bool setRadiusParticle_ = false;
463  //\brief Size dispersity of particles: must be between >= than 1.
465  //\brief Total number of particles.
467  // \brief Bool that saves whether or not the user has set the number of particles
468  bool setNumberOfParticles_ = false;
469 
470  // CLUSTER
471  //\brief Total number of particles.
472  unsigned int idCluster_;
473  //\brief Desired radius of the cluster.
475  // \brief Bool that saves whether or not the user has set the cluster radius
476  bool setRadiusCluster_ = false;
477  //\brief Velocity of the cluster after creation
479  //\brief mean cluster radius after creation.
481 
482  // CENTRAL FORCE
483  //\brief Value of damping modulus for velocity.
485 
486  // DATA ANALYSIS
487  // \brief Number of points used for computing internal structure.
489 
490  // SPECIES
491  //\brief particle species.
493 
494 
495  // File
496  //\brief bool used to define whether or not cluster data output must be created.
498  //\brief bool used to define whether or not overlap data output must be created.
500  //\brief bool used to define whether or not adjacency matrix output must be created.
502  //\brief bool used to define whether or not cluster internal structure output must be created.
504  //\brief bool used to define whether or not vtk output must be created.
506  //\brief bool used to define whether or not vtk output must be created.
508  //\brief bool used to define whether or not vtk output must be created.
510  //\brief bool used to define whether or not vtk output must be created.
512 
513 
514  /*
515  * ----------------------------------------------------------------------
516  * VARIABLES: never accessed by the user
517  * ----------------------------------------------------------------------
518  */
519 
520 
521  // PARTICLES
522  //\brief vector in which all radii will be stored after calculation.
523  std::vector<Mdouble> radii_;
524  //smallest radius
526  //\brief mass of the particle which has radius radiusParticle.
528  //\brief total volume of all particles.
530 
531  // GEOMETRY
532  //\brief size of the cubic domain.
534  //\brief center of mass.
536 
537  // CONTACT RELATED
538  //\brief adjacency matrix.
539  std::vector< std::vector<int> > adjacencyMatrix_;
540  //\brief mean coordination number.
542  //\brief maximum relative overlap.
544  //\brief mean relative overlap.
546  //\brief minimum relative overlap.
548  //\brief number of total intra-cluster bonds.
550 
551  // OUTPUT
552  //\brief cluster data file.
553  std::ofstream cdatFile_;
554  //\brief cluster overlap file.
555  std::ofstream overlFile_;
556  //\brief gnuplot file.
557  std::ofstream gnuplotFile_;
558  //\brief adjacency matrix file.
559  std::ofstream amatFile_;
560  //\brief internal structure file.
561  std::ofstream intStructFile_;
562  //\brief output time of files and print time.
564 
565  // DATA ANALYSIS
566  //\brief radius with which solid fraction is computed
568  //\brief solid fraction computed with the total particle volume and radiusForSolidFraction_.
570  //\brief solid fraction computed with internal structure analysis.
572 
573  // TIME
574  // stage of the simulation: 1 compression, 2 decompression, 3 relaxation, 4 simulation ended.
575  int stage_;
576  //\brief time flag used for the stages duration.
578  //\brief final time.
580 
581  // CENTRAL FORCE
582  //\brief maximum force modulus applied on particles (this value is then multiplied by distance from force center).
584  //\brief force modulus applied on particles at a certain simulation time.
586  //\brief time interval on which force is tuned (increased or decreased).
588  //\brief time interval on which velocity is tuned (increased or decreased).
590  //\brief time duration of force tuning (i.e. duration of compression and decompression stages).
592  //\brief maximum possible time duration of dissipation (i.e. duration of dissipation if energy ratio
593  // tollerance not reached).
595  //\brief Value of damping modulus for forceFactor.
597 
598 };
599 #endif
Array< int, Dynamic, 1 > v
Definition: Array_initializer_list_vector_cxx11.cpp:1
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
float * p
Definition: Tutorial_Map_using.cpp:9
Definition: BaseCluster.h:30
Mdouble getRadiusParticle() const
This returns the value of particles' radius if there's no dispersity in size. In case of dispersity !...
Definition: BaseCluster.cc:67
bool isCdatOutputOn_
Definition: BaseCluster.h:497
void makeCdatFile()
Creates the cluster data output file.
Definition: BaseCluster.cc:1116
void setRadiusParticle(Mdouble rP)
This sets the value of particles' radius if there's no dispersity in size.
Definition: BaseCluster.cc:76
Mdouble meanRelativeOverlap_
Definition: BaseCluster.h:545
bool setRadiusCluster_
Definition: BaseCluster.h:476
void doFStatOutput(bool isfStatOutputOn)
This sets the bool variable that defines whether the cluster fStat output will be written or not.
Definition: BaseCluster.cc:341
std::vector< std::vector< int > > adjacencyMatrix_
Definition: BaseCluster.h:539
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:213
std::ofstream overlFile_
Definition: BaseCluster.h:555
bool isRestartOutputOn_
Definition: BaseCluster.h:507
void doRestartOutput(bool isRestartOutputOn)
This sets the bool variable that defines whether the cluster restart output will be written or not.
Definition: BaseCluster.cc:327
int nInternalStructurePoints_
Definition: BaseCluster.h:488
bool isFStatOutputOn_
Definition: BaseCluster.h:509
Mdouble energyRatioTolerance_
Definition: BaseCluster.h:456
void doEneOutput(bool isEneOutputOn)
This sets the bool variable that defines whether the cluster ene output will be written or not.
Definition: BaseCluster.cc:355
void createAdjacencyMatrix()
This calculates the adjacency matrix of the cluster.
Definition: BaseCluster.cc:1519
void decreaseForce()
This linearly decreases values of forceModulus (stage = 2).
Definition: BaseCluster.cc:1501
bool isVtkOutputOn() const
This returns the bool variable that defines whether the cluster vtk output is written or not.
Definition: BaseCluster.cc:306
Mdouble massParticle_
Definition: BaseCluster.h:527
Mdouble minRelativeOverlap_
Definition: BaseCluster.h:547
void makeDataAnalysis()
This functions computes some important cluster information needed by the program.
Definition: BaseCluster.cc:1235
void setSpecies()
Sets species of particles.
Definition: BaseCluster.cc:982
void setParticleSpecies(LinearPlasticViscoelasticFrictionSpecies *particleSpecies)
This sets the species of the particle.
Definition: BaseCluster.cc:229
void setPosition(Vec3D p)
This sets the value of position_, which is the position in which the cluster will be inserted.
Definition: BaseCluster.cc:39
int nIntraClusterBonds_
Definition: BaseCluster.h:549
void applyCentralForce()
This applies force on each particle.
Definition: BaseCluster.cc:1460
unsigned int idCluster_
Definition: BaseCluster.h:472
Vec3D centerOfMass_
Definition: BaseCluster.h:535
bool isIntStrucOutputOn_
Definition: BaseCluster.h:503
void writeToCdatFile()
This writes on the cluster data output file.
Definition: BaseCluster.cc:1350
int getNumberOfParticles() const
This returns the value of the number of particles in the cluster.
Definition: BaseCluster.cc:105
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:771
Mdouble forceModulus_
Definition: BaseCluster.h:585
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:818
Mdouble forceTuningDuration_
Definition: BaseCluster.h:591
Mdouble forceTuningInterval_
Definition: BaseCluster.h:587
bool isOverlOutputOn_
Definition: BaseCluster.h:499
Mdouble getFinalMassFraction()
This gets the final value obtained for the mass fraction;.
Definition: BaseCluster.cc:144
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:205
void increaseForce()
This linearly increases the value of forceModulus (stage = 1).
Definition: BaseCluster.cc:1479
Mdouble t0_
Definition: BaseCluster.h:577
std::ofstream cdatFile_
Definition: BaseCluster.h:553
std::ofstream gnuplotFile_
Definition: BaseCluster.h:557
void actionsOnRestart() override
Overrides DPMBase actionsOnRestart(): in this all variables needed by the program for restarting are ...
Definition: BaseCluster.cc:864
void setRadiusCluster(Mdouble rCR)
This sets the desired value of the cluster radius (there is no getter of this value,...
Definition: BaseCluster.cc:128
Mdouble getAverageOverlap()
this returns the average overlap.
Definition: BaseCluster.cc:369
Mdouble meanCoordinationNumber_
Definition: BaseCluster.h:541
void doCdatOutput(bool iCOO)
This sets the bool variable that defines whether the cluster data output will be written or not.
Definition: BaseCluster.cc:257
void setVelocity(Vec3D v)
This sets the value of velocity after creation.
Definition: BaseCluster.cc:243
Mdouble sizeDispersityParticle_
Definition: BaseCluster.h:464
Mdouble solidFraction_
Definition: BaseCluster.h:569
void setNumberOfParticles(int nP)
This sets the value of the number of particles in the cluster.
Definition: BaseCluster.cc:113
void setupInitialConditions() override
Overrides DPMBase setupInitialConditions(): in this initial conditions for the problem are set.
Definition: BaseCluster.cc:404
bool setNumberOfParticles_
Definition: BaseCluster.h:468
bool setRadiusParticle_
Definition: BaseCluster.h:462
bool isEneOutputOn_
Definition: BaseCluster.h:511
LinearPlasticViscoelasticFrictionSpecies * getParticleSpecies() const
This returns the species of the particle.
Definition: BaseCluster.cc:222
bool isAmatOutputOn() const
This returns the bool variable that defines whether the cluster adjacency matrix output is written or...
Definition: BaseCluster.cc:278
void actionsAfterSolve() override
Overrides DPMBase actionsAfterSolve(): in this cluster data file and cluster overlap file are closed ...
Definition: BaseCluster.cc:713
void dampVelocities()
This damps values of each particle velocity (stage = 1, stage = 2, stage = 3).
Definition: BaseCluster.cc:1488
bool isFStatOutputOn() const
This returns the bool variable that defines whether the cluster fStat output is written or not.
Definition: BaseCluster.cc:334
void setRadii()
Sets all radii according to particleRadius and sizeDispersityParticle.
Definition: BaseCluster.cc:963
Mdouble clusterTimeMax_
Definition: BaseCluster.h:579
Mdouble boxSize_
Definition: BaseCluster.h:533
void setDomainLimits()
Sets domain limits.
Definition: BaseCluster.cc:1024
std::vector< Mdouble > radii_
Definition: BaseCluster.h:523
void setVelocityDampingModulus(Mdouble vDM)
This sets the value of the velocity damping modulus.
Definition: BaseCluster.cc:179
Mdouble maxRelativeOverlap_
Definition: BaseCluster.h:543
Vec3D getPosition() const
This returns the value of position_, which is the position in which the cluster will be inserted.
Definition: BaseCluster.cc:31
void makeOverlFile()
Creates the cluster overlap output file.
Definition: BaseCluster.cc:1159
Mdouble collisionTimeOverTimeStep_
Definition: BaseCluster.h:454
Mdouble getVelocityDampingModulus() const
This returns the value of the velocity damping modulus.
Definition: BaseCluster.cc:171
bool isAmatOutputOn_
Definition: BaseCluster.h:501
Mdouble radiusParticle_
Definition: BaseCluster.h:460
Mdouble solidFractionIntStruct_
Definition: BaseCluster.h:571
std::ofstream intStructFile_
Definition: BaseCluster.h:561
bool isIntStrucOutputOn() const
This returns the bool variable that defines whether the cluster internal structure output is written ...
Definition: BaseCluster.cc:292
void printTime() const override
Overrides DPMBase printTime(): this way variables of interest are shown.
Definition: BaseCluster.cc:924
bool isCdatOutputOn() const
This returns the bool variable that defines whether the cluster data output (which is NOT the mercury...
Definition: BaseCluster.cc:250
void doVtkOutput(bool iVOO)
This sets the bool variable that defines whether the cluster vtk output will be written or not.
Definition: BaseCluster.cc:313
Mdouble dissipationDuration_
Definition: BaseCluster.h:594
Mdouble getSizeDispersityParticle() const
This returns the value of particles' dispersity in size.
Definition: BaseCluster.cc:88
Mdouble totalParticleVolume_
Definition: BaseCluster.h:529
void writeAmatFile()
This writes on the adjacency matrix file.
Definition: BaseCluster.cc:1556
bool isEneOutputOn() const
This returns the bool variable that defines whether the cluster ene output is written or not.
Definition: BaseCluster.cc:348
Vec3D getVelocity()
This gets the value of velocity after creation.
Definition: BaseCluster.cc:236
void setSizeDispersityParticle(Mdouble sDP)
This sets the value of particles' dispersity in size.
Definition: BaseCluster.cc:96
bool isRestartOutputOn() const
This returns the bool variable that defines whether the cluster restart output is written or not.
Definition: BaseCluster.cc:320
Mdouble getMeanClusterRadius()
this returns meanClusterRadius (radius of an ideal perfectly spherical cluster, there's no setter).
Definition: BaseCluster.cc:362
Mdouble velocityDampingInterval_
Definition: BaseCluster.h:589
Mdouble smallestRadius_
Definition: BaseCluster.h:525
BaseCluster()
Default constructor.
Definition: BaseCluster.cc:10
void calculateTimeStep()
Calculates the time step.
Definition: BaseCluster.cc:1039
void actionsAfterTimeStep() override
Overrides DPMBase actionsAfterTimeStep(): in this compression and decompression are computed,...
Definition: BaseCluster.cc:601
Mdouble radiusCluster_
Definition: BaseCluster.h:474
LinearPlasticViscoelasticFrictionSpecies * particleSpecies_
Definition: BaseCluster.h:492
Vec3D clusterVelocity_
Definition: BaseCluster.h:478
int stage_
Definition: BaseCluster.h:575
unsigned int getClusterId() const
This returns the value of the cluster ID.
Definition: BaseCluster.cc:154
void writeToOverlFile()
This writes on the cluster overlap output file.
Definition: BaseCluster.cc:1417
void insertParticles()
Inserts particles inside the domain.
Definition: BaseCluster.cc:1057
Mdouble velocityDampingModulus_
Definition: BaseCluster.h:484
void doAmatOutput(bool iAOO)
This sets the bool variable that defines whether the cluster adjacency matrix output will be written ...
Definition: BaseCluster.cc:285
void setNumberOfInternalStructurePoints(int gL)
This sets the value of the number of particles used to compute the internal structure.
Definition: BaseCluster.cc:196
Mdouble meanClusterRadius_
Definition: BaseCluster.h:480
void makeIntenalStructureFile()
This creates the file needed for writing down datas from computeInternalStructure().
Definition: BaseCluster.cc:1699
~BaseCluster() final
Default destructor.
Definition: BaseCluster.cc:17
Mdouble fileOutputTimeInterval_
Definition: BaseCluster.h:563
void makeGnuplotFile()
This creates the gnuplot file needed for printing force vs overlaps values.
Definition: BaseCluster.cc:1668
std::ofstream amatFile_
Definition: BaseCluster.h:559
void setClusterId(unsigned int iC)
This sets the value of the cluster ID.
Definition: BaseCluster.cc:162
void computeInternalStructure()
This computes the internal structure of the cluster.
Definition: BaseCluster.cc:1582
Mdouble maximumForceModulus_
Definition: BaseCluster.h:583
bool particleInsertionSuccessful(int n)
This function tries to insert the n-th particle (returns true if it manage to do that)....
Definition: BaseCluster.cc:1178
void doIntStrucOutput(bool iISOO)
This sets the bool variable that defines whether the cluster internal structure output will be writte...
Definition: BaseCluster.cc:299
void makeAmatFile()
This creates the adjacency matrix file.
Definition: BaseCluster.cc:1542
bool isOverlOutputOn() const
This returns the bool variable that defines whether the cluster overlap output is written or not.
Definition: BaseCluster.cc:264
Mdouble getCollisionTimeOverTimeStep() const
This returns the value of the ratio between collision time and time step.
Definition: BaseCluster.cc:47
void setCollisionTimeOverTimeStep(Mdouble cTOTS)
This sets the collisionTimeOverTimeStep number (which is the ratio between collision time and time st...
Definition: BaseCluster.cc:55
Vec3D position_
Definition: BaseCluster.h:450
Mdouble forceDampingModulus_
Definition: BaseCluster.h:596
Mdouble radiusForSolidFraction_
Definition: BaseCluster.h:567
void doOverlOutput(bool iOOO)
This sets the bool variable that defines whether the cluster overlap output will be written or not.
Definition: BaseCluster.cc:271
int nParticles_
Definition: BaseCluster.h:466
bool isVtkOutputOn_
Definition: BaseCluster.h:505
void dampForce()
This damps values of forceModulus (stage = 3).
Definition: BaseCluster.cc:1509
int getNumberOfInternalStructurePoints() const
This returns the value of the number of particles used to compute internal structure.
Definition: BaseCluster.cc:188
ReadOptions
Definition: DPMBase.h:233
This adds on the hierarchical grid code for 3D problems.
Definition: Mercury3D.h:16
Contains material and contact force properties.
Definition: Species.h:14
Definition: Kernel/Math/Vector.h:30