https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Tecplot.C
Go to the documentation of this file.
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 "Tecplot.h"
12#include "MooseApp.h"
13#include "FEProblem.h"
14#include "MooseMesh.h"
15
16#include "libmesh/tecplot_io.h"
17
19
22{
23 // Get the base class parameters
25
26 // Add binary toggle
27 params.addParam<bool>("binary", false, "Set Tecplot files to output in binary format");
28 params.addParamNamesToGroup("binary", "Advanced");
29
30 // Add optional parameter to turn on appending to ASCII files
31 params.addParam<bool>(
32 "ascii_append",
33 false,
34 "If true, append to an existing ASCII file rather than creating a new file each time");
35
36 // Need a layer of geometric ghosting for mesh serialization
37 params.addRelationshipManager("ElementPointNeighborLayers",
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
48 : SampledOutput(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
63void
65{
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().
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
86std::string
88{
89 std::ostringstream output;
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}
void mooseWarning(Args &&... args)
Emit a warning message with the given stringified, concatenated args.
Definition MooseError.h:345
registerMooseObject("MooseApp", Tecplot)
unsigned int _padding
Number of digits to pad the extensions.
Definition FileOutput.h:83
std::string _file_base
The base filename from the input paramaters.
Definition FileOutput.h:89
unsigned int & _file_num
A file number counter, initialized to 0 (this must be controlled by the child class,...
Definition FileOutput.h:80
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
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...
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object.
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.
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.
Real getGlobalTimeOffset() const
Each App has it's own local time.
Definition MooseApp.h:318
MooseApp & _app
The MOOSE application this is associated with.
Definition MooseBase.h:375
libMesh::EquationSystems * _es_ptr
Reference the the libMesh::EquationSystems object that contains the data.
Definition Output.h:194
MooseMesh * _mesh_ptr
A convenience pointer to the current mesh (reference or displaced depending on "use_displaced")
Definition Output.h:197
virtual Real getOutputTime()
Get the time that will be used for stream/file outputting.
Based class for providing re-positioning and oversampling support to output objects.
static InputParameters validParams()
Class for output data to the TecplotII format.
Definition Tecplot.h:19
virtual std::string filename() override
Returns the current filename, this method handles adding the timestep suffix.
Definition Tecplot.C:87
virtual void output() override
Overload the Output::output method, this is required for Tecplot output due to the method utilized fo...
Definition Tecplot.C:64
Tecplot(const InputParameters &parameters)
Class constructor.
Definition Tecplot.C:47
static InputParameters validParams()
Definition Tecplot.C:21
bool _ascii_append
Flag for turning on appending to ASCII files.
Definition Tecplot.h:48
bool _binary
Flag for binary output.
Definition Tecplot.h:45
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:57