LCOV - code coverage report
Current view: top level - include/outputs - Output.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 3 3 100.0 %
Date: 2025-07-17 01:28:37 Functions: 3 3 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             : #include <chrono>
      13             : 
      14             : // MOOSE includes
      15             : #include "MooseObject.h"
      16             : #include "Restartable.h"
      17             : #include "MeshChangedInterface.h"
      18             : #include "SetupInterface.h"
      19             : #include "PostprocessorInterface.h"
      20             : #include "VectorPostprocessorInterface.h"
      21             : #include "ReporterInterface.h"
      22             : #include "AdvancedOutputUtils.h"
      23             : #include "PerfGraphInterface.h"
      24             : #include "FunctionInterface.h"
      25             : 
      26             : class MooseMesh;
      27             : class Times;
      28             : 
      29             : // libMesh forward declarations
      30             : namespace libMesh
      31             : {
      32             : class EquationSystems;
      33             : }
      34             : 
      35             : /**
      36             :  * Based class for output objects
      37             :  *
      38             :  * Each output class (e.g., Exodus) should inherit from this base class. At a minimum, the pure
      39             :  * virtual methods for the various types of output must be defined in the child class.
      40             :  *
      41             :  * @see Exodus Console CSV
      42             :  */
      43             : class Output : public MooseObject,
      44             :                public Restartable,
      45             :                public MeshChangedInterface,
      46             :                public SetupInterface,
      47             :                public FunctionInterface,
      48             :                public PostprocessorInterface,
      49             :                public VectorPostprocessorInterface,
      50             :                public ReporterInterface,
      51             :                public PerfGraphInterface
      52             : {
      53             : public:
      54             :   static InputParameters validParams();
      55             : 
      56             :   /**
      57             :    * Class constructor
      58             :    *
      59             :    * The constructor performs all of the necessary initialization of the various
      60             :    * output lists required for the various output types.
      61             :    *
      62             :    * @see initAvailable init separate
      63             :    */
      64             :   Output(const InputParameters & parameters);
      65             : 
      66             :   /**
      67             :    * Get the output time.
      68             :    * @return The output time, which may be different than the simulation time
      69             :    *
      70             :    * When the Executioner is steady this utilizes the time_step and when Transient the actual time
      71             :    * is used.
      72             :    */
      73             :   virtual Real time();
      74             : 
      75             :   /**
      76             :    * Get the old output time.
      77             :    * @return The old output time, which may be different than the simulation time
      78             :    *
      79             :    * @see time()
      80             :    */
      81             :   virtual Real timeOld();
      82             : 
      83             :   /**
      84             :    * Get the current time step size
      85             :    */
      86             :   virtual Real dt();
      87             : 
      88             :   /**
      89             :    * Get old time step size
      90             :    */
      91             :   virtual Real dtOld();
      92             : 
      93             :   /**
      94             :    * Get the current time step
      95             :    */
      96             :   virtual int timeStep();
      97             : 
      98             :   /**
      99             :    * Get the output interval
     100             :    */
     101             :   const unsigned int & interval() const;
     102             : 
     103             :   /**
     104             :    * Get the current 'execute_on' selections for display
     105             :    */
     106             :   const MultiMooseEnum & executeOn() const;
     107             : 
     108             :   /**
     109             :    * Returns true if this object is an AdvancedOutput object
     110             :    */
     111             :   bool isAdvanced();
     112             : 
     113             :   /**
     114             :    * Returns the advanced 'execute_on' settings.
     115             :    *
     116             :    * Check if this is valid first with isAdvanced()
     117             :    */
     118             :   virtual const OutputOnWarehouse & advancedExecuteOn() const;
     119             : 
     120             :   /**
     121             :    * Return an ExecFlagEnum object with the available execution flags for Output objects.
     122             :    */
     123             :   static ExecFlagEnum getDefaultExecFlagEnum();
     124             : 
     125             :   /**
     126             :    * Method for controlling the allow output state
     127             :    * @param state The state to set the allow flag to
     128             :    */
     129      319289 :   void allowOutput(bool state) { _allow_output = state; }
     130             : 
     131             :   /**
     132             :    * A static helper for injecting deprecated parameters
     133             :    */
     134             :   static void addDeprecatedInputParameters(InputParameters & params);
     135             : 
     136             :   /**
     137             :    * A single call to this function should output all the necessary data for a single timestep.
     138             :    * @param type The type execution flag (see Moose.h)
     139             :    *
     140             :    * @see outputNodalVariables outputElementalVariables outputScalarVariables outputPostprocessors
     141             :    */
     142             :   virtual void outputStep(const ExecFlagType & type);
     143             : 
     144      266109 :   const std::set<Real> & getSyncTimes() { return _sync_times; }
     145             : 
     146             :   /**
     147             :    * A virtual function that stores whether output type supports material output. Defaults to false,
     148             :    * if a particular output type supports material output it can be overridden in the child class.
     149             :    */
     150        6239 :   virtual bool supportsMaterialPropertyOutput() const { return false; }
     151             : 
     152             : protected:
     153             :   /**
     154             :    * Overload this function with the desired output activities
     155             :    */
     156             :   virtual void output() = 0;
     157             : 
     158             :   /**
     159             :    * A method called just prior to the solve, this is used by PetscOutput to perform the necessary
     160             :    * setup actions for each timestep
     161             :    */
     162             :   virtual void solveSetup();
     163             : 
     164             :   /**
     165             :    * Handles logic for determining if a step should be output
     166             :    * @return True if a call if output should be performed
     167             :    */
     168             :   virtual bool shouldOutput();
     169             : 
     170             :   /**
     171             :    * Returns true if the output interval is satisfied
     172             :    * \todo{Implement additional types of intervals (e.g., simulation time and real time)}
     173             :    */
     174             :   virtual bool onInterval();
     175             : 
     176             :   /**
     177             :    * Function to set the wall time interval based on value of command line parameter (used for
     178             :    * testing only).
     179             :    * @param cli_param_name The name of the command line parameter to set the wall time interval to
     180             :    *
     181             :    */
     182             :   void setWallTimeIntervalFromCommandLineParam();
     183             : 
     184             :   /// Pointer the the FEProblemBase object for output object (use this)
     185             :   FEProblemBase * _problem_ptr;
     186             : 
     187             :   /// Transient flag (true = transient)
     188             :   bool _transient;
     189             : 
     190             :   /// Flag for using displaced mesh
     191             :   bool _use_displaced;
     192             : 
     193             :   /// Reference the the libMesh::EquationSystems object that contains the data
     194             :   libMesh::EquationSystems * _es_ptr;
     195             : 
     196             :   /// A convenience pointer to the current mesh (reference or displaced depending on "use_displaced")
     197             :   MooseMesh * _mesh_ptr;
     198             : 
     199             :   /// Flag for forcing call to outputSetup() with every call to output() (restartable)
     200             :   bool _sequence;
     201             : 
     202             :   /// The common Execution types; this is used as the default execution type for everything except system information and input
     203             :   ExecFlagEnum _execute_on;
     204             : 
     205             :   /**
     206             :    * Current execute on flag. This is different from the flag provided by
     207             :    * FEProblemBase::getCurrentExecuteOnFlag() const, as outputs are triggered
     208             :    * in PETSc callbacks which cannot update  FEProblemBase::_current_execute_on_flag
     209             :    * so we shadow it with a new member of the same name.
     210             :    */
     211             :   ExecFlagType _current_execute_flag;
     212             : 
     213             :   /// The current time for output purposes
     214             :   Real & _time;
     215             : 
     216             :   /// The old time
     217             :   Real & _time_old;
     218             : 
     219             :   /// The current time step
     220             :   int & _t_step;
     221             : 
     222             :   /// Time step delta
     223             :   Real & _dt;
     224             : 
     225             :   /// Old time step delta
     226             :   Real & _dt_old;
     227             : 
     228             :   /// The number of outputs written
     229             :   unsigned int _num;
     230             : 
     231             :   /// Whether time step interval is set by AddParam
     232             :   const bool _time_step_interval_set_by_addparam;
     233             : 
     234             :   /// The output time step interval
     235             :   unsigned int _time_step_interval;
     236             : 
     237             :   /// Minimum simulation time between outputs
     238             :   const Real _min_simulation_time_interval;
     239             : 
     240             :   /// Target simulation time between outputs
     241             :   const Real _simulation_time_interval;
     242             : 
     243             :   /// Target wall time between outputs in seconds
     244             :   Real _wall_time_interval;
     245             : 
     246             :   /// Sync times for this outputter
     247             :   std::set<Real> _sync_times;
     248             : 
     249             :   /// Sync times object for this outputter
     250             :   const Times * const _sync_times_object;
     251             : 
     252             :   /// Start outputting time
     253             :   Real _start_time;
     254             : 
     255             :   /// End outputting time
     256             :   Real _end_time;
     257             : 
     258             :   /// Start outputting at this time step
     259             :   int _start_step;
     260             : 
     261             :   /// End outputting at this time step
     262             :   int _end_step;
     263             : 
     264             :   /// Time checking tolerance
     265             :   Real _t_tol;
     266             : 
     267             :   /// Flag for only executing at sync times
     268             :   bool _sync_only;
     269             : 
     270             :   /// Flag for disabling output
     271             :   bool _allow_output;
     272             : 
     273             :   /// Flag for advanced output testing
     274             :   bool _is_advanced;
     275             : 
     276             :   /// Storage for the individual component execute flags
     277             :   // This is here rather than in AdvancedOutput to allow generic
     278             :   // access to this data from the Console object for displaying
     279             :   // the output settings.
     280             :   OutputOnWarehouse _advanced_execute_on;
     281             : 
     282             :   /// last simulation time an output has occured
     283             :   Real & _last_output_simulation_time;
     284             : 
     285             :   /// last wall time an output has occured
     286             :   std::chrono::time_point<std::chrono::steady_clock> _last_output_wall_time;
     287             : 
     288             :   /// time in seconds since last output
     289             :   Real _wall_time_since_last_output;
     290             : 
     291             :   friend class OutputWarehouse;
     292             : };

Generated by: LCOV version 1.14