visualiseSinteringFromRestartFile.cpp File Reference

Functions

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

Function Documentation

◆ main()

int main ( int argc  ,
char argv[] 
)
11 {
12  if (argc < 2)
13  {
14  logger(ERROR, "Please enter the name of the simulation you want to restart and, optionally, the name of the "
15  "simulation after restart");
16  }
17  else
18  {
19  logger(INFO, "restart data: %.restart", argv[1]);
20  }
21 
22  Mercury3D dpm;
23  dpm.setName(argv[1]);
24  dpm.readRestartFile();
25  dpm.setRestarted(false);
26  dpm.setTimeMax(dpm.getTimeStep());
28 
29  logger(INFO, "Writing file %.tex", std::string(argv[1]));
30  ofstream os(std::string(argv[1]) + ".tex");
31  os << "\\documentclass[11pt]{standalone}\n"
32  "\\usepackage{tikz,graphics,multirow,multicol,tabularx, tabu,xcolor}\n"
33  "\n"
34  "\\begin{document}\n"
35  "\\begin{tikzpicture}[\n"
36  "pf/.style ={fill=yellow!50,draw=none},%fill particle\n"
37  "pd/.style ={draw=black} %draw particle\n"
38  "]\n";
39 
40  os << "%draw particles' inside\n";
41  for (auto p : dpm.particleHandler)
42  {
43  const Vec3D& pos = p->getPosition()*1e6;
44  const Mdouble& r = p->getRadius()*1e6;
45  os << "\\draw[pf] (" + std::to_string(pos.X)
46  +"," + std::to_string(pos.Z)
47  + ") circle (" + std::to_string(r) +");\n";
48  }
49 
50  os << "%draw particles' outside\n";
51  for (auto p : dpm.particleHandler)
52  {
53  const Vec3D& pos = p->getPosition()*1e6;
54  const Mdouble& r = p->getRadius()*1e6;
55  os << "\\draw[pd] (" + std::to_string(pos.X)
56  +"," + std::to_string(pos.Z)
57  + ") circle (" + std::to_string(r) +");\n";
58  }
59 
60  os << "%draw plastic overlap' outside\n";
61  for (auto i : dpm.interactionHandler)
62  {
63  auto c = dynamic_cast<SinterInteraction*>(i);
64  const Vec3D& cp = c->getContactPoint()*1e6;
65  const Vec3D& n = c->getNormal();
66  const Vec3D t = Vec3D(n.Z,0,-n.X);
67  const Mdouble& po = 0.5*c->getPlasticOverlap()*1e6;
68  const Mdouble& o = 0.5*c->getOverlap()*1e6;
69  const BaseParticle* p = dynamic_cast<BaseParticle*>(c->getP());
70  logger.assert_always(p!= nullptr,"not particle");
71  const Mdouble& r = p->getRadius()*1e6;
72  const Mdouble x = sqrt(2.0*po*r);
73  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;
74  os << "\\draw[pf] ("+ std::to_string(a0.X) +","+ std::to_string(a0.Z)
75  +") -- ("+ std::to_string(a1.X) +","+ std::to_string(a1.Z)
76  +") -- ("+ std::to_string(a2.X) +","+ std::to_string(a2.Z)
77  +") -- ("+ std::to_string(a3.X) +","+ std::to_string(a3.Z)
78  +") -- cycle;\n";
79  os << "\\draw[pd] ("+ std::to_string(a0.X) +","+ std::to_string(a0.Z)
80  +") -- ("+ std::to_string(a3.X) +","+ std::to_string(a3.Z) + ");\n";
81  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;
82  os << "\\draw[pf] ("+ std::to_string(b0.X) +","+ std::to_string(b0.Z)
83  +") -- ("+ std::to_string(b1.X) +","+ std::to_string(b1.Z)
84  +") -- ("+ std::to_string(b2.X) +","+ std::to_string(b2.Z)
85  +") -- ("+ std::to_string(b3.X) +","+ std::to_string(b3.Z)
86  +") -- cycle;\n";
87  os << "\\draw[pd] ("+ std::to_string(b0.X) +","+ std::to_string(b0.Z)
88  +") -- ("+ std::to_string(b3.X) +","+ std::to_string(b3.Z) + ");\n";
89  }
90  os << "\\end{tikzpicture}\n"
91  "\\end{document}";
92 
93  //dpm.setParticlesWriteVTK(true);
94 // dpm.wallHandler.setWriteVTK(FileType::MULTIPLE_FILES);
95 // dpm.solve(argc-1, argv+1);
96  return 0;
97 }
AnnoyingScalar sqrt(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:134
int i
Definition: BiCGSTAB_step_by_step.cpp:9
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
@ NO_FILE
file will not be created/read
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:32
float * p
Definition: Tutorial_Map_using.cpp:9
Definition: BaseParticle.h:33
void setName(const std::string &name)
Allows to set the name of all the files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:400
Mdouble getTimeStep() const
Returns the simulation time step.
Definition: DPMBase.cc:1241
void setRestarted(bool newRestartedFlag)
Allows to set the flag stating if the simulation is to be restarted or not.
Definition: DPMBase.cc:1492
File restartFile
An instance of class File to handle in- and output into a .restart file.
Definition: DPMBase.h:1499
InteractionHandler interactionHandler
An object of the class InteractionHandler.
Definition: DPMBase.h:1473
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created.
Definition: DPMBase.h:1443
void setTimeMax(Mdouble newTMax)
Sets a new value for the maximum simulation duration.
Definition: DPMBase.cc:864
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:3043
void setFileType(FileType fileType)
Sets the type of file needed to write into or read from. File::fileType_.
Definition: File.cc:193
This adds on the hierarchical grid code for 3D problems.
Definition: Mercury3D.h:16
Computes normal forces in case of a linear plastic visco-elastic interaction.
Definition: SinterInteraction.h:19
Definition: Kernel/Math/Vector.h:30
Mdouble Z
Definition: Kernel/Math/Vector.h:45
Mdouble X
the vector components
Definition: Kernel/Math/Vector.h:45
#define INFO(i)
Definition: mumps_solver.h:54
r
Definition: UniformPSDSelfTest.py:20
int c
Definition: calibrate.py:100
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286
std::string to_string(T object, unsigned float_precision=8)
Definition: oomph_utilities.h:189
list x
Definition: plotDoE.py:28
t
Definition: plotPSD.py:36

References calibrate::c, ERROR, DPMBase::getTimeStep(), i, INFO, DPMBase::interactionHandler, logger, n, NO_FILE, p, DPMBase::particleHandler, UniformPSDSelfTest::r, DPMBase::readRestartFile(), DPMBase::restartFile, File::setFileType(), DPMBase::setName(), DPMBase::setRestarted(), DPMBase::setTimeMax(), sqrt(), oomph::Global_string_for_annotation::string(), plotPSD::t, oomph::StringConversion::to_string(), plotDoE::x, Vec3D::X, and Vec3D::Z.