21#include "libmesh/exodusII_io.h"
22#include "libmesh/libmesh_config.h"
39 "Enable/disable sequential file output (enabled by default "
40 "when 'use_displace = true', otherwise defaults to false");
44 "Use the problem dimension to the mesh output. "
45 "Set to false when outputting lower dimensional "
46 "meshes embedded in a higher dimensional space.",
47 "Use 'output_dimension = problem_dimension' instead.");
49 MooseEnum output_dimension(
"default 1 2 3 problem_dimension",
"default");
52 "output_dimension", output_dimension,
"The dimension of the output file");
57 params.
set<
unsigned int>(
"padding") = 3;
65 "When true the latest timestep will overwrite the "
66 "existing file, so only a single timestep exists.");
73 "discontinuous",
false,
"Enables discontinuous output format for Exodus files.");
77 "side_discontinuous",
false,
"Enables adding side-discontinuous output in Exodus files.");
85 params.
addParam<
bool>(
"write_hdf5",
false,
"Enables HDF5 output format for Exodus files.");
101 "32<=max_output_name_length<=80",
102 "Maximum length for names in Exodus file output.");
116 _exodus_initialized(false),
117 _exodus_mesh_changed(declareRestartableData<bool>(
"exodus_mesh_changed", true)),
118 _sequence(isParamValid(
"sequence") ? getParam<bool>(
"sequence")
119 : _use_displaced ? true
121 _exodus_num(declareRestartableData<unsigned
int>(
"exodus_num", 0)),
122 _recovering(_app.isRecovering()),
123 _overwrite(getParam<bool>(
"overwrite")),
125 _discontinuous(getParam<bool>(
"discontinuous")),
126 _side_discontinuous(getParam<bool>(
"side_discontinuous")),
127 _write_hdf5(getParam<bool>(
"write_hdf5")),
128 _max_output_name_length(getParam<unsigned
int>(
"max_output_name_length"))
132 auto use_problem_dimension = getParam<bool>(
"use_problem_dimension");
134 if (use_problem_dimension)
143 ": Invalid parameters. 'elemental_as_nodal' set to false while 'discontinuous' set "
155 "This method is no longer needed. We can determine output dimension programmatically");
167 mooseError(
"The current settings result in nothing being output to the Exodus file.");
173 mooseError(
"The current settings results in only the input file and no variables being output "
174 "to the Exodus file, this is not supported.");
212 auto serialize = [
this](
auto & moose_mesh)
214 auto & lm_mesh = moose_mesh.getMesh();
216 lm_mesh.gather_to_zero();
219 if ((this->
processor_id() == 0) && !lm_mesh.is_replicated())
220 moose_mesh.markFiniteVolumeInfoDirty();
242#ifndef LIBMESH_HAVE_HDF5
243 mooseError(
"Moose input requested HDF Exodus output, but libMesh was built without HDF5.");
300 switch (output_dimension)
324 ::mooseError(
"Unknown output_dimension in Exodus writer");
337 const bool mesh_contiguous_numbering =
351 if (!mesh_contiguous_numbering)
380 for (
const auto &
name : pps)
410 for (
const auto & out_name :
out)
420 const std::vector<dof_id_type> & dof_indices = scalar_var.
dofIndices();
421 const unsigned int n = dof_indices.size();
425 for (
unsigned int i = 0; i != n; ++i)
441 for (
unsigned int i = 0; i < n; ++i)
443 std::ostringstream os;
444 os << out_name <<
"_" << i;
458 syntax_formatter.
format();
513 int err = std::remove(current.c_str());
515 mooseError(
"MOOSE failed to remove the empty file ", current);
523 std::ostringstream
output;
528 output <<
"-s" << std::setw(
_padding) << std::setprecision(0) << std::setfill(
'0') << std::right
539 const bool mesh_contiguous_numbering =
550 if (!mesh_contiguous_numbering)
568 auto & disp_eq = disp_problem->es();
571 !other_mesh.allow_renumbering(),
572 "The only way we shouldn't have contiguous numbering is if we've disabled renumbering");
573 other_mesh.allow_renumbering(
true);
574 other_mesh.renumber_nodes_and_elements();
578 other_mesh.allow_renumbering(
false);
583 false,
false,
false);
registerMooseObject("MooseApp", Exodus)
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
void mooseDeprecated(Args &&... args)
Emit a deprecated code/feature message with the given stringified, concatenated args.
OutputTools< Real >::VariableValue VariableValue
const ExecFlagType EXEC_INITIAL
const ExecFlagType EXEC_FINAL
void ErrorVector unsigned int
virtual bool hasOutput()
Returns true if any of the other has methods return true.
const std::set< std::string > & getReporterOutput()
The list of Reporter names that are set for output.
static InputParameters enableOutputTypes(const std::string &names=std::string())
A method for enabling individual output type control.
virtual void output()
A single call to this function should output all the necessary data for a single timestep.
bool hasElementalVariableOutput()
Returns true if there exists elemental nonlinear variables for output.
const std::set< std::string > & getElementalVariableOutput()
The list of elemental nonlinear variables names that are set for output.
bool hasNodalVariableOutput()
Returns true if there exists nodal nonlinear variables for output.
bool _elemental_as_nodal
Flags to control nodal output.
bool hasPostprocessorOutput()
Returns true if there exists postprocessors for output.
const ReporterData & _reporter_data
Storage for Reporter values.
void clearLastExecuteTime()
Clears bookkeeping used to suppress duplicate EXEC_FINAL output at the same time.
const std::set< std::string > & getNodalVariableOutput()
The list of nodal nonlinear variables names that are set for output.
bool hasScalarOutput()
Returns true if there exists scalar variables for output.
const std::set< std::string > & getScalarOutput()
The list of scalar variables names that are set for output.
const std::set< std::string > & getPostprocessorOutput()
The list of postprocessor names that are set for output.
A MultiMooseEnum object to hold "execute_on" flags.
Class for output data to the ExodusII format.
virtual void sequence(bool state)
Set the sequence state When the sequence state is set to true then the outputSetup() method is called...
OutputDimension _output_dimension
Enum for the output dimension.
virtual void outputSetup()
Performs the necessary deletion and re-creating of ExodusII_IO object.
bool _side_discontinuous
Flag to output added disjoint fictitious sides for side_discontinuous variables.
unsigned int & _exodus_num
Count of outputs per exodus file.
void clear()
Reset Exodus output.
virtual void outputScalarVariables() override
Writes scalar AuxVariables to global output parameters.
std::unique_ptr< libMesh::ExodusII_IO > _exodus_io_ptr
Pointer to the libMesh::ExodusII_IO object that performs the actual data output.
unsigned int _max_output_name_length
Maximum length of untruncated names in Exodus output.
bool & _exodus_mesh_changed
A flag indicating to the Exodus object that the mesh has changed.
virtual std::string filename() override
Returns the current filename, this method handles the -s000 suffix common to ExodusII files.
bool _recovering
Flag indicating MOOSE is recovering via –recover command-line option.
virtual void initialSetup() override
Performs basic error checking and initial setup of ExodusII_IO output object.
static InputParameters validParams()
bool _discontinuous
Flag to output discontinuous format in Exodus.
Exodus(const InputParameters ¶meters)
Class constructor.
void handleExodusIOMeshRenumbering()
Handle the call to mesh renumbering in libmesh's ExodusIO on non-contiguously numbered meshes.
virtual void outputElementalVariables() override
Outputs elemental, nonlinear variables.
bool _exodus_initialized
Flag for indicating the status of the ExodusII file that is being written.
bool _sequence
Sequence flag, if true each timestep is written to a new file.
bool _write_hdf5
Flag to output HDF5 format (when available) in Exodus.
virtual void customizeFileOutput()
Customizes file output settings.
virtual void outputInput() override
Writes the input file to the ExodusII output.
std::vector< std::string > _global_names
Storage for names of the above scalar values.
bool _overwrite
Flag for overwriting timesteps.
virtual void output() override
Overload the OutputBase::output method, this is required for ExodusII output due to the method utiliz...
void outputEmptyTimestep()
A helper function for 'initializing' the ExodusII output file, see the comments for the _initialized ...
void setOutputDimension(unsigned int dim)
Force the output dimension programatically.
virtual void meshChanged() override
Set flag indicating that the mesh has changed.
virtual void outputNodalVariables() override
Outputs nodal, nonlinear variables.
std::vector< Real > _global_values
Storage for scalar values (postprocessors and scalar AuxVariables)
virtual void outputPostprocessors() override
Writes postprocessor values to global output parameters.
std::vector< std::string > _input_record
Storage for input file record; this is written to the file only after it has been initialized.
static void setOutputDimensionInExodusWriter(libMesh::ExodusII_IO &exodus_io, const MooseMesh &mesh, OutputDimension output_dim=OutputDimension::DEFAULT)
Helper method to change the output dimension in the passed in Exodus writer depending on the dimensio...
virtual void outputReporters() override
Writes the Reporter values to the ExodusII output.
virtual MooseVariableScalar & getScalarVariable(const THREAD_ID tid, const std::string &var_name) override
Returns the scalar variable reference from whichever system contains it.
const PostprocessorValue & getPostprocessorValueByName(const PostprocessorName &name, std::size_t t_index=0) const
Get a read-only reference to the value associated with a Postprocessor that exists.
virtual std::shared_ptr< const DisplacedProblem > getDisplacedProblem() const
virtual MooseMesh & mesh() override
virtual void meshChanged(bool intermediate_change, bool contract_mesh, bool clean_refinement_flags)
Update data after a mesh change.
unsigned int _padding
Number of digits to pad the extensions.
std::string _file_base
The base filename from the input paramaters.
unsigned int & _file_num
A file number counter, initialized to 0 (this must be controlled by the child class,...
Gets an exclusive lock on a file.
ActionWarehouse & actionWarehouse()
Return a writable reference to the ActionWarehouse associated with this app.
Point getOutputPosition() const
Get the output position.
bool hasOutputPosition() const
Whether or not an output position has been set.
Real getGlobalTimeOffset() const
Each App has it's own local time.
const InputParameters & parameters() const
Get the parameters of the object.
const std::string & name() const
Get the name of the class.
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
MooseApp & _app
The MOOSE application this is associated with.
virtual const std::vector< dof_id_type > & dofIndices() const
Get local DoF indices.
SystemBase & sys()
Get the system this variable is part of.
Class for scalar variables (they are different).
const VariableValue & sln() const
void reinit(bool reinit_for_derivative_reordering=false)
Fill out the VariableValue arrays from the system solution vector.
FEProblemBase * _problem_ptr
Pointer the the FEProblemBase object for output object (use this)
libMesh::EquationSystems * _es_ptr
Reference the the libMesh::EquationSystems object that contains the data.
MooseMesh * _mesh_ptr
A convenience pointer to the current mesh (reference or displaced depending on "use_displaced")
virtual Real getOutputTime()
Get the time that will be used for stream/file outputting.
bool hasPostprocessorByName(const PostprocessorName &name) const
Determine if the Postprocessor data exists.
bool hasReporterValue(const ReporterName &reporter_name) const
Return True if a Reporter value with the given type and name have been created.
const T & getReporterValue(const ReporterName &reporter_name, const MooseObject &consumer, const ReporterMode &mode, const std::size_t time_index=0) const
Method for returning read only references to Reporter values.
The Reporter system is comprised of objects that can contain any number of data values.
const std::string & getObjectName() const
Return the object name that produces the Reporter value.
const std::string & getValueName() const
Return the data name for the Reporter value.
Based class for providing re-positioning and oversampling support to output objects.
bool _use_sampled_output
Flag indicating that the sampled output should be used to re-sample the underlying EquationSystem of ...
virtual void initialSetup() override
Call init() method on setup.
virtual void meshChanged() override
Called on this object when the mesh changes.
static InputParameters validParams()
const ExecFlagEnum & getExecuteOnEnum() const
Return the execute on MultiMooseEnum for this object.
virtual libMesh::DofMap & dofMap()
Gets writeable reference to the dof map.
void broadcast(T &data, const unsigned int root_id=0, const bool identical_sizes=false) const
processor_id_type dof_owner(const dof_id_type dof) const
const MeshBase & get_mesh() const
void write_as_dimension(unsigned dim)
void use_mesh_dimension_instead_of_spatial_dimension(bool val)
unsigned int mesh_dimension() const
virtual dof_id_type n_elem() const=0
virtual dof_id_type n_nodes() const=0
virtual dof_id_type max_node_id() const=0
virtual dof_id_type max_elem_id() const=0
processor_id_type processor_id() const
const Parallel::Communicator & comm() const
std::size_t fileSize(const std::string &filename)
bool checkFileReadable(const std::string &filename, bool check_line_endings, bool throw_on_unreadable, bool check_for_git_lfs_pointer)
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
OStreamProxy out(std::cout)
OStreamProxy err(std::cerr)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
uint8_t processor_id_type