LCOV - code coverage report
Current view: top level - include/userobjects - GroundMotionReader.h (source / functions) Hit Total Coverage
Test: idaholab/mastodon: 55510a Lines: 1 3 33.3 %
Date: 2025-08-26 23:09:31 Functions: 0 2 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : #ifndef GROUNDMOTIONREADER_H
       2             : #define GROUNDMOTIONREADER_H
       3             : 
       4             : // MOOSE includes
       5             : #include "gtest/gtest.h"
       6             : #include "GeneralUserObject.h"
       7             : #include "DelimitedFileReader.h"
       8             : 
       9             : 
      10             : 
      11             : /**
      12             :  * Reads and provides access to ground motion data.
      13             :  */
      14             : class GroundMotionReader : public GeneralUserObject
      15             : {
      16             : public:
      17             :   static InputParameters validParams();
      18             :   /// Flag for indicating the data column from input ground motionss
      19             :   enum class Component
      20             :   {
      21             :     TIME = 0,
      22             :     X = 1,
      23             :     Y = 2,
      24             :     Z = 3
      25             :   };
      26             : 
      27             :   /// Alias for underlying storage structure of ground motion data
      28             :   using Data = std::vector<std::map<Component, std::vector<Real>>>;
      29             : 
      30             :   GroundMotionReader(const InputParameters & parameters);
      31             :   virtual void execute() override;
      32           0 :   virtual void initialize() override {}
      33           0 :   virtual void finalize() override {}
      34             : 
      35             :   ///@{
      36             :   /**
      37             :    * Methods for extracting ground motion data.
      38             :    */
      39             :   const std::vector<double> & getData(const std::size_t & index, Component comp) const;
      40             :   Data getData(const Real & scale = 1, const Real & offset = 0) const;
      41             :   const std::vector<std::unique_ptr<MooseUtils::DelimitedFileReader>> & readers() const
      42             :   {
      43          12 :     return _readers;
      44             :   }
      45             :   ///@}
      46             : 
      47             :   /**
      48             :    * Return the number of ground motions.
      49             :    */
      50             :   unsigned int count() const;
      51             : 
      52             : protected:
      53             :   /// Filename pattern (glob)
      54             :   const std::string & _pattern;
      55             : 
      56             :   /// Storage for the readers, the readers maintain ownership of the data
      57             :   std::vector<std::unique_ptr<MooseUtils::DelimitedFileReader>> _readers;
      58             : 
      59             : public:
      60             :   /* The following methods are private static methods that implement the primary functions of this
      61             :    * object. They are static so that they may be unit tested. They are private because they are
      62             :    * not intended to be used outside of this class (excluding testing).
      63             :    */
      64             :   static std::vector<std::unique_ptr<MooseUtils::DelimitedFileReader>>
      65             :   execute(const std::string & name, const std::string & pattern);
      66             : 
      67             :   static const std::vector<double> &
      68             :   getData(const std::string & name,
      69             :           const std::vector<std::unique_ptr<MooseUtils::DelimitedFileReader>> & readers,
      70             :           const std::size_t & index,
      71             :           Component comp);
      72             : 
      73             :   static Data getData(const std::string & name,
      74             :                       const std::vector<std::unique_ptr<MooseUtils::DelimitedFileReader>> & readers,
      75             :                       const Real & scale = 1,
      76             :                       const Real & offset = 0);
      77             : };
      78             : 
      79             : #endif

Generated by: LCOV version 1.14