forked from idaholab/moose
/
SpatialUserObjectVectorPostprocessor.C
86 lines (74 loc) · 2.75 KB
/
SpatialUserObjectVectorPostprocessor.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
//* This file is part of the MOOSE framework
//* https://www.mooseframework.org
//*
//* All rights reserved, see COPYRIGHT for full restrictions
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
//*
//* Licensed under LGPL 2.1, please see LICENSE for details
//* https://www.gnu.org/licenses/lgpl-2.1.html
#include "SpatialUserObjectVectorPostprocessor.h"
#include "DelimitedFileReader.h"
#include "UserObjectInterface.h"
registerMooseObject("MooseApp", SpatialUserObjectVectorPostprocessor);
defineLegacyParams(SpatialUserObjectVectorPostprocessor);
InputParameters
SpatialUserObjectVectorPostprocessor::validParams()
{
InputParameters params = GeneralVectorPostprocessor::validParams();
params.addRequiredParam<UserObjectName>("userobject",
"The userobject whose values are to be reported");
params.addParam<std::vector<Point>>("points",
"Computations will be lumped into values at these points.");
params.addParam<FileName>("points_file",
"A filename that should be looked in for points. Each "
"set of 3 values in that file will represent a Point. "
"This and 'points' cannot be both supplied.");
params.addClassDescription("Outputs the values of a spatial user object in the order "
"of the specified spatial points");
return params;
}
SpatialUserObjectVectorPostprocessor::SpatialUserObjectVectorPostprocessor(
const InputParameters & parameters)
: GeneralVectorPostprocessor(parameters),
_uo_vec(declareVector(MooseUtils::shortName(parameters.get<std::string>("_object_name")))),
_uo(getUserObject<UserObject>("userobject"))
{
fillPoints();
_uo_vec.resize(_points.size());
}
void
SpatialUserObjectVectorPostprocessor::fillPoints()
{
if (!isParamValid("points") && !isParamValid("points_file"))
{
_points = _uo.spatialPoints();
}
else
{
if (isParamValid("points") && isParamValid("points_file"))
paramError("points", "Both 'points' and 'points_file' cannot be specified simultaneously.");
if (isParamValid("points"))
{
_points = getParam<std::vector<Point>>("points");
}
else if (isParamValid("points_file"))
{
const FileName & points_file = getParam<FileName>("points_file");
MooseUtils::DelimitedFileReader file(points_file, &_communicator);
file.setFormatFlag(MooseUtils::DelimitedFileReader::FormatFlag::ROWS);
file.read();
_points = file.getDataAsPoints();
}
}
}
void
SpatialUserObjectVectorPostprocessor::initialize()
{
_uo_vec.clear();
}
void
SpatialUserObjectVectorPostprocessor::execute()
{
for (const auto & pt : _points)
_uo_vec.push_back(_uo.spatialValue(pt));
}