https://mooseframework.inl.gov
Loading...
Searching...
No Matches
VTKOutput.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#include "VTKOutput.h"
11
12#include "libmesh/vtk_io.h"
13#include "libmesh/equation_systems.h"
14
16
19{
21 params.addClassDescription("Output data using the Visualization Toolkit (VTK).");
22
23 // Set default padding to 3
24 params.set<unsigned int>("padding") = 3;
25
26 // Add binary toggle
27 params.addParam<bool>("binary", false, "Set VTK files to output in binary format");
28 params.addParamNamesToGroup("binary", "Advanced");
29
30 return params;
31}
32
34 : SampledOutput(parameters), _binary(getParam<bool>("binary"))
35{
36#ifndef LIBMESH_HAVE_VTK
37 mooseError("VTK output was requested, but libMesh was not configured with VTK. To fix this, you "
38 "must reconfigure libMesh to use VTK.");
39#endif
40}
41
42void
44{
45#ifdef LIBMESH_HAVE_VTK
48
49 // Set the comppression
51
52 // Write the data
54 _file_num++;
55#endif
56}
57
58std::string
60{
61 // Append the .e extension on the base file name
62 std::ostringstream output;
64
65 // In parallel, add the _00x.pvtu extension.
66 // In serial, add the _00x.pvtu extension anyway - libMesh outputs
67 // PVTU format regardless of what file name we give it.
68 const std::string ext = ".pvtu";
69 output << "_" << std::setw(_padding) << std::setfill('0') << std::right << _file_num << ext;
70
71 // Return the filename
72 return output.str();
73}
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
registerMooseObjectAliased("MooseApp", VTKOutput, "VTK")
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 addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump.
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
libMesh::EquationSystems * _es_ptr
Reference the the libMesh::EquationSystems object that contains the data.
Definition Output.h:194
Based class for providing re-positioning and oversampling support to output objects.
static InputParameters validParams()
VTKOutput(const InputParameters &parameters)
Class constructor.
Definition VTKOutput.C:33
static InputParameters validParams()
Definition VTKOutput.C:18
virtual void output() override
Perform the output of VTKOutput.
Definition VTKOutput.C:43
virtual std::string filename() override
Return the file name with the *.vtk extension.
Definition VTKOutput.C:59
bool _binary
Flag for using binary compression.
Definition VTKOutput.h:44
const MeshBase & get_mesh() const
virtual void write_equation_systems(const std::string &, const EquationSystems &, const std::set< std::string > *system_names=nullptr)
void set_compression(bool b)