MercuryDPM  Trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DPMBase.h
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 
26 #ifndef DPMBase_H
27 #define DPMBase_H
28 
29 //so that the user doesn't have to include string/io manipulations:
30 #include <string>
31 #include <iomanip>
32 //The vector class contains a 3D vector class.
33 #include "Math/Vector.h"
34 //This class defines the particle handler
35 #include "ParticleHandler.h"
36 //This class defines the base particle (such that not every Driver has to include it)
37 #include "Particles/BaseParticle.h"
39 //This class defines the wall handler
40 #include "WallHandler.h"
41 //This class defines the boundary handler
42 #include "BoundaryHandler.h"
44 #include "DomainHandler.h"
45 //This class defines the interaction handler
46 #include "InteractionHandler.h"
47 //This class defines the Species handler
48 #include "SpeciesHandler.h"
49 //This class defines the cg handler
50 #include "CG/CGHandler.h"
51 //This class defines the possibleContact lists
52 #ifdef CONTACT_LIST_HGRID
53 #include "PossibleContactList.h"
54 #endif
55 //This class defines the random number generator
56 #include "Math/RNG.h"
57 #include "Domain.h"
62 
63 
72 class DPMBase
73 {
78 public:
79 
85  void constructor();
86 
90  DPMBase();
91 
95  DPMBase(const DPMBase& other);
96 
100  virtual ~DPMBase();
101 
106  static void incrementRunNumberInFile();
107 
111  static int readRunNumberFromFile();
112 
117  void autoNumber();
118 
123  std::vector<int> get1DParametersFromRunNumber(int size_x) const;
124 
129  std::vector<int> get2DParametersFromRunNumber(int size_x, int size_y) const;
130 
135  std::vector<int> get3DParametersFromRunNumber(int size_x, int size_y, int size_z) const;
136 
140  int launchNewRun(const char* name, bool quick = false);
141 
142  //setters and getters
143 
147  void setRunNumber(int runNumber);
148 
152  int getRunNumber() const;
153 
157 // void sendParticlesToRoot(unsigned int &numberOfLocalParticles, unsigned int processorId, ParticleHandler &tempParticleHandler) const;
158 
162  virtual void decompose();
163 
168  void solve();
169 
174  virtual void computeOneTimeStep();
175 
180  void checkSettings();
181 
185  void forceWriteOutputFiles();
186 
191  virtual void writeOutputFiles();
192 
196  void solve(int argc, char* argv[]);
197 
208  virtual void setupInitialConditions();
209 
214  virtual void writeXBallsScript() const;
215 
219  virtual Mdouble getInfo(const BaseParticle& P) const;
220 
222 
230  virtual void writeRestartFile();
231 
232  void writeDataFile();
233 
234  void writeEneFile();
235 
236  void writeFStatFile();
237 
238  void fillDomainWithParticles(unsigned N=50);
239 
240  enum class ReadOptions : int {
241  ReadAll,
244  };
245 
252 
257  int readRestartFile(std::string fileName, ReadOptions opt = ReadOptions::ReadAll);
258 
259 // /*!
260 // * \brief Loads all MD data and plots statistics for all time steps in the .data file
261 // */
262 // void statisticsFromRestartData(const char *name);
264 
268  virtual void write(std::ostream& os, bool writeAllParticles = true) const;
269 
274  virtual void read(std::istream& is, ReadOptions opt = ReadOptions::ReadAll);
275 
279  virtual BaseWall* readUserDefinedWall(const std::string& type) const
280  { return nullptr; }
281 
286  virtual void readOld(std::istream& is);
287 
291  bool readDataFile(std::string fileName = "", unsigned int format = 0);
292 
296  bool readParAndIniFiles(std::string fileName);
297 
303  bool readNextDataFile(unsigned int format = 0);
304 
308  void readNextFStatFile();
309 
313  bool findNextExistingDataFile(Mdouble tMin, bool verbose = true);
314 
319  bool readArguments(int argc, char* argv[]);
320 
324  virtual bool readNextArgument(int& i, int argc, char* argv[]);
325 
329  virtual bool checkParticleForInteraction(const BaseParticle& P);
330 
334  virtual bool checkParticleForInteractionLocal(const BaseParticle& P);
335 
337 
339 
345 
346  //getters and setters
347 
354  File& getDataFile();
355 
362  File& getEneFile();
363 
370  File& getFStatFile();
371 
378  File& getRestartFile();
379 
386  File& getStatFile();
387 
392 
399  const File& getDataFile() const;
400 
407  const File& getEneFile() const;
408 
415  const File& getFStatFile() const;
416 
423  const File& getRestartFile() const;
424 
431  const File& getStatFile() const;
432 
436  const File& getInteractionFile() const;
437 
441  const std::string& getName() const;
442 
446  void setName(const std::string& name);
447 
451  void setName(const char* name);
452 
456  void setSaveCount(unsigned int saveCount);
457 
461  void setFileType(FileType fileType);
462 
466  void setOpenMode(std::fstream::openmode openMode);
467 
468  //other member functions
469 
473  void resetFileCounter();
474 
478  void closeFiles();
479 
483  void setLastSavedTimeStep(unsigned int nextSavedTimeStep);
484 
488  Mdouble getTime() const;
489 
493  Mdouble getNextTime() const;
494 
499  unsigned int getNumberOfTimeSteps() const;
500 
504  void setTime(Mdouble time);
505 
509  void setTimeMax(Mdouble newTMax);
510 
514  Mdouble getTimeMax() const;
515 
519  void setLogarithmicSaveCount(Mdouble logarithmicSaveCountBase);
520 
521 #ifdef CONTACT_LIST_HGRID
522 
525  PossibleContactList& getPossibleContactList();
526 #endif
527 
538  void setRotation(bool rotation)
539  { rotation_ = rotation; }
540 
545  bool getRotation() const
546  { return rotation_; }
547 
551  void setWallsWriteVTK(FileType writeWallsVTK);
552 
556  void setWallsWriteVTK(bool);
557 
561  void setInteractionsWriteVTK(bool);
562 
566  void setParticlesWriteVTK(bool writeParticlesVTK);
567 
568  void setSuperquadricParticlesWriteVTK(bool writeSuperquadricParticlesVTK);
569 
573  FileType getWallsWriteVTK() const;
574 
578  bool getParticlesWriteVTK() const;
579 
581 
586  Mdouble getXMin() const
587  { return min_.x(); }
588 
593  Mdouble getXMax() const
594  { return max_.x(); }
595 
599  Mdouble getYMin() const
600  { return min_.y(); }
601 
605  Mdouble getYMax() const
606  { return max_.y(); }
607 
611  Mdouble getZMin() const
612  { return min_.z(); }
613 
617  Mdouble getZMax() const
618  { return max_.z(); }
619 
620  /*
621  * \brief Returns the minimum coordinates of the problem domain.
622  */
623  Vec3D getMin() const
624  { return min_; }
625 
626  /*
627  * \brief Returns the maximum coordinates of the problem domain.
628  */
629  Vec3D getMax() const
630  { return max_; }
631 
636  void setXMin(Mdouble newXMin);
637 
642  void setYMin(Mdouble newYMin);
643 
648  void setZMin(Mdouble newZMin);
649 
654  void setXMax(Mdouble newXMax);
655 
660  void setYMax(Mdouble newYMax);
661 
666  void setZMax(Mdouble newZMax);
667 
671  void setMax(const Vec3D& max);
672 
676  void setMax(Mdouble, Mdouble, Mdouble);
677 
681  void setDomain(const Vec3D& min, const Vec3D& max);
682 
686  void setMin(const Vec3D& min);
687 
691  void setMin(Mdouble, Mdouble, Mdouble);
692 
693 
697  void setTimeStep(Mdouble newDt);
698 
702  Mdouble getTimeStep() const;
703 
704  /* Sets the number of omp threads */
705  void setNumberOfOMPThreads(int numberOfOMPThreads);
706 
707  /* Returns the number of omp threads */
708  int getNumberOfOMPThreads() const;
709 
713  void setXBallsColourMode(int newCMode);
714 
718  int getXBallsColourMode() const;
719 
723  void setXBallsVectorScale(double newVScale);
724 
728  double getXBallsVectorScale() const;
729 
733  void setXBallsAdditionalArguments(std::string newXBArgs);
734 
738  std::string getXBallsAdditionalArguments() const;
739 
744  void setXBallsScale(Mdouble newScale);
745 
749  double getXBallsScale() const;
750 
754  void setGravity(Vec3D newGravity);
755 
759  Vec3D getGravity() const;
760 
764  void setDimension(unsigned int newDim);
765 
769  void setSystemDimensions(unsigned int newDim);
770 
774  unsigned int getSystemDimensions() const;
775 
779  void setParticleDimensions(unsigned int particleDimensions);
780 
784  unsigned int getParticleDimensions() const;
785 
790  std::string getRestartVersion() const;
791 
795  void setRestartVersion(std::string newRV);
796 
800  bool getRestarted() const;
801 
805  void setRestarted(bool newRestartedFlag);
806 
810  bool getAppend() const;
811 
815  void setAppend(bool newAppendFlag);
816 
820  Mdouble getElasticEnergy() const;
821 
825  Mdouble getKineticEnergy() const;
826 
831 
836 
837  Mdouble getTotalEnergy() const;
838 
842  Mdouble getTotalMass() const;
843 
847  Vec3D getCentreOfMass() const;
848 
852  Vec3D getTotalMomentum() const;
853 
857  static bool areInContact(const BaseParticle* pI, const BaseParticle* pJ);
858 
860 
863  virtual void hGridInsertParticle(BaseParticle* obj UNUSED);
864 
868  virtual void hGridUpdateParticle(BaseParticle* obj UNUSED);
869 
873  virtual void hGridRemoveParticle(BaseParticle* obj UNUSED);
874 
878  virtual void hGridUpdateMove(BaseParticle*, Mdouble);
879 
883  bool mpiIsInCommunicationZone(BaseParticle* particle);
884 
889 
894 
898  void updateGhostGrid(BaseParticle* P);
899 
904  virtual void gatherContactStatistics(unsigned int index1, int index2, Vec3D Contact, Mdouble delta, Mdouble ctheta,
905  Mdouble fdotn, Mdouble fdott, Vec3D P1_P2_normal_, Vec3D P1_P2_tangential);
906 
910  void setNumberOfDomains(std::vector<unsigned> direction);
911 
912  enum class DomainSplit {X, Y, Z, XY, XZ, YZ, XYZ};
913 
919  void splitDomain(DomainSplit domainSplit);
920 
924  std::vector<unsigned> getNumberOfDomains();
925 
930 
931  void removeOldFiles() const;
932 
936  virtual void hGridGetInteractingParticleList(BaseParticle* obj, std::vector<BaseParticle*>& list)
937  {};
938 
939  virtual void computeWallForces(BaseWall* w);
940 
944  virtual bool getHGridUpdateEachTimeStep() const;
945 
947  void setMeanVelocity(Vec3D V_mean_goal);
948 
950  void setMeanVelocityAndKineticEnergy(Vec3D V_mean_goal, Mdouble Ek_goal);
951 
953  Mdouble getTotalVolume() const;
954 
956  Matrix3D getKineticStress() const;
957 
959  Matrix3D getStaticStress() const;
960 
962  Matrix3D getTotalStress() const;
963 
964  //functions that should only be used in the class definitions
965 protected:
966 
971  virtual void computeAllForces();
972 
977  virtual void computeInternalForces(BaseParticle*);
978 
984 
988  virtual void computeExternalForces(BaseParticle*);
989 
994 
999  virtual void actionsOnRestart();
1000 
1005  virtual void actionsBeforeTimeLoop();
1006 
1011  virtual void hGridActionsBeforeTimeLoop();
1012 
1017  virtual void hGridActionsBeforeTimeStep();
1018 
1023  virtual void actionsBeforeTimeStep();
1024 
1029  virtual void actionsAfterSolve();
1030 
1035  virtual void actionsAfterTimeStep();
1036 
1037  void writeVTKFiles() const;
1038 
1043  virtual void outputXBallsData(std::ostream& os) const;
1044 
1049  virtual void outputXBallsDataParticle(unsigned int i, unsigned int format, std::ostream& os) const;
1050 
1054  virtual void writeEneHeader(std::ostream& os) const;
1055 
1059  virtual void writeFstatHeader(std::ostream& os) const;
1060 
1064  virtual void writeEneTimeStep(std::ostream& os) const;
1065 
1066  // Functions for statistics
1070  virtual void initialiseStatistics();
1071 
1075  virtual void outputStatistics();
1076 
1080  void gatherContactStatistics();
1081 
1085  virtual void processStatistics(bool);
1086 
1090  virtual void finishStatistics();
1091 
1098  virtual void integrateBeforeForceComputation();
1099 
1103  virtual void integrateAfterForceComputation();
1104 
1110  virtual void checkInteractionWithBoundaries();
1111 
1115  virtual void hGridActionsBeforeIntegration();
1116 
1120  virtual void hGridActionsAfterIntegration();
1121 
1125  void setFixedParticles(unsigned int n);
1126 
1130  virtual void printTime() const;
1131 
1135  virtual bool continueSolve() const;
1136 
1141  void outputInteractionDetails() const;
1142 
1146  bool isTimeEqualTo(Mdouble time) const;
1147 
1152 
1159 
1166 
1167  void deleteGhostParticles(std::set<BaseParticle*>& particlesToBeDeleted);
1168 
1169  void synchroniseParticle(BaseParticle*, unsigned fromProcessor = 0);
1170 
1175 
1176 private:
1177  /*The number of openmp (symmetric multiprocessing threads)*/
1179 
1183  unsigned int systemDimensions_;
1184 
1188  unsigned int particleDimensions_;
1189 
1194 
1198  std::vector<unsigned> numberOfDomains_;
1199 
1205 
1210 
1214  unsigned int numberOfTimeSteps_;
1215 
1220 
1225 
1231  std::string restartVersion_;
1232 
1237 
1242  bool append_;
1243 
1250 
1255 
1260 
1262 
1264 
1266 
1268 
1270 
1271  //This is the private data that is only used by the xballs output
1272 
1278 
1283 
1288 
1293 
1298 
1302  std::string name_;
1303 
1304  // defines a Macro for creating an instance of class PossibleContactList. See PossibleContactList.h
1305 #ifdef CONTACT_LIST_HGRID
1306  PossibleContactList possibleContactList;
1307 #endif
1308 
1313 
1314 
1315 public:
1320 
1325 
1330 
1335 
1340 
1345 
1350 
1355 
1360 
1361 
1366 
1371 
1376 
1381 
1386 
1391 
1397 
1403 };
1404 
1405 #endif
virtual void computeExternalForces(BaseParticle *)
Computes the external forces, such as gravity, acting on particles.
Definition: DPMBase.cc:3049
Container to store all ParticleSpecies.
Mdouble timeMax_
Stores the duration of the simulation.
Definition: DPMBase.h:1224
int launchNewRun(const char *name, bool quick=false)
This launches a code from within this code. Please pass the name of the code to run.
Definition: DPMBase.cc:764
void setTime(Mdouble time)
Sets a new value for the current simulation time.
Definition: DPMBase.cc:825
virtual void actionsBeforeTimeLoop()
A virtual function. Allows one to carry out any operations before the start of the time loop...
Definition: DPMBase.cc:1629
Container that stores all CG objects.
Definition: CGHandler.h:64
ParticleHandler paoloParticleHandler
Fake particleHandler created by Paolo needed temporary by just Paolo.
Definition: DPMBase.h:1334
void setXBallsVectorScale(double newVScale)
Set the scale of vectors in xballs.
Definition: DPMBase.cc:1280
virtual void write(std::ostream &os, bool writeAllParticles=true) const
Loads all MD data and plots statistics for all time steps in the .data file.
Definition: DPMBase.cc:3375
FileType getWallsWriteVTK() const
Returns whether walls are written in a VTK file.
Definition: DPMBase.cc:935
virtual void hGridUpdateParticle(BaseParticle *obj UNUSED)
Definition: DPMBase.cc:1664
Container to store pointers to all BaseBoundary objects.
void setXMax(Mdouble newXMax)
Sets the value of XMax, the upper bound of the problem domain in the x-direction. ...
Definition: DPMBase.cc:1126
void setWallsWriteVTK(FileType writeWallsVTK)
Sets whether walls are written into a VTK file.
Definition: DPMBase.cc:878
void solve()
The work horse of the code.
Definition: DPMBase.cc:3968
virtual void hGridInsertParticle(BaseParticle *obj UNUSED)
Definition: DPMBase.cc:1657
The DPMBase header includes quite a few header files, defining all the handlers, which are essential...
Definition: DPMBase.h:72
void setLastSavedTimeStep(unsigned int nextSavedTimeStep)
Sets the next time step for all the files (ene, data, fstat, restart, stat) at which the data is to b...
Definition: DPMBase.cc:508
Mdouble getRotationalEnergy() const
JMFT Returns the global rotational energy stored in the system.
Definition: DPMBase.cc:1537
Domain * getCurrentDomain()
Function that returns a pointer to the domain corresponding to the processor.
Definition: DPMBase.cc:5034
virtual void integrateAfterForceComputation()
Update particles' and walls' positions and velocities after force computation.
Definition: DPMBase.cc:3194
void checkAndDuplicatePeriodicParticles()
For simulations using periodic boundaries, checks and adds particles when necessary into the particle...
Definition: DPMBase.cc:4814
std::string name_
the name of the problem, used, e.g., for the output files
Definition: DPMBase.h:1302
static bool areInContact(const BaseParticle *pI, const BaseParticle *pJ)
Checks if two particle are in contact or is there any positive overlap.
Definition: DPMBase.cc:1621
int getXBallsColourMode() const
Get the xballs colour mode (CMode).
Definition: DPMBase.cc:1270
virtual void hGridGetInteractingParticleList(BaseParticle *obj, std::vector< BaseParticle * > &list)
Creates a list of neighbour particles obtained from the hgrid.
Definition: DPMBase.h:936
Matrix3D getStaticStress() const
Calculate the static stress tensor in the system averaged over the whole volume.
Definition: DPMBase.cc:5146
void writeVTKFiles() const
Definition: DPMBase.cc:2091
void setTimeMax(Mdouble newTMax)
Sets a new value for the maximum simulation duration.
Definition: DPMBase.cc:840
void constructor()
A function which initialises the member variables to default values, so that the problem can be solve...
Definition: DPMBase.cc:200
unsigned int getSystemDimensions() const
Returns the system dimensionality.
Definition: DPMBase.cc:1390
bool readArguments(int argc, char *argv[])
Can interpret main function input arguments that are passed by the driver codes.
Definition: DPMBase.cc:4174
bool mpiInsertParticleCheck(BaseParticle *P)
Function that checks if the mpi particle should really be inserted by the current domain...
Definition: DPMBase.cc:1692
File & getInteractionFile()
Return a reference to the file InteractionsFile.
Definition: DPMBase.cc:335
Vec3D max_
Definition: DPMBase.h:1204
double Mdouble
Definition: GeneralDefine.h:34
unsigned int particleDimensions_
determines if 2D or 3D particle volume is used for mass calculations
Definition: DPMBase.h:1188
void splitDomain(DomainSplit domainSplit)
Definition: DPMBase.cc:4968
void setMax(const Vec3D &max)
Sets the maximum coordinates of the problem domain.
Definition: DPMBase.cc:1043
void setYMin(Mdouble newYMin)
Sets the value of YMin, the lower bound of the problem domain in the y-direction. ...
Definition: DPMBase.cc:995
virtual void processStatistics(bool)
Definition: DPMBase.cc:1878
Mdouble getZMax() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMax() returns ZMax...
Definition: DPMBase.h:617
Mdouble getXMin() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMin() returns XMin...
Definition: DPMBase.h:586
Vec3D getCentreOfMass() const
JMFT: Return the centre of mass of the system, excluding fixed particles.
Definition: DPMBase.cc:1574
void readNextFStatFile()
Reads the next fstat file.
Definition: DPMBase.cc:2754
bool readSpeciesFromDataFile_
Determines if the last column of the data file is interpreted as the info parameter during restart...
Definition: DPMBase.h:1312
virtual void decompose()
Sends particles from processorId to the root processor.
Definition: DPMBase.cc:3885
unsigned int getParticleDimensions() const
Returns the particle dimensionality.
Definition: DPMBase.cc:1427
Vec3D getMin() const
Definition: DPMBase.h:623
void setParticlesWriteVTK(bool writeParticlesVTK)
Sets whether particles are written in a VTK file.
Definition: DPMBase.cc:904
virtual void initialiseStatistics()
Definition: DPMBase.cc:1845
void setLogarithmicSaveCount(Mdouble logarithmicSaveCountBase)
Sets File::logarithmicSaveCount_ for all files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:5192
const std::complex< Mdouble > i
Definition: ExtendedMath.h:50
WallVTKWriter wallVTKWriter_
Definition: DPMBase.h:1265
Mdouble getYMin() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMin() returns YMin...
Definition: DPMBase.h:599
void setXBallsColourMode(int newCMode)
Set the xballs output mode.
Definition: DPMBase.cc:1260
File interactionFile
File class to handle in- and output into .interactions file. This file hold information about interac...
Definition: DPMBase.h:1396
virtual void readOld(std::istream &is)
Reads all data from a restart file, e.g. domain data and particle data; old version.
Definition: DPMBase.cc:3739
const std::string & getName() const
Returns the name of the file. Does not allow to change it though.
Definition: DPMBase.cc:389
InteractionVTKWriter interactionVTKWriter_
Definition: DPMBase.h:1267
int runNumber_
This stores the run number for saving.
Definition: DPMBase.h:1297
virtual void outputXBallsDataParticle(unsigned int i, unsigned int format, std::ostream &os) const
This function writes out the particle locations into an output stream in a format the XBalls program ...
void setParticleDimensions(unsigned int particleDimensions)
Sets the particle dimensionality.
Definition: DPMBase.cc:1408
virtual ~DPMBase()
virtual destructor
Definition: DPMBase.cc:287
virtual void actionsAfterTimeStep()
A virtual function which allows to define operations to be executed after time step.
Definition: DPMBase.cc:1838
void writePythonFileForVTKVisualisation() const
record when the simulation started
Definition: DPMBase.cc:2127
DomainHandler domainHandler
An object of the class DomainHandler which deals with parallel code.
Definition: DPMBase.h:1354
void setZMax(Mdouble newZMax)
Sets the value of ZMax, the upper bound of the problem domain in the z-direction. ...
Definition: DPMBase.cc:1178
virtual void computeWallForces(BaseWall *w)
Definition: DPMBase.cc:5172
void setDimension(unsigned int newDim)
Sets both the system dimensions and the particle dimensionality.
Definition: DPMBase.cc:1363
std::vector< unsigned > numberOfDomains_
Vector containing the number of domains in x-,y- and z-direction, required for parallel computations...
Definition: DPMBase.h:1198
MERCURY_DEPRECATED File & getEneFile()
The non const version. Allows to edit the File::eneFile.
Definition: DPMBase.cc:303
void synchroniseParticle(BaseParticle *, unsigned fromProcessor=0)
Definition: DPMBase.cc:4895
void setAppend(bool newAppendFlag)
Sets whether the "append" option is on or off.
Definition: DPMBase.cc:1482
int getNumberOfOMPThreads() const
Definition: DPMBase.cc:1246
virtual void writeOutputFiles()
Writes simulation data to all the main Mercury files: .data, .ene, .fstat, .xballs and ...
Definition: DPMBase.cc:3846
void setSystemDimensions(unsigned int newDim)
Sets the system dimensionality.
Definition: DPMBase.cc:1377
void setMeanVelocityAndKineticEnergy(Vec3D V_mean_goal, Mdouble Ek_goal)
This function will help you set a fixed kinetic energy and mean velocity in your system.
Definition: DPMBase.cc:5067
void setGravity(Vec3D newGravity)
Sets a new value for the gravitational acceleration.
Definition: DPMBase.cc:1343
virtual void outputXBallsData(std::ostream &os) const
This function writes the location of the walls and particles in a format the XBalls program can read...
Definition: DPMBase.cc:2240
virtual bool getHGridUpdateEachTimeStep() const
Definition: DPMBase.cc:1678
bool rotation_
A flag to turn on/off particle rotation. true will enable particle rotation. false will disable parti...
Definition: DPMBase.h:1249
Mdouble & z()
RW reference to Z.
Definition: Vector.h:368
bool getParticlesWriteVTK() const
Returns whether particles are written in a VTK file.
Definition: DPMBase.cc:946
#define MERCURY_DEPRECATED
Definition: GeneralDefine.h:37
void updateGhostGrid(BaseParticle *P)
Checks if the Domain/periodic interaction distance needs to be updated and updates it accordingly...
Definition: DPMBase.cc:1797
unsigned int numberOfTimeSteps_
Stores the number of time steps.
Definition: DPMBase.h:1214
FileType
With FileType options, one is able to choose if data is to be read/written from/into no or single or ...
Definition: File.h:40
bool restarted_
A bool to check if the simulation was restarted or not, ie. if setupInitialConditionsShould be run an...
Definition: DPMBase.h:1236
Mdouble getXMax() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMax() returns XMax...
Definition: DPMBase.h:593
Matrix3D getTotalStress() const
Calculate the total stress tensor in the system averaged over the whole volume.
Definition: DPMBase.cc:5166
Container to store pointers to all BasePeriodicBoundary objects.
bool findNextExistingDataFile(Mdouble tMin, bool verbose=true)
Finds and opens the next data file, if such a file exists.
Definition: DPMBase.cc:2538
virtual void writeEneTimeStep(std::ostream &os) const
Write the global kinetic, potential energy, etc. in the system.
Definition: DPMBase.cc:2067
void forceWriteOutputFiles()
Writes output files immediately, even if the current time step was not meant to be written...
Definition: DPMBase.cc:3825
void setYMax(Mdouble newYMax)
Sets the value of YMax, the upper bound of the problem domain in the y-direction. ...
Definition: DPMBase.cc:1152
unsigned int systemDimensions_
The dimensions of the simulation i.e. 2D or 3D.
Definition: DPMBase.h:1183
void writeFStatFile()
Definition: DPMBase.cc:2858
void setDomain(const Vec3D &min, const Vec3D &max)
Sets the minimum coordinates of the problem domain.
Definition: DPMBase.cc:1059
This is a class that generates random numbers i.e. named the Random Number Generator (RNG)...
Definition: RNG.h:52
Mdouble getElasticEnergy() const
Returns the global elastic energy within the system.
Definition: DPMBase.cc:1490
Matrix3D getKineticStress() const
Calculate the kinetic stress tensor in the system averaged over the whole volume. ...
Definition: DPMBase.cc:5124
Mdouble getGravitationalEnergy() const
Returns the global gravitational potential energy stored in the system.
Definition: DPMBase.cc:1521
static void incrementRunNumberInFile()
Increment the run Number (counter value) stored in the file_counter (COUNTER_DONOTDEL) by 1 and store...
Definition: DPMBase.cc:617
File dataFile
An instance of class File to handle in- and output into a .data file.
Definition: DPMBase.h:1370
bool readParAndIniFiles(std::string fileName)
Allows the user to read par.ini files (useful to read files produced by the MDCLR simulation code - e...
Definition: DPMBase.cc:2355
MERCURY_DEPRECATED File & getDataFile()
The non const version. Allows one to edit the File::dataFile.
Definition: DPMBase.cc:295
virtual void read(std::istream &is, ReadOptions opt=ReadOptions::ReadAll)
Reads all data from a restart file, e.g. domain data and particle data.
Definition: DPMBase.cc:3496
virtual void hGridActionsBeforeIntegration()
This function has to be called before integrateBeforeForceComputation.
Definition: DPMBase.cc:1900
virtual BaseWall * readUserDefinedWall(const std::string &type) const
Allows you to read in a wall defined in a Driver directory; see USER/Luca/ScrewFiller.
Definition: DPMBase.h:279
File fStatFile
An instance of class File to handle in- and output into a .fstat file.
Definition: DPMBase.h:1375
bool getAppend() const
Returns whether the "append" option is on or off.
Definition: DPMBase.cc:1470
virtual bool readNextArgument(int &i, int argc, char *argv[])
Interprets the i^th command-line argument.
Definition: DPMBase.cc:4299
virtual bool checkParticleForInteraction(const BaseParticle &P)
Checks whether a particle P has any interaction with walls or other particles.
Definition: DPMBase.cc:4588
void performGhostVelocityUpdate()
updates the final time-step velocity of the ghost particles
Definition: DPMBase.cc:4913
bool getRestarted() const
Returns the flag denoting if the simulation was restarted or not.
Definition: DPMBase.cc:1453
bool writeSuperquadricParticlesVTK_
Definition: DPMBase.h:1261
CGHandler cgHandler
Object of the class cgHandler.
Definition: DPMBase.h:1365
unsigned int getNumberOfTimeSteps() const
Returns the current counter of time-steps, i.e. the number of time-steps that the simulation has unde...
Definition: DPMBase.cc:813
int xBallsColourMode_
XBalls is a package to view the particle data. As an alternative MercuryDPM also supports ParaView...
Definition: DPMBase.h:1277
BoundaryHandler boundaryHandler
An object of the class BoundaryHandler which concerns insertion and deletion of particles into or fro...
Definition: DPMBase.h:1344
PeriodicBoundaryHandler periodicBoundaryHandler
Internal handler that deals with periodic boundaries, especially in a parallel build.
Definition: DPMBase.h:1349
ParticleVtkWriter * vtkWriter_
Definition: DPMBase.h:1263
BoundaryVTKWriter boundaryVTKWriter_
Definition: DPMBase.h:1269
void fillDomainWithParticles(unsigned N=50)
Inserts particles in the whole domain.
Definition: DPMBase.cc:2874
virtual Mdouble getInfo(const BaseParticle &P) const
A virtual function that returns some user-specified information about a particle. ...
Definition: DPMBase.cc:1602
Mdouble xBallsScale_
sets the xballs argument scale (see XBalls/xballs.txt)
Definition: DPMBase.h:1287
void readSpeciesFromDataFile(bool read=true)
Definition: DPMBase.h:338
void writeEneFile()
Definition: DPMBase.cc:2848
void setXMin(Mdouble newXMin)
Sets the value of XMin, the lower bound of the problem domain in the x-direction. ...
Definition: DPMBase.cc:971
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1329
Container to store Interaction objects.
Mdouble getKineticEnergy() const
Returns the global kinetic energy stored in the system.
Definition: DPMBase.cc:1504
Mdouble & x()
RW reference to X.
Definition: Vector.h:344
Mdouble time_
Stores the current simulation time.
Definition: DPMBase.h:1209
void setRestartVersion(std::string newRV)
Sets restart_version.
Definition: DPMBase.cc:1444
void setMin(const Vec3D &min)
Sets the minimum coordinates of the problem domain.
Definition: DPMBase.cc:1079
void setSaveCount(unsigned int saveCount)
Sets File::saveCount_ for all files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:398
void closeFiles()
Closes all files (ene, data, fstat, restart, stat) that were opened to read or write.
Definition: DPMBase.cc:492
Mdouble getTotalVolume() const
Get the total volume of the cuboid system.
Definition: DPMBase.cc:5115
Vec3D getGravity() const
Returns the gravitational acceleration.
Definition: DPMBase.cc:1351
void setOpenMode(std::fstream::openmode openMode)
Sets File::openMode_ for all files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:479
void checkSettings()
Checks if the essentials are set properly to go ahead with solving the problem.
Definition: DPMBase.cc:3796
#define UNUSED
Definition: GeneralDefine.h:39
virtual void hGridActionsBeforeTimeLoop()
A virtual function that allows one to carry out hGrid operations before the start of the time loop...
Definition: DPMBase.cc:1636
virtual void computeAllForces()
Computes all the forces acting on the particles using the BaseInteractable::setForce() and BaseIntera...
Definition: DPMBase.cc:3277
bool mpiIsInCommunicationZone(BaseParticle *particle)
Checks if the position of the particle is in an mpi communication zone or not.
Definition: DPMBase.cc:1724
std::vector< int > get3DParametersFromRunNumber(int size_x, int size_y, int size_z) const
This turns a counter into 3 indices, which is a useful feature for performing a 3D parameter study...
Definition: DPMBase.cc:724
bool readNextDataFile(unsigned int format=0)
Reads the next data file with default format=0. However, one can modify the format based on whether t...
Definition: DPMBase.cc:2575
void setInteractionsWriteVTK(bool)
Sets whether interactions are written into a VTK file.
Definition: DPMBase.cc:894
Basic class for walls.
Definition: BaseWall.h:47
void setZMin(Mdouble newZMin)
Sets the value of ZMin, the lower bound of the problem domain in the z-direction. ...
Definition: DPMBase.cc:1019
virtual void actionsAfterSolve()
A virtual function which allows to define operations to be executed after the solve().
Definition: DPMBase.cc:1831
int numberOfOMPThreads_
Definition: DPMBase.h:1178
virtual void printTime() const
Displays the current simulation time and the maximum simulation duration.
Definition: DPMBase.cc:1930
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
FileType writeWallsVTK_
A flag to turn on/off the vtk writer for walls.
Definition: DPMBase.h:1254
virtual void writeXBallsScript() const
This writes a script which can be used to load the xballs problem to display the data just generated...
void setNumberOfOMPThreads(int numberOfOMPThreads)
Definition: DPMBase.cc:1218
Mdouble & y()
RW reference to Y.
Definition: Vector.h:356
void outputInteractionDetails() const
Displays the interaction details corresponding to the pointer objects in the interaction handler...
Definition: DPMBase.cc:4927
Vec3D getMax() const
Definition: DPMBase.h:629
void setXBallsAdditionalArguments(std::string newXBArgs)
Set the additional arguments for xballs.
Definition: DPMBase.cc:1307
Container to store all BaseParticle.
void setFixedParticles(unsigned int n)
Sets a number, n, of particles in the particleHandler as "fixed particles".
Definition: DPMBase.cc:1920
Mdouble getYMax() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMax() returns XMax...
Definition: DPMBase.h:605
Mdouble xBallsVectorScale_
sets the xballs argument vscale (see XBalls/xballs.txt)
Definition: DPMBase.h:1282
virtual void actionsBeforeTimeStep()
A virtual function which allows to define operations to be executed before the new time step...
Definition: DPMBase.cc:1824
ParticleVtkWriter * getVtkWriter() const
Definition: DPMBase.cc:5039
virtual void computeInternalForce(BaseParticle *, BaseParticle *)
Computes the forces between two particles (internal in the sense that the sum over all these forces i...
Definition: DPMBase.cc:2994
Mdouble timeStep_
Stores the simulation time step.
Definition: DPMBase.h:1219
WallHandler wallHandler
An object of the class WallHandler. Contains pointers to all the walls created.
Definition: DPMBase.h:1339
Container to store all BaseWall.
Definition: WallHandler.h:42
RNG random
This is a random generator, often used for setting up the initial conditions etc...
Definition: DPMBase.h:1324
virtual void computeInternalForces(BaseParticle *)
Computes the internal forces on particle i (internal in the sense that the sum over all these forces ...
Definition: DPMBase.cc:3359
The simulation can be subdivided into Domain's used in parallel code.
Definition: Domain.h:63
virtual void hGridRemoveParticle(BaseParticle *obj UNUSED)
Definition: DPMBase.cc:1671
void setMeanVelocity(Vec3D V_mean_goal)
This function will help you set a fixed kinetic energy and mean velocity in your system.
Definition: DPMBase.cc:5050
std::vector< int > get1DParametersFromRunNumber(int size_x) const
This turns a counter into 1 index, which is a useful feature for performing 1D parameter study...
Definition: DPMBase.cc:659
bool writeParticlesVTK_
A flag to turn on/off the vtk writer for particles.
Definition: DPMBase.h:1259
void setName(const std::string &name)
Allows to set the name of all the files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:412
virtual void actionsOnRestart()
A virtual function where the users can add extra code which is executed only when the code is restart...
Definition: DPMBase.cc:1643
Manages the linked list of PossibleContact.
void writeDataFile()
Definition: DPMBase.cc:2839
virtual void writeEneHeader(std::ostream &os) const
Writes a header with a certain format for ENE file.
Definition: DPMBase.cc:1977
void autoNumber()
The autoNumber() function calls three functions: setRunNumber(), readRunNumberFromFile() and incremen...
Definition: DPMBase.cc:528
Vec3D getTotalMomentum() const
JMFT: Return the total momentum of the system, excluding fixed particles.
Definition: DPMBase.cc:1584
std::vector< unsigned > getNumberOfDomains()
returns the number of domains
Definition: DPMBase.cc:5025
void removeOldFiles() const
Definition: DPMBase.cc:4205
int getRunNumber() const
This returns the current value of the counter (runNumber_)
Definition: DPMBase.cc:606
Mdouble getZMin() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMin() returns ZMin...
Definition: DPMBase.h:611
void setSuperquadricParticlesWriteVTK(bool writeSuperquadricParticlesVTK)
Definition: DPMBase.cc:918
void insertGhostParticle(BaseParticle *P)
This function inserts a particle in the mpi communication boundaries.
Definition: DPMBase.cc:1771
void gatherContactStatistics()
Definition: DPMBase.cc:1858
MERCURY_DEPRECATED File & getFStatFile()
The non const version. Allows to edit the File::fStatFile.
Definition: DPMBase.cc:311
virtual void outputStatistics()
Definition: DPMBase.cc:1853
File statFile
An instance of class File to handle in- and output into a .stat file.
Definition: DPMBase.h:1390
Container to store all Domain.
Definition: DomainHandler.h:46
void setTimeStep(Mdouble newDt)
Sets a new value for the simulation time step.
Definition: DPMBase.cc:1195
void removeDuplicatePeriodicParticles()
Removes periodic duplicate Particles.
Definition: DPMBase.cc:4771
bool checkParticleForInteractionLocalPeriodic(const BaseParticle &P)
Definition: DPMBase.cc:4637
bool getSuperquadricParticlesWriteVTK() const
Definition: DPMBase.cc:954
File eneFile
An instance of class File to handle in- and output into a .ene file.
Definition: DPMBase.h:1380
virtual void integrateBeforeForceComputation()
Update particles' and walls' positions and velocities before force computation.
Definition: DPMBase.cc:3108
static int readRunNumberFromFile()
Read the run number or the counter from the counter file (COUNTER_DONOTDEL)
Definition: DPMBase.cc:542
virtual void writeRestartFile()
Stores all the particle data for current save time step to a "restart" file, which is a file simply i...
Definition: DPMBase.cc:2829
std::string xBallsAdditionalArguments_
A string of additional arguments for xballs can be specified (see XBalls/xballs.txt). e.g. "-solidf -v0".
Definition: DPMBase.h:1292
void computeForcesDueToWalls(BaseParticle *, BaseWall *)
Computes the forces on the particles due to the walls (normals are outward normals) ...
Definition: DPMBase.cc:3069
double getXBallsVectorScale() const
Returns the scale of vectors used in xballs.
Definition: DPMBase.cc:1290
Mdouble getTotalMass() const
JMFT: Return the total mass of the system, excluding fixed particles.
Definition: DPMBase.cc:1558
virtual bool continueSolve() const
A virtual function for deciding whether to continue the simulation, based on a user-specified criteri...
Definition: DPMBase.cc:1953
void setRotation(bool rotation)
Sets whether particle rotation is enabled or disabled.
Definition: DPMBase.h:538
File restartFile
An instance of class File to handle in- and output into a .restart file.
Definition: DPMBase.h:1385
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
Mdouble getNextTime() const
Returns the current simulation time.
Definition: DPMBase.cc:805
bool readDataFile(std::string fileName="", unsigned int format=0)
This allows particle data to be reloaded from data files.
Definition: DPMBase.cc:2319
virtual void hGridUpdateMove(BaseParticle *, Mdouble)
Definition: DPMBase.cc:1893
std::string restartVersion_
Previous versions of MercuryDPM had a different restart file format, the below member variable allows...
Definition: DPMBase.h:1231
void setNumberOfDomains(std::vector< unsigned > direction)
Sets the number of domains in x-,y- and z-direction. Required for parallel computations.
Definition: DPMBase.cc:4958
DomainSplit
Definition: DPMBase.h:912
void setRestarted(bool newRestartedFlag)
Allows to set the flag stating if the simulation is to be restarted or not.
Definition: DPMBase.cc:1461
void deleteGhostParticles(std::set< BaseParticle * > &particlesToBeDeleted)
Definition: DPMBase.cc:4871
Implementation of a 3D matrix.
Definition: Matrix.h:37
Definition: Vector.h:49
MERCURY_DEPRECATED File & getStatFile()
The non const version. Allows to edit the File::statFile.
Definition: DPMBase.cc:327
std::string getXBallsAdditionalArguments() const
Returns the additional arguments for xballs.
Definition: DPMBase.cc:1315
virtual void hGridActionsAfterIntegration()
This function has to be called after integrateBeforeForceComputation.
Definition: DPMBase.cc:1907
Mdouble getTimeStep() const
Returns the simulation time step.
Definition: DPMBase.cc:1211
double getXBallsScale() const
Returns the scale of the view in xballs.
Definition: DPMBase.cc:1332
Definition: File.h:80
std::vector< int > get2DParametersFromRunNumber(int size_x, int size_y) const
This turns a counter into 2 indices which is a very useful feature for performing a 2D study...
Definition: DPMBase.cc:687
virtual void hGridActionsBeforeTimeStep()
A virtual function that allows one to set or execute hGrid parameters or operations before every simu...
Definition: DPMBase.cc:1650
void setXBallsScale(Mdouble newScale)
Sets the scale of the view (either normal, zoom in or zoom out) to display in xballs. The default is fit to screen.
Definition: DPMBase.cc:1323
bool readRestartFile(ReadOptions opt=ReadOptions::ReadAll)
Reads all the particle data corresponding to a given, existing . restart file (for more details regar...
Definition: DPMBase.cc:2896
bool getRotation() const
Indicates whether particle rotation is enabled or disabled.
Definition: DPMBase.h:545
virtual void finishStatistics()
Definition: DPMBase.cc:1885
MERCURY_DEPRECATED File & getRestartFile()
The non const version. Allows to edit the File::restartFile.
Definition: DPMBase.cc:319
void setRunNumber(int runNumber)
This sets the counter/Run number, overriding the defaults.
Definition: DPMBase.cc:595
Mdouble getTime() const
Returns the current simulation time.
Definition: DPMBase.cc:797
virtual void checkInteractionWithBoundaries()
There are a range of boundaries one could implement depending on ones' problem. This methods checks f...
Definition: DPMBase.cc:3152
virtual void writeFstatHeader(std::ostream &os) const
Writes a header with a certain format for FStat file.
Definition: DPMBase.cc:2006
Vec3D min_
These vectors are used for the XBalls domain, and occasionally people use it to add walls...
Definition: DPMBase.h:1203
Mdouble getTimeMax() const
Returns the maximum simulation duration.
Definition: DPMBase.cc:855
void resetFileCounter()
Resets the file counter for each file i.e. for ene, data, fstat, restart, stat)
Definition: DPMBase.cc:461
DPMBase()
Constructor that calls the "void constructor()".
Definition: DPMBase.cc:187
virtual void computeOneTimeStep()
Performs everything needed for one time step, used in the time-loop of solve().
Definition: DPMBase.cc:4090
Vec3D gravity_
Gravity vector.
Definition: DPMBase.h:1193
void performGhostParticleUpdate()
When the Verlet scheme updates the positions and velocities of particles, ghost particles will need a...
Definition: DPMBase.cc:4848
virtual bool checkParticleForInteractionLocal(const BaseParticle &P)
Checks if a particle P has any interaction with walls or other particles in the local domain...
Definition: DPMBase.cc:4687
Mdouble getTotalEnergy() const
Definition: DPMBase.cc:1551
virtual void setupInitialConditions()
This function allows to set the initial conditions for our problem to be solved, by default particle ...
Definition: DPMBase.cc:1961
ReadOptions
Definition: DPMBase.h:240
bool append_
A flag to determine if the file has to be appended or not. See DPMBase::Solve() for example...
Definition: DPMBase.h:1242
std::string getRestartVersion() const
This is to take into account for different Mercury versions. Returns the version of the restart file...
Definition: DPMBase.cc:1435
void setFileType(FileType fileType)
Sets File::fileType_ for all files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:449
bool isTimeEqualTo(Mdouble time) const
Checks whether the input variable "time" is the current time in the simulation.
Definition: DPMBase.cc:4948