visualiseSinteringFromRestartFile.cpp File Reference

Functions

int main (int argc, char *argv[])
 

Function Documentation

◆ main()

int main ( int argc  ,
char argv[] 
)
32 {
33  if (argc < 2)
34  {
35  logger(ERROR, "Please enter the name of the simulation you want to restart and, optionally, the name of the "
36  "simulation after restart");
37  }
38  else
39  {
40  logger(INFO, "restart data: %.restart", argv[1]);
41  }
42 
43  Mercury3D dpm;
44  dpm.setName(argv[1]);
45  dpm.readRestartFile();
46  dpm.setRestarted(false);
47  dpm.setTimeMax(dpm.getTimeStep());
49 
50  logger(INFO, "Writing file %.tex", std::string(argv[1]));
51  ofstream os(std::string(argv[1]) + ".tex");
52  os << "\\documentclass[11pt]{standalone}\n"
53  "\\usepackage{tikz,graphics,multirow,multicol,tabularx, tabu,xcolor}\n"
54  "\n"
55  "\\begin{document}\n"
56  "\\begin{tikzpicture}[\n"
57  "pf/.style ={fill=yellow!50,draw=none},%fill particle\n"
58  "pd/.style ={draw=black} %draw particle\n"
59  "]\n";
60 
61  os << "%draw particles' inside\n";
62  for (auto p : dpm.particleHandler)
63  {
64  const Vec3D& pos = p->getPosition()*1e6;
65  const Mdouble& r = p->getRadius()*1e6;
66  os << "\\draw[pf] (" + std::to_string(pos.X)
67  +"," + std::to_string(pos.Z)
68  + ") circle (" + std::to_string(r) +");\n";
69  }
70 
71  os << "%draw particles' outside\n";
72  for (auto p : dpm.particleHandler)
73  {
74  const Vec3D& pos = p->getPosition()*1e6;
75  const Mdouble& r = p->getRadius()*1e6;
76  os << "\\draw[pd] (" + std::to_string(pos.X)
77  +"," + std::to_string(pos.Z)
78  + ") circle (" + std::to_string(r) +");\n";
79  }
80 
81  os << "%draw plastic overlap' outside\n";
82  for (auto i : dpm.interactionHandler)
83  {
84  auto c = dynamic_cast<SinterInteraction*>(i);
85  const Vec3D& cp = c->getContactPoint()*1e6;
86  const Vec3D& n = c->getNormal();
87  const Vec3D t = Vec3D(n.Z,0,-n.X);
88  const Mdouble& po = 0.5*c->getPlasticOverlap()*1e6;
89  const Mdouble& o = 0.5*c->getOverlap()*1e6;
90  const BaseParticle* p = dynamic_cast<BaseParticle*>(c->getP());
91  logger.assert_always(p!= nullptr,"not particle");
92  const Mdouble& r = p->getRadius()*1e6;
93  const Mdouble x = sqrt(2.0*po*r);
94  const Vec3D a0 = cp+x*t+(o-po)*n, a1 = cp+x*t+0.5*r*n, a2 = cp-x*t+0.5*r*n, a3 = cp-x*t+(o-po)*n;
95  os << "\\draw[pf] ("+ std::to_string(a0.X) +","+ std::to_string(a0.Z)
96  +") -- ("+ std::to_string(a1.X) +","+ std::to_string(a1.Z)
97  +") -- ("+ std::to_string(a2.X) +","+ std::to_string(a2.Z)
98  +") -- ("+ std::to_string(a3.X) +","+ std::to_string(a3.Z)
99  +") -- cycle;\n";
100  os << "\\draw[pd] ("+ std::to_string(a0.X) +","+ std::to_string(a0.Z)
101  +") -- ("+ std::to_string(a3.X) +","+ std::to_string(a3.Z) + ");\n";
102  const Vec3D b0 = cp+x*t-(o-po)*n, b1 = cp+x*t-0.5*r*n, b2 = cp-x*t-0.5*r*n, b3 = cp-x*t-(o-po)*n;
103  os << "\\draw[pf] ("+ std::to_string(b0.X) +","+ std::to_string(b0.Z)
104  +") -- ("+ std::to_string(b1.X) +","+ std::to_string(b1.Z)
105  +") -- ("+ std::to_string(b2.X) +","+ std::to_string(b2.Z)
106  +") -- ("+ std::to_string(b3.X) +","+ std::to_string(b3.Z)
107  +") -- cycle;\n";
108  os << "\\draw[pd] ("+ std::to_string(b0.X) +","+ std::to_string(b0.Z)
109  +") -- ("+ std::to_string(b3.X) +","+ std::to_string(b3.Z) + ");\n";
110  }
111  os << "\\end{tikzpicture}\n"
112  "\\end{document}";
113 
114  //dpm.setParticlesWriteVTK(true);
115 // dpm.wallHandler.setWriteVTK(FileType::MULTIPLE_FILES);
116 // dpm.solve(argc-1, argv+1);
117  return 0;
118 }
const unsigned n
Definition: CG3DPackingUnitTest.cpp:32
@ NO_FILE
file will not be created/read
LL< Log::INFO > INFO
Info log level.
Definition: Logger.cc:55
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
LL< Log::ERROR > ERROR
Error log level.
Definition: Logger.cc:53
Definition: BaseParticle.h:54
Mdouble getRadius() const
Returns the particle's radius.
Definition: BaseParticle.h:348
void setName(const std::string &name)
Allows to set the name of all the files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:422
Mdouble getTimeStep() const
Returns the simulation time step.
Definition: DPMBase.cc:1250
void setRestarted(bool newRestartedFlag)
Allows to set the flag stating if the simulation is to be restarted or not.
Definition: DPMBase.cc:1501
File restartFile
An instance of class File to handle in- and output into a .restart file.
Definition: DPMBase.h:1493
InteractionHandler interactionHandler
An object of the class InteractionHandler.
Definition: DPMBase.h:1467
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created.
Definition: DPMBase.h:1437
void setTimeMax(Mdouble newTMax)
Sets a new value for the maximum simulation duration.
Definition: DPMBase.cc:873
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:3006
void setFileType(FileType fileType)
Sets the type of file needed to write into or read from. File::fileType_.
Definition: File.cc:215
This adds on the hierarchical grid code for 3D problems.
Definition: Mercury3D.h:37
Computes normal forces in case of a linear plastic visco-elastic interaction.
Definition: SinterInteraction.h:40
Definition: Vector.h:51
Mdouble Z
Definition: Vector.h:66
Mdouble X
the vector components
Definition: Vector.h:66
const std::complex< Mdouble > i
Definition: ExtendedMath.h:51

References ERROR, BaseParticle::getRadius(), DPMBase::getTimeStep(), constants::i, INFO, DPMBase::interactionHandler, logger, n, NO_FILE, DPMBase::particleHandler, DPMBase::readRestartFile(), DPMBase::restartFile, File::setFileType(), DPMBase::setName(), DPMBase::setRestarted(), DPMBase::setTimeMax(), Vec3D::X, and Vec3D::Z.