LCOV - code coverage report
Current view: top level - src/outputs - XDA.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 27 29 93.1 %
Date: 2025-07-17 01:28:37 Functions: 4 4 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 "XDA.h"
      12             : #include "MooseApp.h"
      13             : #include "FEProblem.h"
      14             : #include "MooseMesh.h"
      15             : 
      16             : // libMesh includes
      17             : #include "libmesh/enum_xdr_mode.h"
      18             : 
      19             : using namespace libMesh;
      20             : 
      21             : registerMooseObject("MooseApp", XDA);
      22             : registerMooseObjectAliased("MooseApp", XDA, "XDR");
      23             : 
      24             : InputParameters
      25       28894 : XDA::validParams()
      26             : {
      27             :   // Get the base class parameters
      28       28894 :   InputParameters params = SampledOutput::validParams();
      29             : 
      30             :   // Add description for the XDA class
      31       28894 :   params.addClassDescription("Object for outputting data in the XDA/XDR format.");
      32             : 
      33             :   /* Set a private parameter for controlling the output type (XDR = binary), the value
      34             :      of this parameter is set by the AddOutputAction*/
      35       28894 :   params.addPrivateParam<bool>("_binary", false);
      36             : 
      37             :   // Return the InputParameters
      38       28894 :   return params;
      39           0 : }
      40             : 
      41         172 : XDA::XDA(const InputParameters & parameters)
      42         172 :   : SampledOutput(parameters), _binary(getParam<bool>("_binary"))
      43             : {
      44         172 : }
      45             : 
      46             : void
      47         407 : XDA::output()
      48             : {
      49             :   // Strings for the two filenames to be written
      50         407 :   std::string es_name = filename();
      51         407 :   std::string mesh_name = es_name;
      52             : 
      53             :   // Make sure the filename has an extension
      54         407 :   if (es_name.size() < 4)
      55           0 :     mooseError("Unacceptable filename, you must include an extension (.xda or .xdr).");
      56             : 
      57             :   // Insert the mesh suffix
      58         407 :   mesh_name.insert(mesh_name.size() - 4, "_mesh");
      59             : 
      60             :   // Set the binary flag
      61         407 :   XdrMODE mode = _binary ? ENCODE : WRITE;
      62             : 
      63             :   // Write the files
      64         407 :   _mesh_ptr->getMesh().write(mesh_name);
      65         407 :   _es_ptr->write(
      66             :       es_name, mode, EquationSystems::WRITE_DATA | EquationSystems::WRITE_ADDITIONAL_DATA);
      67         407 :   _file_num++;
      68         407 : }
      69             : 
      70             : std::string
      71         579 : XDA::filename()
      72             : {
      73             :   // Append the padded time step to the file base
      74         579 :   std::ostringstream output;
      75         579 :   output << _file_base << "_" << std::setw(_padding) << std::setprecision(0) << std::setfill('0')
      76         579 :          << std::right << _file_num;
      77             : 
      78         579 :   if (_binary)
      79         181 :     output << ".xdr";
      80             :   else
      81         398 :     output << ".xda";
      82        1158 :   return output.str();
      83         579 : }

Generated by: LCOV version 1.14