LCOV - code coverage report
Current view: top level - src/positions - FilePositions.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 23 24 95.8 %
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 "FilePositions.h"
      11             : #include "DelimitedFileReader.h"
      12             : 
      13             : registerMooseObject("MooseApp", FilePositions);
      14             : 
      15             : InputParameters
      16       14353 : FilePositions::validParams()
      17             : {
      18       14353 :   InputParameters params = Positions::validParams();
      19       14353 :   params.addClassDescription("Import positions from one or more files.");
      20       14353 :   params.addRequiredParam<std::vector<FileName>>("files",
      21             :                                                  "Text file(s) with the positions, one per line");
      22             : 
      23             :   // Input from file should not be re-ordered
      24       14353 :   params.set<bool>("auto_sort") = false;
      25             :   // File is loaded on all processes
      26       14353 :   params.set<bool>("auto_broadcast") = false;
      27             : 
      28       14353 :   return params;
      29           0 : }
      30             : 
      31          44 : FilePositions::FilePositions(const InputParameters & parameters) : Positions(parameters)
      32             : {
      33          44 :   const auto & positions_files = getParam<std::vector<FileName>>("files");
      34          44 :   _positions_2d.resize(positions_files.size());
      35             : 
      36             :   // Copied from MultiApp.C
      37          88 :   for (const auto p_file_it : index_range(positions_files))
      38             :   {
      39          44 :     const std::string positions_file = positions_files[p_file_it];
      40          44 :     MooseUtils::DelimitedFileReader file(positions_file, &_communicator);
      41          44 :     file.setFormatFlag(MooseUtils::DelimitedFileReader::FormatFlag::ROWS);
      42          44 :     file.read();
      43             : 
      44          44 :     const std::vector<Point> & data = file.getDataAsPoints();
      45         220 :     for (const auto & d : data)
      46             :     {
      47         176 :       _positions.push_back(d);
      48         176 :       _positions_2d[p_file_it].push_back(d);
      49             :     }
      50          44 :   }
      51          44 :   _initialized = true;
      52             :   // Sort (if requested) and create KDTree
      53          44 :   finalize();
      54          44 : }

Generated by: LCOV version 1.14