www.mooseframework.org
ExodusFormatter.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
15 // MOOSE includes
16 #include "ExodusFormatter.h"
17 #include "Parser.h"
18 #include "MooseApp.h"
19 #include "SystemInfo.h"
20 #include "CommandLine.h"
21 
22 #include "libmesh/exodusII.h"
23 
24 // C++
25 #include <sstream>
26 #include <vector>
27 
29 
30 void
32 {
33  _ss << "####################\n"
34  << "# Created by MOOSE #\n"
35  << "####################\n";
36 
37  // Grab the command line arguments first
38  _ss << "### Command Line Arguments ###\n";
39  if (wh.mooseApp().commandLine())
40  {
41  auto argc = wh.mooseApp().commandLine()->argc();
42  auto argv = wh.mooseApp().commandLine()->argv();
43  for (int i = 1; i < argc; i++)
44  _ss << " " << argv[i];
45  }
46  if (wh.mooseApp().getSystemInfo() != NULL)
47  {
48  _ss << "### Version Info ###\n" << wh.mooseApp().getSystemInfo()->getInfo() << "\n";
49  }
50 
51  _ss << "### Input File ###" << std::endl;
52  wh.printInputFile(_ss);
53 }
54 
55 void
57 {
58  std::string s;
59  _input_file_record.clear();
60 
61  while (std::getline(_ss, s))
62  {
63  // MAX_LINE_LENGTH is from ExodusII
64  if (s.length() > MAX_LINE_LENGTH)
65  {
66  const std::string continuation("...");
67  const size_t cont_len = continuation.length();
68  size_t num_lines = s.length() / (MAX_LINE_LENGTH - cont_len) + 1;
69  std::string split_line;
70  for (size_t j = 0, l_begin = 0; j < num_lines; ++j, l_begin += MAX_LINE_LENGTH - cont_len)
71  {
72  size_t l_len = MAX_LINE_LENGTH - cont_len;
73  if (s.length() < l_begin + l_len)
74  l_len = s.length() - l_begin;
75 
76  split_line = s.substr(l_begin, l_len);
77 
78  if (l_begin + l_len != s.length())
79  split_line += continuation;
80 
81  _input_file_record.push_back(split_line);
82  }
83  }
84  else
85  _input_file_record.push_back(s);
86  }
87 }
std::vector< std::string > _input_file_record
MooseApp & mooseApp()
const SystemInfo * getSystemInfo() const
Get SystemInfo object.
Definition: MooseApp.h:377
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
std::shared_ptr< CommandLine > commandLine()
Get the command line.
Definition: MooseApp.h:265
std::string getInfo() const
Definition: SystemInfo.C:32
void printInputFile(ActionWarehouse &wh)
This class produces produces a dump of the InputFileParameters that appears like the normal input fil...