LCOV - code coverage report
Current view: top level - src/outputs/formatters - ExodusFormatter.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 27 27 100.0 %
Date: 2025-07-17 01:28:37 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //* This file is part of the MOOSE framework
       2             : //* https://mooseframework.inl.gov
       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             : #include "ConsoleUtils.h"
      18             : 
      19             : #include "libmesh/exodusII.h"
      20             : 
      21             : // C++
      22             : #include <sstream>
      23             : #include <vector>
      24             : 
      25       31628 : ExodusFormatter::ExodusFormatter() : InputFileFormatter(false) {}
      26             : 
      27             : void
      28       31628 : ExodusFormatter::printInputFile(ActionWarehouse & wh)
      29             : {
      30             :   _ss << "####################\n"
      31             :       << "# Created by MOOSE #\n"
      32       31628 :       << "####################\n";
      33             : 
      34             :   // write Console output header info
      35       31628 :   _ss << ConsoleUtils::outputFrameworkInformation(wh.mooseApp());
      36             : 
      37             :   // write input file syntax
      38       31628 :   _ss << "### Input File ###" << std::endl;
      39       31628 :   wh.printInputFile(_ss);
      40       31628 : }
      41             : 
      42             : void
      43       31628 : ExodusFormatter::format()
      44             : {
      45       31628 :   std::string s;
      46       31628 :   _input_file_record.clear();
      47             : 
      48    20014537 :   while (std::getline(_ss, s))
      49             :   {
      50             :     // MAX_LINE_LENGTH is from ExodusII
      51    19982909 :     if (s.length() > MAX_LINE_LENGTH)
      52             :     {
      53      114263 :       const std::string continuation("...");
      54      114263 :       const size_t cont_len = continuation.length();
      55      114263 :       size_t num_lines = s.length() / (MAX_LINE_LENGTH - cont_len) + 1;
      56      114263 :       std::string split_line;
      57      343714 :       for (size_t j = 0, l_begin = 0; j < num_lines; ++j, l_begin += MAX_LINE_LENGTH - cont_len)
      58             :       {
      59      229451 :         size_t l_len = MAX_LINE_LENGTH - cont_len;
      60      229451 :         if (s.length() < l_begin + l_len)
      61      114263 :           l_len = s.length() - l_begin;
      62             : 
      63      229451 :         split_line = s.substr(l_begin, l_len);
      64             : 
      65      229451 :         if (l_begin + l_len != s.length())
      66      115129 :           split_line += continuation;
      67             : 
      68      229451 :         _input_file_record.push_back(split_line);
      69             :       }
      70      114263 :     }
      71             :     else
      72    19868646 :       _input_file_record.push_back(s);
      73             :   }
      74       31628 : }

Generated by: LCOV version 1.14