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 
17 #include "libmesh/exodusII.h"
18 
19 // C++
20 #include <sstream>
21 #include <vector>
22 
24 
25 void
27 {
28  _ss << "####################\n"
29  << "# Created by MOOSE #\n"
30  << "####################\n";
31 
32  // Grab the command line arguments first
33  _ss << "### Command Line Arguments ###\n";
34  if (wh.mooseApp().commandLine())
35  {
36  for (const auto & arg : wh.mooseApp().commandLine()->getArguments())
37  _ss << " " << arg;
38  }
39  if (wh.mooseApp().getSystemInfo() != NULL)
40  {
41  _ss << "### Version Info ###\n" << wh.mooseApp().getSystemInfo()->getInfo() << "\n";
42  }
43 
44  _ss << "### Input File ###" << std::endl;
45  wh.printInputFile(_ss);
46 }
47 
48 void
50 {
51  std::string s;
52  _input_file_record.clear();
53 
54  while (std::getline(_ss, s))
55  {
56  // MAX_LINE_LENGTH is from ExodusII
57  if (s.length() > MAX_LINE_LENGTH)
58  {
59  const std::string continuation("...");
60  const size_t cont_len = continuation.length();
61  size_t num_lines = s.length() / (MAX_LINE_LENGTH - cont_len) + 1;
62  std::string split_line;
63  for (size_t j = 0, l_begin = 0; j < num_lines; ++j, l_begin += MAX_LINE_LENGTH - cont_len)
64  {
65  size_t l_len = MAX_LINE_LENGTH - cont_len;
66  if (s.length() < l_begin + l_len)
67  l_len = s.length() - l_begin;
68 
69  split_line = s.substr(l_begin, l_len);
70 
71  if (l_begin + l_len != s.length())
72  split_line += continuation;
73 
74  _input_file_record.push_back(split_line);
75  }
76  }
77  else
78  _input_file_record.push_back(s);
79  }
80 }
std::vector< std::string > _input_file_record
MooseApp & mooseApp()
std::shared_ptr< CommandLine > commandLine() const
Get the command line.
Definition: MooseApp.h:300
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:423
std::string getInfo() const
Definition: SystemInfo.C:26
void printInputFile(ActionWarehouse &wh)
This class produces produces a dump of the InputFileParameters that appears like the normal input fil...