LCOV - code coverage report
Current view: top level - src/vectorpostprocessors - SpatialUserObjectVectorPostprocessor.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 419b9d Lines: 36 37 97.3 %
Date: 2025-08-08 20:01:16 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       14841 : SpatialUserObjectVectorPostprocessor::validParams()
      18             : {
      19       14841 :   InputParameters params = GeneralVectorPostprocessor::validParams();
      20             : 
      21       14841 :   params.addRequiredParam<UserObjectName>("userobject",
      22             :                                           "The userobject whose values are to be reported");
      23       14841 :   params.addParam<std::vector<Point>>("points",
      24             :                                       "Computations will be lumped into values at these points.");
      25       14841 :   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       14841 :   params.addClassDescription("Outputs the values of a spatial user object in the order "
      30             :                              "of the specified spatial points");
      31             : 
      32       14841 :   return params;
      33           0 : }
      34             : 
      35         288 : SpatialUserObjectVectorPostprocessor::SpatialUserObjectVectorPostprocessor(
      36         288 :     const InputParameters & parameters)
      37             :   : GeneralVectorPostprocessor(parameters),
      38         288 :     _uo_vec(declareVector(MooseUtils::shortName(parameters.get<std::string>("_object_name")))),
      39         576 :     _uo(getUserObject<UserObject>("userobject"))
      40             : {
      41         288 :   fillPoints();
      42         284 :   _uo_vec.resize(_points.size());
      43         284 : }
      44             : 
      45             : void
      46         288 : SpatialUserObjectVectorPostprocessor::fillPoints()
      47             : {
      48         288 :   if (!isParamValid("points") && !isParamValid("points_file"))
      49             :   {
      50         195 :     _points = _uo.spatialPoints();
      51             :   }
      52             :   else
      53             :   {
      54          93 :     if (isParamValid("points") && isParamValid("points_file"))
      55           4 :       paramError("points", "Both 'points' and 'points_file' cannot be specified simultaneously.");
      56             : 
      57          89 :     if (isParamValid("points"))
      58             :     {
      59          76 :       _points = getParam<std::vector<Point>>("points");
      60             :     }
      61          13 :     else if (isParamValid("points_file"))
      62             :     {
      63          13 :       const FileName & points_file = getParam<FileName>("points_file");
      64             : 
      65          13 :       MooseUtils::DelimitedFileReader file(points_file, &_communicator);
      66          13 :       file.setFormatFlag(MooseUtils::DelimitedFileReader::FormatFlag::ROWS);
      67          13 :       file.read();
      68          13 :       _points = file.getDataAsPoints();
      69          13 :     }
      70             :   }
      71         284 : }
      72             : 
      73             : void
      74         260 : SpatialUserObjectVectorPostprocessor::initialize()
      75             : {
      76         260 :   _uo_vec.clear();
      77         260 : }
      78             : 
      79             : void
      80         260 : SpatialUserObjectVectorPostprocessor::execute()
      81             : {
      82        2036 :   for (const auto & pt : _points)
      83        1784 :     _uo_vec.push_back(_uo.spatialValue(pt));
      84         252 : }

Generated by: LCOV version 1.14