www.mooseframework.org
Tecplot.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 "Tecplot.h"
12 #include "MooseApp.h"
13 #include "FEProblem.h"
14 #include "MooseMesh.h"
15 
16 #include "libmesh/tecplot_io.h"
17 
18 registerMooseObject("MooseApp", Tecplot);
19 
20 template <>
23 {
24  // Get the base class parameters
26 
27  // Add binary toggle
28  params.addParam<bool>("binary", false, "Set Tecplot files to output in binary format");
29  params.addParamNamesToGroup("binary", "Advanced");
30 
31  // Add optional parameter to turn on appending to ASCII files
32  params.addParam<bool>(
33  "ascii_append",
34  false,
35  "If true, append to an existing ASCII file rather than creating a new file each time");
36 
37  // Need a layer of geometric ghosting for mesh serialization
38  params.addRelationshipManager("MooseGhostPointNeighbors",
40 
41  // Add description for the Tecplot class
42  params.addClassDescription("Object for outputting data in the Tecplot format");
43 
44  // Return the InputParameters
45  return params;
46 }
47 
48 Tecplot::Tecplot(const InputParameters & parameters)
49  : OversampleOutput(parameters),
50  _binary(getParam<bool>("binary")),
51  _ascii_append(getParam<bool>("ascii_append")),
52  _first_time(declareRestartableData<bool>("first_time", true))
53 {
54 #ifndef LIBMESH_HAVE_TECPLOT_API
55  if (_binary)
56  {
58  "Teclplot binary output requested but not available, outputting ASCII format instead.");
59  _binary = false;
60  }
61 #endif
62 }
63 
64 void
65 Tecplot::output(const ExecFlagType & /*type*/)
66 {
67  TecplotIO out(*_mesh_ptr, _binary, time() + _app.getGlobalTimeOffset());
68 
69  // Only set the append flag on the TecplotIO object if the user has
70  // asked for it, and this is not the first time we called output().
71  if (_ascii_append && !_first_time)
72  out.ascii_append() = true;
73 
74  out.write_equation_systems(filename(), *_es_ptr);
75 
76  // If we're not appending, increment the file number. If we are appending,
77  // we'll use the same filename each time.
78  if (_binary || !_ascii_append)
79  _file_num++;
80 
81  // If this was the first time we called output(), the next time will not be
82  // the first time.
83  if (_first_time)
84  _first_time = false;
85 }
86 
87 std::string
89 {
90  std::ostringstream output;
91  output << _file_base;
92 
93  // If not appending, put the padded time step in the filename.
94  if (_binary || !_ascii_append)
95  output << "_" << std::setw(_padding) << std::setprecision(0) << std::setfill('0') << std::right
96  << _file_num;
97 
98  // .plt extension is for binary files
99  // .dat extension is for ASCII files
100  if (_binary)
101  return output.str() + ".plt";
102  else
103  return output.str() + ".dat";
104 }
Based class for providing re-positioning and oversampling support to output objects.
registerMooseObject("MooseApp", Tecplot)
InputParameters validParams< Tecplot >()
Definition: Tecplot.C:22
void mooseWarning(Args &&... args) const
Definition: MooseObject.h:155
virtual Real time() override
Get the output time.
Definition: PetscOutput.C:253
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:81
InputParameters validParams< OversampleOutput >()
void addRelationshipManager(const std::string &name, Moose::RelationshipManagerType rm_type, Moose::RelationshipManagerInputParameterCallback input_parameter_callback=nullptr)
Tells MOOSE about a RelationshipManager that this object needs.
unsigned int _padding
Number of digits to pad the extensions.
Definition: FileOutput.h:87
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:59
EquationSystems * _es_ptr
Reference the the libMesh::EquationSystems object that contains the data.
Definition: Output.h:176
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:65
bool _ascii_append
Flag for turning on appending to ASCII files.
Definition: Tecplot.h:50
Class for output data to the TecplotII format.
Definition: Tecplot.h:24
Class for containing MooseEnum item information.
Definition: MooseEnumItem.h:21
MooseApp & _app
The MooseApp this object is associated with.
Definition: MooseObject.h:177
MooseMesh * _mesh_ptr
A convenience pointer to the current mesh (reference or displaced depending on "use_displaced") ...
Definition: Output.h:179
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:84
Real getGlobalTimeOffset() const
Each App has it&#39;s own local time.
Definition: MooseApp.h:229
Tecplot(const InputParameters &parameters)
Class constructor.
Definition: Tecplot.C:48
virtual std::string filename() override
Returns the current filename, this method handles adding the timestep suffix.
Definition: Tecplot.C:88
bool _binary
Flag for binary output.
Definition: Tecplot.h:47
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...