21 #include "libmesh/exodusII_io.h" 22 #include "libmesh/libmesh_config.h" 37 "Enable/disable sequential file output (enabled by default " 38 "when 'use_displace = true', otherwise defaults to false");
42 "Use the problem dimension to the mesh output. " 43 "Set to false when outputting lower dimensional " 44 "meshes embedded in a higher dimensional space.",
45 "Use 'output_dimension = problem_dimension' instead.");
47 MooseEnum output_dimension(
"default 1 2 3 problem_dimension",
"default");
50 "output_dimension", output_dimension,
"The dimension of the output file");
55 params.
set<
unsigned int>(
"padding") = 3;
63 "When true the latest timestep will overwrite the " 64 "existing file, so only a single timestep exists.");
71 "discontinuous",
false,
"Enables discontinuous output format for Exodus files.");
75 "side_discontinuous",
false,
"Enables adding side-discontinuous output in Exodus files.");
83 params.
addParam<
bool>(
"write_hdf5",
false,
"Enables HDF5 output format for Exodus files.");
95 _exodus_initialized(false),
96 _exodus_mesh_changed(declareRestartableData<bool>(
"exodus_mesh_changed", true)),
97 _sequence(isParamValid(
"sequence") ? getParam<bool>(
"sequence")
98 : _use_displaced ? true
100 _exodus_num(declareRestartableData<unsigned
int>(
"exodus_num", 0)),
101 _recovering(_app.isRecovering()),
102 _overwrite(getParam<bool>(
"overwrite")),
104 _discontinuous(getParam<bool>(
"discontinuous")),
105 _side_discontinuous(getParam<bool>(
"side_discontinuous")),
106 _write_hdf5(getParam<bool>(
"write_hdf5"))
110 auto use_problem_dimension = getParam<bool>(
"use_problem_dimension");
112 if (use_problem_dimension)
121 ": Invalid parameters. 'elemental_as_nodal' set to false while 'discontinuous' set " 133 "This method is no longer needed. We can determine output dimension programmatically");
145 mooseError(
"The current settings result in nothing being output to the Exodus file.");
151 mooseError(
"The current settings results in only the input file and no variables being output " 152 "to the Exodus file, this is not supported.");
156 if ((
mesh.n_nodes() !=
mesh.max_node_id()) || (
mesh.n_elem() !=
mesh.max_elem_id()))
197 auto serialize = [
this](
auto & moose_mesh)
199 auto & lm_mesh = moose_mesh.getMesh();
201 lm_mesh.gather_to_zero();
204 if ((this->
processor_id() == 0) && !lm_mesh.is_replicated())
205 moose_mesh.markFiniteVolumeInfoDirty();
227 #ifndef LIBMESH_HAVE_HDF5 228 mooseError(
"Moose input requested HDF Exodus output, but libMesh was built without HDF5.");
281 switch (output_dimension)
288 if (
mesh.getMesh().mesh_dimension() == 1)
289 exodus_io.write_as_dimension(3);
291 exodus_io.write_as_dimension(static_cast<int>(
mesh.effectiveSpatialDimension()));
297 exodus_io.write_as_dimension(static_cast<int>(output_dimension));
301 exodus_io.use_mesh_dimension_instead_of_spatial_dimension(
true);
305 ::mooseError(
"Unknown output_dimension in Exodus writer");
354 for (
const auto &
name : pps)
384 for (
const auto & out_name :
out)
394 const std::vector<dof_id_type> & dof_indices = scalar_var.
dofIndices();
395 const unsigned int n = dof_indices.size();
398 const DofMap & dof_map = scalar_var.
sys().
dofMap();
399 for (
unsigned int i = 0; i != n; ++i)
415 for (
unsigned int i = 0; i < n; ++i)
417 std::ostringstream
os;
418 os << out_name <<
"_" << i;
432 syntax_formatter.
format();
487 int err = std::remove(current.c_str());
489 mooseError(
"MOOSE failed to remove the empty file ", current);
497 std::ostringstream
output;
502 output <<
"-s" << std::setw(
_padding) << std::setprecision(0) << std::setfill(
'0') << std::right
virtual void meshChanged() override
Called on this object when the mesh changes.
Based class for providing re-positioning and oversampling support to output objects.
const std::set< std::string > & getPostprocessorOutput()
The list of postprocessor names that are set for output.
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 mooseDeprecated(Args &&... args) 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 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...
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.
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.
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 DofMap & dofMap()
Gets writeable reference to the dof map.
bool _mesh_contiguous_numbering
whether the mesh is contiguously numbered (exodus output will force that)
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.
EquationSystems * _es_ptr
Reference the the libMesh::EquationSystems object that contains the data.
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 _oversample
Flag indicating that oversampling is enabled.
bool hasPostprocessorByName(const PostprocessorName &name) const
Determine if the Postprocessor data exists.
bool _recovering
Flag indicating MOOSE is recovering via –recover command-line option.
virtual void initialSetup() override
Call init() method on setup.
bool & _exodus_mesh_changed
A flag indicating to the Exodus object that the mesh has changed.
Class for output data to the ExodusII format.
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)
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 void meshChanged() override
Update data after a mesh change.
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.
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.
static void setOutputDimensionInExodusWriter(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...
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
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") ...
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.
processor_id_type processor_id() const
SystemBase & sys()
Get the system this variable is part of.
std::unique_ptr< ExodusII_IO > _exodus_io_ptr
Pointer to the libMesh::ExodusII_IO object that performs the actual data output.
Real getGlobalTimeOffset() const
Each App has it's own local time.
bool _change_position
Flag for re-positioning.
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.
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.
const ExecFlagType EXEC_INITIAL