From 90b17acbd0c6829ffd03683eb6ade350cde798b0 Mon Sep 17 00:00:00 2001 From: aprilnovak Date: Mon, 27 Sep 2021 16:37:44 -0500 Subject: [PATCH] Address review comments. Refs #18931 --- .../SpatialUserObjectVectorPostprocessor.md | 8 +++++--- framework/include/userobject/NearestPointBase.h | 3 ++- framework/include/userobject/UserObject.h | 2 +- .../SpatialUserObjectVectorPostprocessor.h | 7 +++---- .../SpatialUserObjectVectorPostprocessor.C | 15 +++------------ .../spatial_userobject_vector_postprocessor/tests | 9 +++++++++ 6 files changed, 23 insertions(+), 21 deletions(-) diff --git a/framework/doc/content/source/vectorpostprocessors/SpatialUserObjectVectorPostprocessor.md b/framework/doc/content/source/vectorpostprocessors/SpatialUserObjectVectorPostprocessor.md index a6d000486b61..982a92e56938 100644 --- a/framework/doc/content/source/vectorpostprocessors/SpatialUserObjectVectorPostprocessor.md +++ b/framework/doc/content/source/vectorpostprocessors/SpatialUserObjectVectorPostprocessor.md @@ -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 diff --git a/framework/include/userobject/NearestPointBase.h b/framework/include/userobject/NearestPointBase.h index f21dfba821d1..a40c412332b1 100644 --- a/framework/include/userobject/NearestPointBase.h +++ b/framework/include/userobject/NearestPointBase.h @@ -270,7 +270,8 @@ NearestPointBase::spatialPoints() const for (MooseIndex(_points) i = 0; i < _points.size(); ++i) { - std::shared_ptr layered_base = std::dynamic_pointer_cast(_user_objects[i]); + std::shared_ptr layered_base = + std::dynamic_pointer_cast(_user_objects[i]); if (layered_base) { const auto & layers = layered_base->getLayerCenters(); diff --git a/framework/include/userobject/UserObject.h b/framework/include/userobject/UserObject.h index 1339ddd75d89..630cae9f28ce 100644 --- a/framework/include/userobject/UserObject.h +++ b/framework/include/userobject/UserObject.h @@ -107,7 +107,7 @@ class UserObject : public MooseObject, */ virtual const std::vector spatialPoints() const { - mooseError(name(), " does not satisfy the points Spatial UserObject interface!"); + mooseError("Spatial UserObject interface is not satisfied; spatialPoints() must be overridden"); } /** diff --git a/framework/include/vectorpostprocessors/SpatialUserObjectVectorPostprocessor.h b/framework/include/vectorpostprocessors/SpatialUserObjectVectorPostprocessor.h index 038267125226..a729545e3b81 100644 --- a/framework/include/vectorpostprocessors/SpatialUserObjectVectorPostprocessor.h +++ b/framework/include/vectorpostprocessors/SpatialUserObjectVectorPostprocessor.h @@ -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(); @@ -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 _points; }; diff --git a/framework/src/vectorpostprocessors/SpatialUserObjectVectorPostprocessor.C b/framework/src/vectorpostprocessors/SpatialUserObjectVectorPostprocessor.C index 44090fd86484..88913b48023d 100644 --- a/framework/src/vectorpostprocessors/SpatialUserObjectVectorPostprocessor.C +++ b/framework/src/vectorpostprocessors/SpatialUserObjectVectorPostprocessor.C @@ -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( - "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"); @@ -40,8 +38,7 @@ SpatialUserObjectVectorPostprocessor::SpatialUserObjectVectorPostprocessor( const InputParameters & parameters) : GeneralVectorPostprocessor(parameters), _uo_vec(declareVector(MooseUtils::shortName(parameters.get("_object_name")))), - _uo(getUserObject("userobject")), - _use_points_from_uo(getParam("use_points_from_uo")) + _uo(getUserObject("userobject")) { fillPoints(); _uo_vec.resize(_points.size()); @@ -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")) { @@ -76,8 +69,6 @@ SpatialUserObjectVectorPostprocessor::fillPoints() file.read(); _points = file.getDataAsPoints(); } - else - mooseError(name(), ": You need to supply either 'points' or 'points_file' parameter."); } } diff --git a/test/tests/vectorpostprocessors/spatial_userobject_vector_postprocessor/tests b/test/tests/vectorpostprocessors/spatial_userobject_vector_postprocessor/tests index 0716b82391c2..a7aa6e4999bb 100644 --- a/test/tests/vectorpostprocessors/spatial_userobject_vector_postprocessor/tests +++ b/test/tests/vectorpostprocessors/spatial_userobject_vector_postprocessor/tests @@ -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.' + [] []