Skip to content

Commit

Permalink
enable reporter data to be read in by vectorPostprocessorPointSource c…
Browse files Browse the repository at this point in the history
  • Loading branch information
lynnmunday committed Aug 5, 2021
1 parent f2340a0 commit 5717b60
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 30 deletions.
@@ -1,14 +1,33 @@
# VectorPostprocessorPointSource

A `VectorPostprocessorPointSource` reads in multiple point sources from a VectorPostprocessor. The point source values and coordinates are updated as the vectorPostprocessor values are changed. Example syntax for a `VectorPostprocessorPointSource` used in a transient simulation is given by:
A `VectorPostprocessorPointSource` reads in multiple point sources from a `VectorPostprocessor` or `Reporter`. The point source values and coordinates are updated as the `VectorPostprocessor` or `Reporter` values are changed.

An example of a `VectorPostprocessorPointSource` using a `Reporter` of type [ConstantReporter](/ConstantReporter.md)
and a `VectorPostrocessor` of type [CSVReader](/CSVReader.md) is given by

!listing test/tests/dirackernels/vectorPostprocessor_point_source/2d_vpp.i block=reporter_point_source

with the following `Reporter`:

!listing test/tests/dirackernels/vectorPostprocessor_point_source/2d_vpp.i block=Reporters

and `CSVReader`:

!listing test/tests/dirackernels/vectorPostprocessor_point_source/2d_vpp.i block=VectorPostprocessors

reading from the following csv file:

!listing test/tests/dirackernels/vectorPostprocessor_point_source/point_value_file.csv

The next example applies a `VectorPostprocessorPointSource` in a transient simulation given by:

!listing test/tests/dirackernels/vectorPostprocessor_point_source/2d_vpp_transient.i block=DiracKernels

using the following VectorPostprocessor to provide x,y,z coordinates and `value_name = u`
using the following `VectorPostprocessor` to provide x,y,z coordinates and `value_name = u`

!listing test/tests/dirackernels/vectorPostprocessor_point_source/2d_vpp_transient.i block=VectorPostprocessors/point_sample_out

Note that the `PointValueSampler` has `execute_on = timestep_begin` to force the vpp to execute prior to being used by `VectorPostprocessorPointSource`. It is also important for the `VectorPostprocessorPointSource` to never use a vpp with `contains_complete_history = true`, as this can modify the ordering of the coordinates and points. In the above input file, two locations have loads applied to them by the `VectorPostprocessorPointSource`. The load values are given by the `PointValueSampler`.
Note that the `PointValueSampler` has `execute_on = timestep_begin` to force the `VectorPostprocessor` to execute prior to being used by `VectorPostprocessorPointSource`. It is also important for the `VectorPostprocessorPointSource` to never use a `VectorPostprocessor` with `contains_complete_history = true`, as this can modify the ordering of the coordinates and points. In the above input file, two locations have loads applied to them by the `VectorPostprocessorPointSource`. The load values are given by the `PointValueSampler`.

!syntax parameters /DiracKernels/VectorPostprocessorPointSource

Expand Down
11 changes: 6 additions & 5 deletions framework/include/dirackernels/VectorPostprocessorPointSource.h
Expand Up @@ -11,6 +11,7 @@

// Moose Includes
#include "DiracKernel.h"
#include "ReporterInterface.h"

// Forward Declarations
class VectorPostprocessorPointSource;
Expand All @@ -23,7 +24,7 @@ InputParameters validParams<VectorPostprocessorPointSource>();
* Coordinates and values are given by a vector Postprocessor. Values and coordinates for the point
* source are allowed change as the vector Postprocessor is updated.
*/
class VectorPostprocessorPointSource : public DiracKernel
class VectorPostprocessorPointSource : public DiracKernel, public ReporterInterface
{
public:
static InputParameters validParams();
Expand All @@ -34,10 +35,10 @@ class VectorPostprocessorPointSource : public DiracKernel
virtual Real computeQpResidual() override;

private:
const VectorPostprocessorValue & _vpp_values;
const VectorPostprocessorValue & _x_coord;
const VectorPostprocessorValue & _y_coord;
const VectorPostprocessorValue & _z_coord;
const std::vector<Real> & _vpp_values;
const std::vector<Real> & _x_coord;
const std::vector<Real> & _y_coord;
const std::vector<Real> & _z_coord;
/// map to associate points with their index into the vpp value
std::map<Point, size_t> _point_to_index;
};
48 changes: 33 additions & 15 deletions framework/src/dirackernels/VectorPostprocessorPointSource.C
Expand Up @@ -20,28 +20,46 @@ VectorPostprocessorPointSource::validParams()
{
InputParameters params = DiracKernel::validParams();

params.addClassDescription("Apply a point load defined by VectorPostprocessor.");
params.addClassDescription("Apply a point load defined by Reporter or VectorPostprocessor.");

params.addParam<VectorPostprocessorName>(
params.addParam<std::string>(
"vector_postprocessor",
"The name of the VectorPostprocessor containing positions and corresponding load values");
params.addParam<std::string>("x_coord_name", "x", "name of column containing x coordinates.");
params.addParam<std::string>("y_coord_name", "y", "name of column containing y coordinates.");
params.addParam<std::string>("z_coord_name", "z", "name of column containing z coordinates.");
params.addParam<std::string>("value_name", "value", "name of column containing values.");
"The name of the VectorPostprocessor containing positions and corresponding load values. "
"This will be appended onto the reporter name as <vector_postprocessor>/<vector_name>.");
params.addParam<std::string>("x_coord_name", "x", "name of reporter containing x coordinates.");
params.addParam<std::string>("y_coord_name", "y", "name of reporter containing y coordinates.");
params.addParam<std::string>("z_coord_name", "z", "name of reporter containing z coordinates.");
params.addParam<std::string>("value_name", "value", "name of reporter containing values.");

return params;
}

