LCOV - code coverage report
Current view: top level - src/times - ExodusFileTimes.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 20 21 95.2 %
Date: 2025-07-17 01:28:37 Functions: 2 2 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             : #include "ExodusFileTimes.h"
      11             : #include "MooseUtils.h"
      12             : #include "libmesh/serial_mesh.h"
      13             : #include "libmesh/exodusII_io.h"
      14             : 
      15             : registerMooseObject("MooseApp", ExodusFileTimes);
      16             : 
      17             : InputParameters
      18       14289 : ExodusFileTimes::validParams()
      19             : {
      20       14289 :   InputParameters params = Times::validParams();
      21       14289 :   params.addClassDescription("Import times from one or more Exodus files.");
      22       14289 :   params.addRequiredParam<std::vector<FileName>>("files", "Exodus file(s) with the times");
      23             :   // File is loaded only on zeroth process
      24       14289 :   params.set<bool>("auto_broadcast") = true;
      25             : 
      26       14289 :   return params;
      27           0 : }
      28             : 
      29          12 : ExodusFileTimes::ExodusFileTimes(const InputParameters & parameters) : Times(parameters)
      30             : {
      31             :   // Reading exodus files on all ranks could be expensive
      32          12 :   const auto & times_files = getParam<std::vector<FileName>>("files");
      33             : 
      34          12 :   if (processor_id() == 0)
      35             :   {
      36          27 :     for (const auto p_file_it : index_range(times_files))
      37             :     {
      38             :       // Check that the required file exists
      39          18 :       MooseUtils::checkFileReadable(times_files[p_file_it]);
      40             : 
      41             :       // dummy mesh
      42          18 :       ReplicatedMesh mesh(_communicator);
      43             : 
      44          18 :       libMesh::ExodusII_IO exodusII_io(mesh);
      45          18 :       exodusII_io.read(times_files[p_file_it]);
      46          18 :       auto & times = exodusII_io.get_time_steps();
      47             : 
      48         432 :       for (const auto & d : times)
      49         414 :         _times.push_back(d);
      50          18 :     }
      51             :   }
      52             : 
      53             :   // Sort all the times, but also broadcast to other ranks
      54          12 :   finalize();
      55          12 : }

Generated by: LCOV version 1.14