www.mooseframework.org
ExodusFormatter.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 // MOOSE includes
11 #include "ExodusFormatter.h"
12 #include "Parser.h"
13 #include "MooseApp.h"
14 #include "SystemInfo.h"
15 #include "CommandLine.h"
16 #include "ActionWarehouse.h"
17 
18 #include "libmesh/exodusII.h"
19 
20 // C++
21 #include <sstream>
22 #include <vector>
23 
25 
26 void
28 {
29  _ss << "####################\n"
30  << "# Created by MOOSE #\n"
31  << "####################\n";
32 
33  // Grab the command line arguments first
34  _ss << "### Command Line Arguments ###\n";
35  if (wh.mooseApp().commandLine())
36  {
37  for (const auto & arg : wh.mooseApp().commandLine()->getArguments())
38  _ss << " " << arg;
39  }
40  if (wh.mooseApp().getSystemInfo() != NULL)
41  {
42  _ss << "### Version Info ###\n" << wh.mooseApp().getSystemInfo()->getInfo() << "\n";
43  }
44 
45  _ss << "### Input File ###" << std::endl;
46  wh.printInputFile(_ss);
47 }
48 
49 void
51 {
52  std::string s;
53  _input_file_record.clear();
54 
55  while (std::getline(_ss, s))
56  {
57  // MAX_LINE_LENGTH is from ExodusII
58  if (s.length() > MAX_LINE_LENGTH)
59  {
60  const std::string continuation("...");
61  const size_t cont_len = continuation.length();
62  size_t num_lines = s.length() / (MAX_LINE_LENGTH - cont_len) + 1;
63  std::string split_line;
64  for (size_t j = 0, l_begin = 0; j < num_lines; ++j, l_begin += MAX_LINE_LENGTH - cont_len)
65  {
66  size_t l_len = MAX_LINE_LENGTH - cont_len;
67  if (s.length() < l_begin + l_len)
68  l_len = s.length() - l_begin;
69 
70  split_line = s.substr(l_begin, l_len);
71 
72  if (l_begin + l_len != s.length())
73  split_line += continuation;
74 
75  _input_file_record.push_back(split_line);
76  }
77  }
78  else
79  _input_file_record.push_back(s);
80  }
81 }
std::vector< std::string > _input_file_record
MooseApp & mooseApp()
std::shared_ptr< CommandLine > commandLine() const
Get the command line.
Definition: MooseApp.h:413
Storage for action instances.
void printInputFile(std::ostream &out)
This method uses the Actions in the warehouse to reproduce the input file.
std::stringstream _ss
const SystemInfo * getSystemInfo() const
Get SystemInfo object.
Definition: MooseApp.h:546
std::string getInfo() const
Definition: SystemInfo.C:26
void printInputFile(ActionWarehouse &wh)
This class produces produces a dump of the InputParameters that appears like the normal input file sy...