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.");
97 _exodus_initialized(false),
98 _exodus_mesh_changed(declareRestartableData<bool>(
"exodus_mesh_changed", true)),
99 _sequence(isParamValid(
"sequence") ? getParam<bool>(
"sequence")
100 : _use_displaced ? true
102 _exodus_num(declareRestartableData<unsigned
int>(
"exodus_num", 0)),
103 _recovering(_app.isRecovering()),
104 _overwrite(getParam<bool>(
"overwrite")),
106 _discontinuous(getParam<bool>(
"discontinuous")),
107 _side_discontinuous(getParam<bool>(
"side_discontinuous")),
108 _write_hdf5(getParam<bool>(
"write_hdf5"))
112 auto use_problem_dimension = getParam<bool>(
"use_problem_dimension");
114 if (use_problem_dimension)
123 ": Invalid parameters. 'elemental_as_nodal' set to false while 'discontinuous' set " 135 "This method is no longer needed. We can determine output dimension programmatically");
147 mooseError(
"The current settings result in nothing being output to the Exodus file.");
153 mooseError(
"The current settings results in only the input file and no variables being output " 154 "to the Exodus file, this is not supported.");
192 auto serialize = [
this](
auto & moose_mesh)
194 auto & lm_mesh = moose_mesh.getMesh();
196 lm_mesh.gather_to_zero();
199 if ((this->
processor_id() == 0) && !lm_mesh.is_replicated())
200 moose_mesh.markFiniteVolumeInfoDirty();
222 #ifndef LIBMESH_HAVE_HDF5 223 mooseError(
"Moose input requested HDF Exodus output, but libMesh was built without HDF5.");
278 switch (output_dimension)
302 ::mooseError(
"Unknown output_dimension in Exodus writer");
315 const bool mesh_contiguous_numbering =
329 if (!mesh_contiguous_numbering)
358 for (
const auto &
name : pps)
388 for (
const auto & out_name :
out)
398 const std::vector<dof_id_type> & dof_indices = scalar_var.
dofIndices();
399 const unsigned int n = dof_indices.size();
403 for (
unsigned int i = 0; i != n; ++i)
419 for (
unsigned int i = 0; i < n; ++i)
421 std::ostringstream
os;
422 os << out_name <<
"_" << i;
436 syntax_formatter.
format();
491 int err = std::remove(current.c_str());
493 mooseError(
"MOOSE failed to remove the empty file ", current);
501 std::ostringstream
output;
506 output <<
"-s" << std::setw(
_padding) << std::setprecision(0) << std::setfill(
'0') << std::right
517 const bool mesh_contiguous_numbering =
528 if (!mesh_contiguous_numbering)
545 auto & disp_eq = disp_problem->es();
548 !other_mesh.allow_renumbering(),
549 "The only way we shouldn't have contiguous numbering is if we've disabled renumbering");
551 other_mesh.renumber_nodes_and_elements();
555 other_mesh.allow_renumbering(
false);
560 false,
false,
false);
const std::set< std::string > & getPostprocessorOutput()
The list of postprocessor names that are set for output.
virtual void meshChanged(bool intermediate_change, bool contract_mesh, bool clean_refinement_flags)
Update data after a mesh change.
bool _use_sampled_output
Flag indicating that the sampled output should be used to re-sample the underlying EquationSystem of ...
void use_mesh_dimension_instead_of_spatial_dimension(bool val)
virtual void outputReporters() override
Writes the Reporter values to the ExodusII output.
bool hasPostprocessorOutput()
Returns true if there exists postprocessors for output.
virtual bool hasOutput()
Returns true if any of the other has methods return true.
A MultiMooseEnum object to hold "execute_on" flags.
std::vector< std::string > _input_record
Storage for input file record; this is written to the file only after it has been initialized...
void write_as_dimension(unsigned dim)
void mooseDeprecated(Args &&... args) const
processor_id_type dof_owner(const dof_id_type dof) const
virtual void sequence(bool state)
Set the sequence state When the sequence state is set to true then the outputSetup() method is called...
bool hasOutputPosition() const
Whether or not an output position has been set.
void allow_renumbering(bool allow)
void reinit(bool reinit_for_derivative_reordering=false)
Fill out the VariableValue arrays from the system solution vector.
virtual void meshChanged() override
Set flag indicating that the mesh has changed.
virtual void output() override
Overload the OutputBase::output method, this is required for ExodusII output due to the method utiliz...
std::unique_ptr< libMesh::ExodusII_IO > _exodus_io_ptr
Pointer to the libMesh::ExodusII_IO object that performs the actual data output.
bool _write_hdf5
Flag to output HDF5 format (when available) in Exodus.
bool _elemental_as_nodal
Flags to control nodal output.
const Parallel::Communicator & comm() const
virtual std::string filename() override
Returns the current filename, this method handles the -s000 suffix common to ExodusII files...
std::string _file_base
The base filename from the input paramaters.
bool _overwrite
Flag for overwriting timesteps.
virtual void output()
A single call to this function should output all the necessary data for a single timestep.
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
std::basic_ostream< charT, traits > * os
void clear()
Reset Exodus output.
bool _side_discontinuous
Flag to output added disjoint fictitious sides for side_discontinuous variables.
virtual void outputNodalVariables() override
Outputs nodal, nonlinear variables.
OutputDimension _output_dimension
Enum for the output dimension.
bool _discontinuous
Flag to output discontinuous format in Exodus.
virtual const std::string & name() const
Get the name of the class.
Based class for providing re-positioning and oversampling support to output objects.
bool _exodus_initialized
Flag for indicating the status of the ExodusII file that is being written.
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
static InputParameters validParams()
unsigned int _padding
Number of digits to pad the extensions.
const std::set< std::string > & getReporterOutput()
The list of Reporter names that are set for output.
uint8_t processor_id_type
virtual libMesh::DofMap & dofMap()
Gets writeable reference to the dof map.
void setOutputDimension(unsigned int dim)
Force the output dimension programatically.
bool hasNodalVariableOutput()
Returns true if there exists nodal nonlinear variables for output.
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
const std::set< std::string > & getScalarOutput()
The list of scalar variables names that are set for output.
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
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.
bool hasPostprocessorByName(const PostprocessorName &name) const
Determine if the Postprocessor data exists.
bool _recovering
Flag indicating MOOSE is recovering via –recover command-line option.
bool & _exodus_mesh_changed
A flag indicating to the Exodus object that the mesh has changed.
Class for output data to the ExodusII format.
const ExecFlagEnum & getExecuteOnEnum() const
Return the execute on MultiMooseEnum for this object.
bool checkFileReadable(const std::string &filename, bool check_line_endings=false, bool throw_on_unreadable=true, bool check_for_git_lfs_pointer=true)
Checks to see if a file is readable (exists and permissions)
FEProblemBase * _problem_ptr
Pointer the the FEProblemBase object for output object (use this)
virtual dof_id_type max_elem_id() const=0
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
virtual MooseVariableScalar & getScalarVariable(const THREAD_ID tid, const std::string &var_name) override
Returns the scalar variable reference from whichever system contains it.
virtual const std::vector< dof_id_type > & dofIndices() const
Get local DoF indices.
std::vector< std::string > _global_names
Storage for names of the above scalar values.
std::size_t fileSize(const std::string &filename)
Check the file size.
Exodus(const InputParameters ¶meters)
Class constructor.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
bool hasScalarOutput()
Returns true if there exists scalar variables for output.
ActionWarehouse & actionWarehouse()
Return a writable reference to the ActionWarehouse associated with this app.
virtual void meshChanged() override
Called on this object when the mesh changes.
MooseApp & _app
The MOOSE application this is associated with.
std::vector< Real > _global_values
Storage for scalar values (postprocessors and scalar AuxVariables)
const std::string & getObjectName() const
Return the object name that produces the Reporter value.
unsigned int & _exodus_num
Count of outputs per exodus file.
static InputParameters enableOutputTypes(const std::string &names=std::string())
A method for enabling individual output type control.
bool hasElementalVariableOutput()
Returns true if there exists elemental nonlinear variables for output.
bool _sequence
Sequence flag, if true each timestep is written to a new file.
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.
void broadcast(T &data, const unsigned int root_id=0, const bool identical_sizes=false) const
Point getOutputPosition() const
Get the output position.
const ReporterData & _reporter_data
Storage for Reporter values.
virtual void outputElementalVariables() override
Outputs elemental, nonlinear variables.
OutputTools< Real >::VariableValue VariableValue
void outputEmptyTimestep()
A helper function for 'initializing' the ExodusII output file, see the comments for the _initialized ...
virtual void outputSetup()
Performs the necessary deletion and re-creating of ExodusII_IO object.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual std::shared_ptr< const DisplacedProblem > getDisplacedProblem() const
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...
libMesh::EquationSystems * _es_ptr
Reference the the libMesh::EquationSystems object that contains the data.
const MeshBase & get_mesh() const
virtual void outputInput() override
Writes the input file to the ExodusII output.
Class for scalar variables (they are different).
virtual MooseMesh & mesh() override
MooseMesh * _mesh_ptr
A convenience pointer to the current mesh (reference or displaced depending on "use_displaced") ...
unsigned int mesh_dimension() const
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
const std::set< std::string > & getElementalVariableOutput()
The list of elemental nonlinear variables names that are set for output.
const InputParameters & parameters() const
Get the parameters of the object.
virtual void outputScalarVariables() override
Writes scalar AuxVariables to global output parameters.
bool hasReporterValue(const ReporterName &reporter_name) const
Return True if a Reporter value with the given type and name have been created.
unsigned int & _file_num
A file number counter, initialized to 0 (this must be controlled by the child class, see Exodus)
const std::set< std::string > & getNodalVariableOutput()
The list of nodal nonlinear variables names that are set for output.
Gets an exclusive lock on a file.
virtual void customizeFileOutput()
Customizes file output settings.
const std::string & getValueName() const
Return the data name for the Reporter value.
virtual dof_id_type max_node_id() const=0
virtual dof_id_type n_elem() const=0
processor_id_type processor_id() const
SystemBase & sys()
Get the system this variable is part of.
Real getGlobalTimeOffset() const
Each App has it's own local time.
const ExecFlagType EXEC_FINAL
static InputParameters validParams()
const VariableValue & sln() const
virtual void outputPostprocessors() override
Writes postprocessor values to global output parameters.
virtual Real getOutputTime()
Get the time that will be used for stream/file outputting.
void ErrorVector unsigned int
The Reporter system is comprised of objects that can contain any number of data values.
virtual dof_id_type n_nodes() const=0
registerMooseObject("MooseApp", Exodus)
void handleExodusIOMeshRenumbering()
Handle the call to mesh renumbering in libmesh's ExodusIO on non-contiguously numbered meshes...
virtual void initialSetup() override
Performs basic error checking and initial setup of ExodusII_IO output object.
virtual void initialSetup() override
Call init() method on setup.
const ExecFlagType EXEC_INITIAL