AutoDomino.cpp File Reference
#include <cstdio>
#include <iostream>
#include <memory>
#include <stdexcept>
#include <string>
#include <array>
#include <CMakeDefinitions.h>

Functions

std::string exec_command (const char *cmd)
 
int main (int argc, char *argv[])
 

Function Documentation

◆ exec_command()

std::string exec_command ( const char cmd)
38  {
39  std::array<char, 256> buffer;
40  std::string result;
41 
42  // Prepare a pipe to write a to execute a systm command and read the result
43  std::unique_ptr<FILE, decltype(&pclose)> pipe(popen(cmd, "r"), pclose);
44  if (!pipe) {
45  throw std::runtime_error("popen() failed!");
46  }
47  while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr) {
48  result += buffer.data();
49  }
50  return result;
51 }

Referenced by main().

◆ main()

int main ( int argc  ,
char argv[] 
)
55 {
56  // Automatic script to clean working directories, recompile the code and post-process the output for Paraview
57  std::string command;
58  std::string name = "Domino";
59 
60  // Remove data for stl sequence (Blender) visualizations
61  command = "rm ClumpSeq.txt";
62  exec_command(command.c_str());
63 
64  // Make
65  command = "make " + name;
66  exec_command(command.c_str());
67 
68  // Run
69  command = "./" + name;
70  exec_command(command.c_str());
71 
72  // Clean the old paraview output directory
73  command = "rm -rf paraview_" + name;
74  exec_command(command.c_str());
75 
76  // Create new paraview output directory
77  command = "mkdir paraview_" + name;
78  exec_command(command.c_str());
79 
80  // Data2pvd tool run
81  command = "../../../Tools/data2pvd " + name + ".data paraview_" + name + "/" + name;
82  exec_command(command.c_str());
83 
84  // Paraview energy data postprocessing tool
85  command = "python " + getMercuryDPMSourceDir() + "/Tools/MClump/PlotEnergies.py " +
86  getMercuryDPMBuildDir() + "/Drivers/Clump/" + name + "/ " + name;
87  exec_command(command.c_str());
88  return 0;
89 }
std::string exec_command(const char *cmd)
Definition: AutoDomino.cpp:38
const std::string getMercuryDPMSourceDir()
This file is used for generating definitions that give access to CMakeVariables from within a cpp fil...
Definition: CMakeDefinitions.cc:32
const std::string getMercuryDPMBuildDir()
Definition: CMakeDefinitions.cc:37
std::string name
Definition: MercuryProb.h:48

References exec_command(), getMercuryDPMBuildDir(), getMercuryDPMSourceDir(), and units::name.