LCOV - code coverage report
Current view: top level - src/vectorpostprocessors - SpatialUserObjectVectorPostprocessor.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #32971 (54bef8) with base c6cf66 Lines: 36 37 97.3 %
Date: 2026-05-29 20:35:17 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        3613 : SpatialUserObjectVectorPostprocessor::validParams()
      18             : {
      19        3613 :   InputParameters params = GeneralVectorPostprocessor::validParams();
      20             : 
      21       14452 :   params.addRequiredParam<UserObjectName>("userobject",
      22             :                                           "The userobject whose values are to be reported");
      23       14452 :   params.addParam<std::vector<Point>>("points",
      24             :                                       "Computations will be lumped into values at these points.");
      25       14452 :   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        3613 :   params.addClassDescription("Outputs the values of a spatial user object in the order "
      30             :                              "of the specified spatial points");
      31             : 
      32        3613 :   return params;
      33           0 : }
      34             : 
      35         276 : SpatialUserObjectVectorPostprocessor::SpatialUserObjectVectorPostprocessor(
      36         276 :     const InputParameters & parameters)
      37             :   : GeneralVectorPostprocessor(parameters),
      38         276 :     _uo_vec(declareVector(MooseUtils::shortName(parameters.getObjectName()))),
      39        1104 :     _uo(getUserObject<UserObject>("userobject"))
      40             : {
      41         276 :   fillPoints();
      42         273 :   _uo_vec.resize(_points.size());
      43         273 : }
      44             : 
      45             : void
      46         276 : SpatialUserObjectVectorPostprocessor::fillPoints()
      47             : {
      48        1236 :   if (!isParamValid("points") && !isParamValid("points_file"))
      49             :   {
      50         192 :     _points = _uo.spatialPoints();
      51             :   }
      52             :   else
      53             :   {
      54         396 :     if (isParamValid("points") && isParamValid("points_file"))
      55           6 :       paramError("points", "Both 'points' and 'points_file' cannot be specified simultaneously.");
      56             : 
      57         243 :     if (isParamValid("points"))
      58             :     {
      59         207 :       _points = getParam<std::vector<Point>>("points");
      60             :     }
      61          36 :     else if (isParamValid("points_file"))
      62             :     {
      63          24 :       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         273 : }
      72             : 
      73             : void
      74         248 : SpatialUserObjectVectorPostprocessor::initialize()
      75             : {
      76         248 :   _uo_vec.clear();
      77         248 : }
      78             : 
      79             : void
      80         248 : SpatialUserObjectVectorPostprocessor::execute()
      81             : {
      82        1909 :   for (const auto & pt : _points)
      83        1667 :     _uo_vec.push_back(_uo.spatialValue(pt));
      84         242 : }

Generated by: LCOV version 1.14