VectorPostprocessorPointSource::VectorPostprocessorPointSource(const InputParameters & parameters)
: DiracKernel(parameters),
_vpp_values(getVectorPostprocessorValue(
"vector_postprocessor", getParam<std::string>("value_name"), true)),
_x_coord(getVectorPostprocessorValue(
"vector_postprocessor", getParam<std::string>("x_coord_name"), true)),
_y_coord(getVectorPostprocessorValue(
"vector_postprocessor", getParam<std::string>("y_coord_name"), true)),
_z_coord(getVectorPostprocessorValue(
"vector_postprocessor", getParam<std::string>("z_coord_name"), true))
ReporterInterface(this),
_vpp_values(
isParamValid("vector_postprocessor")
? getReporterValueByName<std::vector<Real>>(
getParam<std::string>("vector_postprocessor") + "/" +
getParam<std::string>("value_name"))
: getReporterValueByName<std::vector<Real>>(getParam<std::string>("value_name"))),
_x_coord(
isParamValid("vector_postprocessor")
? getReporterValueByName<std::vector<Real>>(
getParam<std::string>("vector_postprocessor") + "/" +
getParam<std::string>("x_coord_name"))
: getReporterValueByName<std::vector<Real>>(getParam<std::string>("x_coord_name"))),
_y_coord(
isParamValid("vector_postprocessor")
? getReporterValueByName<std::vector<Real>>(
getParam<std::string>("vector_postprocessor") + "/" +
getParam<std::string>("y_coord_name"))
: getReporterValueByName<std::vector<Real>>(getParam<std::string>("y_coord_name"))),
_z_coord(isParamValid("vector_postprocessor")
? getReporterValueByName<std::vector<Real>>(
getParam<std::string>("vector_postprocessor") + "/" +
getParam<std::string>("z_coord_name"))
: getReporterValueByName<std::vector<Real>>(getParam<std::string>("z_coord_name")))
{
}

Expand Down
21 changes: 21 additions & 0 deletions test/tests/dirackernels/vectorPostprocessor_point_source/2d_vpp.i
Expand Up @@ -23,12 +23,21 @@
[]

[DiracKernels]
inactive = 'reporter_point_source'
[./vpp_point_source]
type = VectorPostprocessorPointSource
variable = u
value_name = 'u'
vector_postprocessor = csv_reader
[../]
[./reporter_point_source]
type = VectorPostprocessorPointSource
variable = u
value_name = 'reporterData/u'
x_coord_name = 'reporterData/x'
y_coord_name = 'reporterData/y'
z_coord_name = 'reporterData/z'
[../]
[]

[BCs]
Expand All @@ -53,6 +62,18 @@
[../]
[]

[Reporters]
[reporterData]
type = ConstantReporter
real_vector_names = 'x y z u'
real_vector_values =
'0.2 0.2 0.0;
0.3 0.8 0.0;
0 0 0;
1 -.5 0'
[]
[]

[Executioner]
type = Steady
solve_type = 'PJFNK'
Expand Down
26 changes: 19 additions & 7 deletions test/tests/dirackernels/vectorPostprocessor_point_source/tests
@@ -1,21 +1,33 @@
[Tests]
issues = '#15831'
design = 'syntax/DiracKernels/index.md'
design = 'VectorPostprocessorPointSource.md'
[2dConstant]
type = 'Exodiff'
input = '2d_vpp.i'
exodiff = '2d_vpp_out.e'
requirement = "The system shall support point sources with locations and values given by a VectorPostprocessor "
"in a steady state 2D problem, reproducing the constantPointSource."
requirement = 'The system shall support point sources with locations and values given by a'
[vpp]
issues = '#15831'
type = 'Exodiff'
input = '2d_vpp.i'
exodiff = '2d_vpp_out.e'
detail = ' VectorPostprocessor in a steady state 2D problem, reproducing the constantPointSource.'
[]
[reporter]
issues = '#18528'
type = 'Exodiff'
input = '2d_vpp.i'
exodiff = '2d_vpp_out.e'
cli_args = 'DiracKernels/inactive=vpp_point_source'
detail = ' ConstantReporter in a steady state 2D problem, reproducing the constantPointSource.'
[]
[]
[3dConstant]
issues = '#15831'
type = 'Exodiff'
input = '3d_vpp.i'
exodiff = '3d_vpp_out.e'
requirement = "The system shall support point sources with locations and values referenced by name from the input "
"file given by a VectorPostprocessor in steady state 3D problem, reproducing the constantPointSource."
[]
[2dTransient]
issues = '#15831'
type = 'CSVDiff'
input = '2d_vpp_transient.i'
csvdiff = '2d_vpp_transient_out_point_sample_out.csv'
Expand Down

0 comments on commit 5717b60

Please sign in to comment.