#include #include #include #include "ChemPlugin.h" void open_input(std::ifstream& input, int argc, char** argv) { while (!input.is_open()) { std::string filename; if (argc < 2) { std::cout << "Enter React input script: "; std::cin >> filename; std::cin.ignore(); } else { filename = argv[1]; } input.open(filename); if (!input.is_open()) std::cerr << "The input file does not exist" << std::endl; } } int main(int argc, char** argv) { std::cout << "mReact -- Use ChemPlugin to emulate React" << std::endl << std::endl; // Create a ChemPlugin instance and capture output messages. ChemPlugin cp("stdout"); // Use React's default settings; write print- and plot-format output. cp.Config("delxi = 0.01; step_increase = 1.5; pluses = banner"); cp.Config("print = on; plot = on"); // Process input line-by-line while watching for "go" statements. std::ifstream input; open_input(input, argc, argv); while (!input.eof()) { std::string line; std::getline(input, line); if (line != "go" ) { cp.Config(line); } else { cp.Initialize(); while (true) { // Time marching loop. double deltat = cp.ReportTimeStep(); if (cp.AdvanceTimeStep(deltat)) break; if (cp.AdvanceHeatTransport()) break; if (cp.AdvanceChemical()) break; } } } // Any keystroke closes the console. std::cin.get(); return 0; }