www.mooseframework.org
VTKOutput.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 #include "VTKOutput.h"
16 
17 #include "libmesh/vtk_io.h"
18 #include "libmesh/equation_systems.h"
19 
20 template <>
23 {
25 
26  // Set default padding to 3
27  params.set<unsigned int>("padding") = 3;
28 
29  // Add binary toggle
30  params.addParam<bool>("binary", false, "Set VTK files to output in binary format");
31  params.addParamNamesToGroup("binary", "Advanced");
32 
33  return params;
34 }
35 
37  : OversampleOutput(parameters), _binary(getParam<bool>("binary"))
38 {
39 }
40 
41 void
43 {
44 #ifdef LIBMESH_HAVE_VTK
45 
47  VTKIO vtk(_es_ptr->get_mesh());
48 
49  // Set the comppression
50  vtk.set_compression(_binary);
51 
52  // Write the data
53  vtk.write_equation_systems(filename(), *_es_ptr);
54  _file_num++;
55 
56 #else
57  mooseError("libMesh not configured with VTK");
58 #endif
59 }
60 
61 std::string
63 {
64  // Append the .e extension on the base file name
65  std::ostringstream output;
66  output << _file_base;
67 
68  // In serial, add the _00x.vtk extension.
69  // In parallel, add the _00x.pvtu extension.
70  std::string ext = (n_processors() == 1) ? ".vtk" : ".pvtu";
71  output << "_" << std::setw(_padding) << std::setfill('0') << std::right << _file_num << ext;
72 
73  // Return the filename
74  return output.str();
75 }
Based class for providing re-positioning and oversampling support to output objects.
InputParameters validParams< VTKOutput >()
Definition: VTKOutput.C:22
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
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 >()
bool _binary
Flag for using binary compression.
Definition: VTKOutput.h:52
unsigned int _padding
Number of digits to pad the extensions.
Definition: FileOutput.h:93
virtual std::string filename() override
Return the file name with the *.vtk extension.
Definition: VTKOutput.C:62
EquationSystems * _es_ptr
Reference the the libMesh::EquationSystems object that contains the data.
Definition: Output.h:180
virtual void output(const ExecFlagType &type) override
Perform the output of VTKOutput.
Definition: VTKOutput.C:42
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...
void mooseError(Args &&...args) const
Definition: MooseObject.h:80
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
VTKOutput(const InputParameters &parameters)
Class constructor.
Definition: VTKOutput.C:36
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...