LCOV - code coverage report
Current view: top level - src/vectorpostprocessors - SpatialUserObjectVectorPostprocessor.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 36 37 97.3 %
Date: 2025-07-17 01:28:37 Functions: 5 5 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 "SpatialUserObjectVectorPostprocessor.h"
      11             : #include "DelimitedFileReader.h"
      12             : #include "UserObjectInterface.h"
      13             : 
      14             : registerMooseObject("MooseApp", SpatialUserObjectVectorPostprocessor);
      15             : 
      16             : InputParameters
      17       14799 : SpatialUserObjectVectorPostprocessor::validParams()
      18             : {
      19       14799 :   InputParameters params = GeneralVectorPostprocessor::validParams();
      20             : 
      21       14799 :   params.addRequiredParam<UserObjectName>("userobject",
      22             :                                           "The userobject whose values are to be reported");
      23       14799 :   params.addParam<std::vector<Point>>("points",
      24             :                                       "Computations will be lumped into values at these points.");
      25       14799 :   params.addParam<FileName>("points_file",
      26             :                             "A filename that should be looked in for points. Each "
      27             :                             "set of 3 values in that file will represent a Point.  "
      28             :                             "This and 'points' cannot be both supplied.");
      29       14799 :   params.addClassDescription("Outputs the values of a spatial user object in the order "
      30             :                              "of the specified spatial points");
      31             : 
      32       14799 :   return params;
      33           0 : }
      34             : 
      35         267 : SpatialUserObjectVectorPostprocessor::SpatialUserObjectVectorPostprocessor(
      36         267 :     const InputParameters & parameters)
      37             :   : GeneralVectorPostprocessor(parameters),
      38         267 :     _uo_vec(declareVector(MooseUtils::shortName(parameters.get<std::string>("_object_name")))),
      39         534 :     _uo(getUserObject<UserObject>("userobject"))
      40             : {
      41         267 :   fillPoints();
      42         263 :   _uo_vec.resize(_points.size());
      43         263 : }
      44             : 
      45             : void
      46         267 : SpatialUserObjectVectorPostprocessor::fillPoints()
      47             : {
      48         267 :   if (!isParamValid("points") && !isParamValid("points_file"))
      49             :   {
      50         180 :     _points = _uo.spatialPoints();
      51             :   }
      52             :   else
      53             :   {
      54          87 :     if (isParamValid("points") && isParamValid("points_file"))
      55           4 :       paramError("points", "Both 'points' and 'points_file' cannot be specified simultaneously.");
      56             : 
      57          83 :     if (isParamValid("points"))
      58             :     {
      59          71 :       _points = getParam<std::vector<Point>>("points");
      60             :     }
      61          12 :     else if (isParamValid("points_file"))
      62             :     {
      63          12 :       const FileName & points_file = getParam<FileName>("points_file");
      64             : 
      65          12 :       MooseUtils::DelimitedFileReader file(points_file, &_communicator);
      66          12 :       file.setFormatFlag(MooseUtils::DelimitedFileReader::FormatFlag::ROWS);
      67          12 :       file.read();
      68          12 :       _points = file.getDataAsPoints();
      69          12 :     }
      70             :   }
      71         263 : }
      72             : 
      73             : void
      74         239 : SpatialUserObjectVectorPostprocessor::initialize()
      75             : {
      76         239 :   _uo_vec.clear();
      77         239 : }
      78             : 
      79             : void
      80         239 : SpatialUserObjectVectorPostprocessor::execute()
      81             : {
      82        1867 :   for (const auto & pt : _points)
      83        1636 :     _uo_vec.push_back(_uo.spatialValue(pt));
      84         231 : }

Generated by: LCOV version 1.14