LCOV - code coverage report
Current view: top level - include/outputs - Exodus.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 1 1 100.0 %
Date: 2025-07-17 01:28:37 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : #pragma once
      11             : 
      12             : // MOOSE includes
      13             : #include "SampledOutput.h"
      14             : 
      15             : // libMesh forward declarations
      16             : namespace libMesh
      17             : {
      18             : class ExodusII_IO;
      19             : }
      20             : 
      21             : /**
      22             :  * Class for output data to the ExodusII format
      23             :  */
      24             : class Exodus : public SampledOutput
      25             : {
      26             : public:
      27             :   static InputParameters validParams();
      28             : 
      29             :   enum class OutputDimension : int
      30             :   {
      31             :     DEFAULT,
      32             :     ONE,
      33             :     TWO,
      34             :     THREE,
      35             :     PROBLEM_DIMENSION
      36             :   };
      37             : 
      38             :   /**
      39             :    * Class constructor
      40             :    */
      41             :   Exodus(const InputParameters & parameters);
      42             : 
      43             :   /**
      44             :    * Overload the OutputBase::output method, this is required for ExodusII
      45             :    * output due to the method utilized for outputting single/global parameters
      46             :    */
      47             :   virtual void output() override;
      48             : 
      49             :   /**
      50             :    * Performs basic error checking and initial setup of ExodusII_IO output object
      51             :    */
      52             :   virtual void initialSetup() override;
      53             : 
      54             :   /**
      55             :    * Set flag indicating that the mesh has changed
      56             :    */
      57             :   virtual void meshChanged() override;
      58             : 
      59             :   /**
      60             :    * Performs the necessary deletion and re-creating of ExodusII_IO object
      61             :    *
      62             :    * This function is stand-alone and called directly from the output() method because
      63             :    * the ExodusII_IO object is extremely fragile with respect to closing a file that has
      64             :    * not had data written. Thus, it is important to only create a new ExodusII_IO object
      65             :    * if it is certain that it will be used.
      66             :    */
      67             :   virtual void outputSetup();
      68             : 
      69             :   /**
      70             :    * Set the sequence state
      71             :    * When the sequence state is set to true then the outputSetup() method is called with every
      72             :    * call to output(). In the case of Exodus output, this creates a new file with each output.
      73             :    *
      74             :    * The sequence state is automatically set to true when 'use_displaced = true', otherwise it
      75             :    * is set to false initially
      76             :    */
      77             :   virtual void sequence(bool state);
      78             : 
      79             :   /**
      80             :    * Force the output dimension programatically
      81             :    *
      82             :    * @param dim The dimension written in the output file
      83             :    */
      84             :   void setOutputDimension(unsigned int dim);
      85             : 
      86             :   /**
      87             :    * Helper method to change the output dimension in the passed in Exodus writer depending on
      88             :    * the dimension and coordinates of the passed in mesh.
      89             :    *
      90             :    * @param exodus_io The ExodusII_IO object to modify
      91             :    * @param mesh The MooseMesh object that is queried to determine the appropriate output dimension.
      92             :    */
      93             :   static void
      94             :   setOutputDimensionInExodusWriter(libMesh::ExodusII_IO & exodus_io,
      95             :                                    const MooseMesh & mesh,
      96             :                                    OutputDimension output_dim = OutputDimension::DEFAULT);
      97             : 
      98             :   /// Reset Exodus output
      99             :   void clear();
     100             : 
     101        2920 :   bool supportsMaterialPropertyOutput() const override { return true; }
     102             : 
     103             : protected:
     104             :   /**
     105             :    * Outputs nodal, nonlinear variables
     106             :    */
     107             :   virtual void outputNodalVariables() override;
     108             : 
     109             :   /**
     110             :    * Outputs elemental, nonlinear variables
     111             :    */
     112             :   virtual void outputElementalVariables() override;
     113             : 
     114             :   /**
     115             :    * Writes postprocessor values to global output parameters
     116             :    */
     117             :   virtual void outputPostprocessors() override;
     118             : 
     119             :   /**
     120             :    * Writes scalar AuxVariables to global output parameters
     121             :    */
     122             :   virtual void outputScalarVariables() override;
     123             : 
     124             :   /**
     125             :    * Writes the input file to the ExodusII output
     126             :    */
     127             :   virtual void outputInput() override;
     128             : 
     129             :   /**
     130             :    * Writes the Reporter values to the ExodusII output
     131             :    */
     132             :   virtual void outputReporters() override;
     133             : 
     134             :   /**
     135             :    * Customizes file output settings.
     136             :    */
     137             :   virtual void customizeFileOutput();
     138             : 
     139             :   /**
     140             :    * Returns the current filename, this method handles the -s000 suffix
     141             :    * common to ExodusII files.
     142             :    * @return A string containing the current filename to be written
     143             :    */
     144             :   virtual std::string filename() override;
     145             : 
     146             :   /// Pointer to the libMesh::ExodusII_IO object that performs the actual data output
     147             :   std::unique_ptr<libMesh::ExodusII_IO> _exodus_io_ptr;
     148             : 
     149             :   /// Storage for scalar values (postprocessors and scalar AuxVariables)
     150             :   std::vector<Real> _global_values;
     151             : 
     152             :   /// Storage for names of the above scalar values
     153             :   std::vector<std::string> _global_names;
     154             : 
     155             :   /**
     156             :    * Flag for indicating the status of the ExodusII file that is being written. The ExodusII_IO
     157             :    * interface requires that the file be 'initialized' prior to writing any type of data. This
     158             :    * initialization occurs when write_timestep() is called. However, write_timestep also writes
     159             :    * nodal
     160             :    * data, so in the case where no nodal data is output, it is necessary to call write_timestep()
     161             :    * after
     162             :    * calling set_output_variables with an empty input string. This flag allows for the various
     163             :    * output
     164             :    * methods to check that the ExodusII file is in the proper state prior to writing data.
     165             :    * @see outputEmptyTimestep()
     166             :    */
     167             :   bool _exodus_initialized;
     168             : 
     169             :   /// A flag indicating to the Exodus object that the mesh has changed
     170             :   bool & _exodus_mesh_changed;
     171             : 
     172             :   /// Sequence flag, if true each timestep is written to a new file
     173             :   bool _sequence;
     174             : 
     175             :   /// Count of outputs per exodus file
     176             :   unsigned int & _exodus_num;
     177             : 
     178             : private:
     179             :   /// Handle the call to mesh renumbering in libmesh's ExodusIO on non-contiguously numbered meshes
     180             :   void handleExodusIOMeshRenumbering();
     181             : 
     182             :   /**
     183             :    * A helper function for 'initializing' the ExodusII output file, see the comments for the
     184             :    * _initialized
     185             :    * member variable.
     186             :    * @see _initialized
     187             :    */
     188             :   void outputEmptyTimestep();
     189             : 
     190             :   /// Flag indicating MOOSE is recovering via --recover command-line option
     191             :   bool _recovering;
     192             : 
     193             :   /// Storage for input file record; this is written to the file only after it has been initialized
     194             :   std::vector<std::string> _input_record;
     195             : 
     196             :   /// Flag for overwriting timesteps
     197             :   bool _overwrite;
     198             : 
     199             :   /// Enum for the output dimension
     200             :   OutputDimension _output_dimension;
     201             : 
     202             :   /// Flag to output discontinuous format in Exodus
     203             :   bool _discontinuous;
     204             : 
     205             :   /// Flag to output added disjoint fictitious sides for side_discontinuous variables
     206             :   bool _side_discontinuous;
     207             : 
     208             :   /// Flag to output HDF5 format (when available) in Exodus
     209             :   bool _write_hdf5;
     210             : };

Generated by: LCOV version 1.14