Skip to content

Commit

Permalink
Address review comments. Refs idaholab#18931
Browse files Browse the repository at this point in the history
  • Loading branch information
aprilnovak committed Sep 27, 2021
1 parent ba00ec7 commit 90b17ac
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 21 deletions.
Expand Up @@ -11,9 +11,11 @@ This postprocessor may be used to convert spatial user objects such as
postprocessor that can be transferred to another application with a
[MultiAppVectorPostprocessorTransfer](/transfers/MultiAppVectorPostprocessorTransfer.md).

The `use_points_from_uo` parameter can be used with user objects that define
the `spatialPoints()` interface to automatically get points in space at which the
user object obtains unique values.
If neither [!param](/VectorPostprocessors/SpatialUserObjectVectorPostprocessor/points)
or [!param](/VectorPostprocessors/SpatialUserObjectVectorPostprocessor/points_file) are
provided, this object will attempt to get the spatial points directly from the user object.
These points will represent locations in space where the user object obtains a unique value.
To use this feature, the user object must define the `spatialPoints()` interface.

## Example Input File Syntax

Expand Down
3 changes: 2 additions & 1 deletion framework/include/userobject/NearestPointBase.h
Expand Up @@ -270,7 +270,8 @@ NearestPointBase<UserObjectType, BaseType>::spatialPoints() const

for (MooseIndex(_points) i = 0; i < _points.size(); ++i)
{
std::shared_ptr<LayeredBase> layered_base = std::dynamic_pointer_cast<LayeredBase>(_user_objects[i]);
std::shared_ptr<LayeredBase> layered_base =
std::dynamic_pointer_cast<LayeredBase>(_user_objects[i]);
if (layered_base)
{
const auto & layers = layered_base->getLayerCenters();
Expand Down
2 changes: 1 addition & 1 deletion framework/include/userobject/UserObject.h
Expand Up @@ -107,7 +107,7 @@ class UserObject : public MooseObject,
*/
virtual const std::vector<Point> spatialPoints() const
{
mooseError(name(), " does not satisfy the points Spatial UserObject interface!");
mooseError("Spatial UserObject interface is not satisfied; spatialPoints() must be overridden");
}

/**
Expand Down
Expand Up @@ -42,7 +42,9 @@ class SpatialUserObjectVectorPostprocessor : public GeneralVectorPostprocessor
virtual void execute() override;

/**
* Read the points at which to evaluate from a vector or file
* Read the points at which to evaluate from a vector ('points'), a file ('points_file'),
* or neither (which will read from the user object directly if it satisfies the
* spatialPoints interface)
*/
void fillPoints();

Expand All @@ -53,9 +55,6 @@ class SpatialUserObjectVectorPostprocessor : public GeneralVectorPostprocessor
/// Userobject to evaluate spatially
const UserObject & _uo;

/// Whether to get the points from the user object
const bool & _use_points_from_uo;

/// Points at which to evaluate the user object
std::vector<Point> _points;
};
Expand Up @@ -28,8 +28,6 @@ SpatialUserObjectVectorPostprocessor::validParams()
"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.addParam<bool>(
"use_points_from_uo", false, "Whether to obtain the points directly from the user object");
params.addClassDescription("Outputs the values of a spatial user object in the order "
"of the specified spatial points");

Expand All @@ -40,8 +38,7 @@ SpatialUserObjectVectorPostprocessor::SpatialUserObjectVectorPostprocessor(
const InputParameters & parameters)
: GeneralVectorPostprocessor(parameters),
_uo_vec(declareVector(MooseUtils::shortName(parameters.get<std::string>("_object_name")))),
_uo(getUserObject<UserObject>("userobject")),
_use_points_from_uo(getParam<bool>("use_points_from_uo"))
_uo(getUserObject<UserObject>("userobject"))
{
fillPoints();
_uo_vec.resize(_points.size());
Expand All @@ -50,18 +47,14 @@ SpatialUserObjectVectorPostprocessor::SpatialUserObjectVectorPostprocessor(
void
SpatialUserObjectVectorPostprocessor::fillPoints()
{
if (_use_points_from_uo)
if (!isParamValid("points") && !isParamValid("points_file"))
{
if (isParamValid("points") || isParamValid("points_file"))
mooseWarning("When 'use_points_from_uo' is true, the 'points' and 'points_file' parameters "
"are ignored");

_points = _uo.spatialPoints();
}
else
{
if (isParamValid("points") && isParamValid("points_file"))
mooseError(name(), ": Both 'points' and 'points_file' cannot be specified simultaneously.");
paramError("points", "Both 'points' and 'points_file' cannot be specified simultaneously.");

if (isParamValid("points"))
{
Expand All @@ -76,8 +69,6 @@ SpatialUserObjectVectorPostprocessor::fillPoints()
file.read();
_points = file.getDataAsPoints();
}
else
mooseError(name(), ": You need to supply either 'points' or 'points_file' parameter.");
}
}

Expand Down
Expand Up @@ -7,4 +7,13 @@
design = 'SpatialUserObjectVectorPostprocessor.md'
requirement = 'The system shall be able to query a spatial user object and aggregate the results into a vector postprocessor.'
[]
[missing_pts]
type = RunException
input = spatial_userobject.i
cli_args="VectorPostprocessors/vpp/points='0 0 0'"
expect_err = "Both 'points' and 'points_file' cannot be specified simultaneously."
issues = '#19831'
design = 'SpatialUserObjectVectorPostprocessor.md'
requirement = 'The system shall error if the points are specified in more than one manner for a spatial vector postprocessor.'
[]
[]

0 comments on commit 90b17ac

Please sign in to comment.