www.mooseframework.org
XDA.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 "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 registerMooseObject("MooseApp", XDA);
20 registerMooseObjectAliased("MooseApp", XDA, "XDR");
21 
23 
26 {
27  // Get the base class parameters
29 
30  // Add description for the XDA class
31  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  params.addPrivateParam<bool>("_binary", false);
36 
37  // Return the InputParameters
38  return params;
39 }
40 
41 XDA::XDA(const InputParameters & parameters)
42  : OversampleOutput(parameters), _binary(getParam<bool>("_binary"))
43 {
44 }
45 
46 void
47 XDA::output(const ExecFlagType & /*type*/)
48 {
49  // Strings for the two filenames to be written
50  std::string es_name = filename();
51  std::string mesh_name = es_name;
52 
53  // Make sure the filename has an extension
54  if (es_name.size() < 4)
55  mooseError("Unacceptable filename, you must include an extension (.xda or .xdr).");
56 
57  // Insert the mesh suffix
58  mesh_name.insert(mesh_name.size() - 4, "_mesh");
59 
60  // Set the binary flag
61  XdrMODE mode = _binary ? ENCODE : WRITE;
62 
63  // Write the files
64  _mesh_ptr->getMesh().write(mesh_name);
65  _es_ptr->write(
66  es_name, mode, EquationSystems::WRITE_DATA | EquationSystems::WRITE_ADDITIONAL_DATA);
67  _file_num++;
68 }
69 
70 std::string
72 {
73  // Append the padded time step to the file base
74  std::ostringstream output;
75  output << _file_base << "_" << std::setw(_padding) << std::setprecision(0) << std::setfill('0')
76  << std::right << _file_num;
77 
78  if (_binary)
79  output << ".xdr";
80  else
81  output << ".xda";
82  return output.str();
83 }
MooseMesh.h
FEProblem.h
FileOutput::_file_num
unsigned int & _file_num
A file number counter, initialized to 0 (this must be controlled by the child class,...
Definition: FileOutput.h:75
MooseObject::mooseError
void mooseError(Args &&... args) const
Definition: MooseObject.h:141
registerMooseObjectAliased
registerMooseObjectAliased("MooseApp", XDA, "XDR")
XDA::filename
virtual std::string filename() override
Returns the current filename, this method handles adding the timestep suffix.
Definition: XDA.C:71
defineLegacyParams
defineLegacyParams(XDA)
XDA::XDA
XDA(const InputParameters &parameters)
Class consturctor.
Definition: XDA.C:41
Output::_es_ptr
EquationSystems * _es_ptr
Reference the the libMesh::EquationSystems object that contains the data.
Definition: Output.h:178
XDA::validParams
static InputParameters validParams()
Definition: XDA.C:25
XDA
Class for output data to the XDAII format.
Definition: XDA.h:24
InputParameters
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
Definition: InputParameters.h:53
XDA::_binary
bool _binary
Flag for binary output.
Definition: XDA.h:49
MooseApp.h
MooseMesh::getMesh
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
Definition: MooseMesh.C:2599
OversampleOutput::validParams
static InputParameters validParams()
Definition: OversampleOutput.C:26
InputParameters::addClassDescription
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump.
Definition: InputParameters.C:70
registerMooseObject
registerMooseObject("MooseApp", XDA)
MooseEnumItem
Class for containing MooseEnum item information.
Definition: MooseEnumItem.h:21
Output::_mesh_ptr
MooseMesh * _mesh_ptr
A convenience pointer to the current mesh (reference or displaced depending on "use_displaced")
Definition: Output.h:181
XDA::output
virtual void output(const ExecFlagType &type) override
Overload the Output::output method, this is required for XDA output due to the method utlized for out...
Definition: XDA.C:47
FileOutput::_padding
unsigned int _padding
Number of digits to pad the extensions.
Definition: FileOutput.h:78
InputParameters::addPrivateParam
void addPrivateParam(const std::string &name, const T &value)
These method add a parameter to the InputParameters object which can be retrieved like any other para...
Definition: InputParameters.h:1308
FileOutput::_file_base
std::string _file_base
The base filename from the input paramaters.
Definition: FileOutput.h:72
XDA.h
OversampleOutput
Based class for providing re-positioning and oversampling support to output objects.
Definition: OversampleOutput.h:42