www.mooseframework.org
Tecplot.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 "Tecplot.h"
17 #include "MooseApp.h"
18 #include "FEProblem.h"
19 #include "MooseMesh.h"
20 
21 #include "libmesh/tecplot_io.h"
22 
23 template <>
26 {
27  // Get the base class parameters
29 
30  // Add binary toggle
31  params.addParam<bool>("binary", false, "Set Tecplot files to output in binary format");
32  params.addParamNamesToGroup("binary", "Advanced");
33 
34  // Add optional parameter to turn on appending to ASCII files
35  params.addParam<bool>(
36  "ascii_append",
37  false,
38  "If true, append to an existing ASCII file rather than creating a new file each time");
39 
40  // Add description for the Tecplot class
41  params.addClassDescription("Object for outputting data in the Tecplot format");
42 
43  // Return the InputParameters
44  return params;
45 }
46 
47 Tecplot::Tecplot(const InputParameters & parameters)
48  : OversampleOutput(parameters),
49  _binary(getParam<bool>("binary")),
50  _ascii_append(getParam<bool>("ascii_append")),
51  _first_time(declareRestartableData<bool>("first_time", true))
52 {
53 #ifndef LIBMESH_HAVE_TECPLOT_API
54  if (_binary)
55  {
57  "Teclplot binary output requested but not available, outputting ASCII format instead.");
58  _binary = false;
59  }
60 #endif
61 }
62 
63 void
64 Tecplot::output(const ExecFlagType & /*type*/)
65 {
66  TecplotIO out(*_mesh_ptr, _binary, time() + _app.getGlobalTimeOffset());
67 
68  // Only set the append flag on the TecplotIO object if the user has
69  // asked for it, and this is not the first time we called output().
70  if (_ascii_append && !_first_time)
71  out.ascii_append() = true;
72 
73  out.write_equation_systems(filename(), *_es_ptr);
74 
75  // If we're not appending, increment the file number. If we are appending,
76  // we'll use the same filename each time.
77  if (_binary || !_ascii_append)
78  _file_num++;
79 
80  // If this was the first time we called output(), the next time will not be
81  // the first time.
82  if (_first_time)
83  _first_time = false;
84 }
85 
86 std::string
88 {
89  std::ostringstream output;
90  output << _file_base;
91 
92  // If not appending, put the padded time step in the filename.
93  if (_binary || !_ascii_append)
94  output << "_" << std::setw(_padding) << std::setprecision(0) << std::setfill('0') << std::right
95  << _file_num;
96 
97  // .plt extension is for binary files
98  // .dat extension is for ASCII files
99  if (_binary)
100  return output.str() + ".plt";
101  else
102  return output.str() + ".dat";
103 }
Based class for providing re-positioning and oversampling support to output objects.
void mooseWarning(Args &&...args) const
Definition: MooseObject.h:89
InputParameters validParams< Tecplot >()
Definition: Tecplot.C:25
MooseMesh * _mesh_ptr
A convenience pointer to the current mesh (reference or displaced depending on "use_displaced") ...
Real getGlobalTimeOffset()
Each App has it&#39;s own local time.
Definition: MooseApp.h:207
virtual Real time() override
Get the output time.
Definition: PetscOutput.C:258
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
std::string _file_base
The base filename from the input paramaters.
Definition: FileOutput.h:87
InputParameters validParams< OversampleOutput >()
unsigned int _padding
Number of digits to pad the extensions.
Definition: FileOutput.h:93
bool & _first_time
True if this is the first time the file has been written to, gets set to false after the first call t...
Definition: Tecplot.h:65
EquationSystems * _es_ptr
Reference the the libMesh::EquationSystems object that contains the data.
Definition: Output.h:180
virtual void output(const ExecFlagType &type) override
Overload the Output::output method, this is required for Tecplot output due to the method utilized fo...
Definition: Tecplot.C:64
bool _ascii_append
Flag for turning on appending to ASCII files.
Definition: Tecplot.h:56
MooseApp & _app
The MooseApp this object is associated with.
Definition: MooseObject.h:108
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...
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an option parameter and a documentation string to the InputParameters object...
unsigned int & _file_num
A file number counter, initialized to 0 (this must be controlled by the child class, see Exodus)
Definition: FileOutput.h:90
ExecFlagType
Execution flags - when is the object executed/evaluated.
Definition: MooseTypes.h:90
Tecplot(const InputParameters &parameters)
Class constructor.
Definition: Tecplot.C:47
virtual std::string filename() override
Returns the current filename, this method handles adding the timestep suffix.
Definition: Tecplot.C:87
bool _binary
Flag for binary output.
Definition: Tecplot.h:53
void addParamNamesToGroup(const std::string &space_delim_names, const std::string group_name)
This method takes a space delimited list of parameter names and adds them to the specified group name...