https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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.getObjectName()))),
39 _uo(getUserObject<UserObject>("userobject"))
40{
41 fillPoints();
42 _uo_vec.resize(_points.size());
43}
44
45void
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
73void
78
79void
81{
82 for (const auto & pt : _points)
83 _uo_vec.push_back(_uo.spatialValue(pt));
84}
registerMooseObject("MooseApp", SpatialUserObjectVectorPostprocessor)
This class is here to combine the VectorPostprocessor interface and the base class VectorPostprocesso...
static InputParameters validParams()
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
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.
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...
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.
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 ...
Definition MooseBase.h:457
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
Definition MooseBase.h:199
Utility class for reading delimited data (e.g., CSV data).
const std::vector< Point > getDataAsPoints() const
Get the data in Point format.
void read()
Perform the actual data reading.
SpatialUserObjectVectorPostprocessor is a type of VectorPostprocessor that outputs the values of a sp...
const UserObject & _uo
Userobject to evaluate spatially.
std::vector< Point > _points
Points at which to evaluate the user object.
VectorPostprocessorValue & _uo_vec
The VectorPostprocessorValue object where the results are stored.
void fillPoints()
Read the points at which to evaluate from a vector ('points'), a file ('points_file'),...
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.
SpatialUserObjectVectorPostprocessor(const InputParameters &parameters)
Class constructor.
Base class for user-specific data.
Definition UserObject.h:20
virtual const std::vector< Point > spatialPoints() const
Optional interface function for providing the points at which a UserObject attains spatial values.
Definition UserObject.h:47
virtual Real spatialValue(const Point &) const
Optional interface function for "evaluating" a UserObject at a spatial position.
Definition UserObject.h:36
const Parallel::Communicator & _communicator