https://mooseframework.inl.gov
SpatialUserObjectVectorPostprocessor.C
Go to the documentation of this file.
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 
11 #include "DelimitedFileReader.h"
12 #include "UserObjectInterface.h"
13 
15 
18 {
20 
21  params.addRequiredParam<UserObjectName>("userobject",
22  "The userobject whose values are to be reported");
23  params.addParam<std::vector<Point>>("points",
24  "Computations will be lumped into values at these points.");
25  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  params.addClassDescription("Outputs the values of a spatial user object in the order "
30  "of the specified spatial points");
31 
32  return params;
33 }
34 
36  const InputParameters & parameters)
37  : GeneralVectorPostprocessor(parameters),
38  _uo_vec(declareVector(MooseUtils::shortName(parameters.get<std::string>("_object_name")))),
39  _uo(getUserObject<UserObject>("userobject"))
40 {
41  fillPoints();
42  _uo_vec.resize(_points.size());
43 }
44 
45 void
47 {
48  if (!isParamValid("points") && !isParamValid("points_file"))
49  {
51  }
52  else
53  {
54  if (isParamValid("points") && isParamValid("points_file"))
55  paramError("points", "Both 'points' and 'points_file' cannot be specified simultaneously.");
56 
57  if (isParamValid("points"))
58  {
59  _points = getParam<std::vector<Point>>("points");
60  }
61  else if (isParamValid("points_file"))
62  {
63  const FileName & points_file = getParam<FileName>("points_file");
64 
67  file.read();
68  _points = file.getDataAsPoints();
69  }
70  }
71 }
72 
73 void
75 {
76  _uo_vec.clear();
77 }
78 
79 void
81 {
82  for (const auto & pt : _points)
83  _uo_vec.push_back(_uo.spatialValue(pt));
84 }
virtual const std::vector< Point > spatialPoints() const
Optional interface function for providing the points at which a UserObject attains spatial values...
Definition: UserObject.h:106
T * get(const std::unique_ptr< T > &u)
The MooseUtils::get() specializations are used to support making forwards-compatible code changes fro...
Definition: MooseUtils.h:1155
This class is here to combine the VectorPostprocessor interface and the base class VectorPostprocesso...
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
virtual void execute() override
Populates the postprocessor vector of values with the userobject evaluations in space.
virtual void initialize() override
Initialize, clears the postprocessor vector.
const Parallel::Communicator & _communicator
void addRequiredParam(const std::string &name, const std::string &doc_string)
This method adds a parameter and documentation string to the InputParameters object that will be extr...
std::string shortName(const std::string &name)
Function for stripping name after the file / in parser block.
Definition: MooseUtils.C:608
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
VectorPostprocessorValue & _uo_vec
The VectorPostprocessorValue object where the results are stored.
SpatialUserObjectVectorPostprocessor(const InputParameters &parameters)
Class constructor.
void fillPoints()
Read the points at which to evaluate from a vector (&#39;points&#39;), a file (&#39;points_file&#39;), or neither (which will read from the user object directly if it satisfies the spatialPoints interface)
static InputParameters validParams()
void paramError(const std::string &param, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
registerMooseObject("MooseApp", SpatialUserObjectVectorPostprocessor)
virtual Real spatialValue(const Point &) const
Optional interface function for "evaluating" a UserObject at a spatial position.
Definition: UserObject.h:95
Utility class for reading delimited data (e.g., CSV data).
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump...
const UserObject & _uo
Userobject to evaluate spatially.
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object...
SpatialUserObjectVectorPostprocessor is a type of VectorPostprocessor that outputs the values of a sp...
Base class for user-specific data.
Definition: UserObject.h:40
std::vector< Point > _points
Points at which to evaluate the user object.