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

Functions

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

Function Documentation

◆ ExecCommand()

std::string ExecCommand ( const char cmd)
17  {
18  std::array<char, 256> buffer;
19  std::string result;
20 
21  // Prepare a pipe to write a to execute a systm command and read the result
22  std::unique_ptr<FILE, int(*)(FILE*)> pipe(popen(cmd, "r"), pclose);
23  if (!pipe) {
24  throw std::runtime_error("popen() failed!");
25  }
26  while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr) {
27  result += buffer.data();
28  }
29  return result;
30 }
return int(ret)+1
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286

References int(), and oomph::Global_string_for_annotation::string().

Referenced by main().

◆ main()

int main ( int argc  ,
char argv[] 
)
34 {
35  // Automatic script to clean working directories, recompile the code and post-process the output for Paraview
36  std::string command;
37  std::string name = "Domino";
38 
39  // Remove data for stl sequence (Blender) visualizations
40  command = "rm ClumpSeq.txt";
41  ExecCommand(command.c_str());
42 
43  // Make
44  command = "make " + name;
45  ExecCommand(command.c_str());
46 
47  // Run
48  command = "./" + name;
49  ExecCommand(command.c_str());
50 
51  // Clean the old paraview output directory
52  command = "rm -rf paraview_" + name;
53  ExecCommand(command.c_str());
54 
55  // Create new paraview output directory
56  command = "mkdir paraview_" + name;
57  ExecCommand(command.c_str());
58 
59  // Data2pvd tool run
60  command = "../../../Tools/data2pvd " + name + ".data paraview_" + name + "/" + name;
61  ExecCommand(command.c_str());
62 
63  // Paraview energy data postprocessing tool
64  command = "python " + getMercuryDPMSourceDir() + "/Tools/MClump/PlotEnergies.py " +
65  getMercuryDPMBuildDir() + "/Drivers/Clump/" + name + "/ " + name;
66  ExecCommand(command.c_str());
67  return 0;
68 }
std::string ExecCommand(const char *cmd)
Definition: AutoDomino.cpp:17
const std::string getMercuryDPMSourceDir()
This file is used for generating definitions that give access to CMakeVariables from within a cpp fil...
Definition: Configuration/CMakeDefinitions.cc:10
const std::string getMercuryDPMBuildDir()
Definition: Configuration/CMakeDefinitions.cc:15
string name
Definition: plotDoE.py:33

References ExecCommand(), getMercuryDPMBuildDir(), getMercuryDPMSourceDir(), plotDoE::name, and oomph::Global_string_for_annotation::string().