www.mooseframework.org
VectorPostprocessorVisualizationAux.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 
13 
14 template <>
17 {
19 
20  params.addClassDescription("Read values from a VectorPostprocessor that is producing vectors "
21  "that are 'number of processors' * in length. Puts the value for "
22  "each processor into an elemental auxiliary field.");
23 
24  params.addRequiredParam<VectorPostprocessorName>(
25  "vpp", "The name of the VectorPostprocessor to pull the data from.");
26  params.addRequiredParam<std::string>(
27  "vector_name", "The name of the vector to use from the VectorPostprocessor");
28 
29  params.addParam<bool>("use_broadcast",
30  false,
31  "Causes this AuxKernel to use a broadcasted version of the vector instead "
32  "of a scattered version of the vector (the default). This is slower - but "
33  "is useful for debugging and testing");
34 
35  return params;
36 }
37 
39  const InputParameters & parameters)
40  : AuxKernel(parameters),
41  _use_broadcast(getParam<bool>("use_broadcast")),
42  _vpp_scatter(getScatterVectorPostprocessorValue("vpp", getParam<std::string>("vector_name"))),
43  _vpp_vector(
44  getVectorPostprocessorValue("vpp", getParam<std::string>("vector_name"), _use_broadcast)),
45  _my_pid(processor_id())
46 {
47 }
48 
49 void
51 {
52  if (_my_pid == 0 && _vpp_vector.size() != n_processors())
53  mooseError("Error in AuxKernel ",
54  name(),
55  ". Vector ",
56  getParam<std::string>("vector_name"),
57  " in VectorPostprocessor ",
58  getParam<VectorPostprocessorName>("vpp"),
59  " does not contain num_procs number of entries. num_procs: ",
60  n_processors(),
61  " num_entries: ",
62  _vpp_vector.size());
63 }
64 
65 Real
67 {
68  if (_use_broadcast)
69  {
70  mooseAssert(_vpp_vector.size() > _my_pid,
71  "Vector does not contain enough entries in VectorPostprocessorVisualization named "
72  << name());
73  return _vpp_vector[_my_pid];
74  }
75  else
76  return _vpp_scatter;
77 }
bool _use_broadcast
Whether or not we&#39;re using a broadcast (replicated) vector.
virtual void timestepSetup() override
Note: this used for error checking.
virtual Real computeValue() override
Get the value from the vector and assign it to the element.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
VectorPostprocessorVisualizationAux(const InputParameters &parameters)
void mooseError(Args &&... args) const
Definition: MooseObject.h:147
InputParameters validParams< VectorPostprocessorVisualizationAux >()
Read values from a VectorPostprocessor that is producing vectors that are "number of processors" in l...
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...
registerMooseObject("MooseApp", VectorPostprocessorVisualizationAux)
const VectorPostprocessorValue & _vpp_vector
Holds the values we want to display.
InputParameters validParams< AuxKernel >()
Definition: AuxKernel.C:25
const ScatterVectorPostprocessorValue & _vpp_scatter
Holds the values we want to display.
const std::string & name() const
Get the name of the object.
Definition: MooseObject.h:59
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 addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an option parameter and a documentation string to the InputParameters object...
Base class for creating new auxiliary kernels and auxiliary boundary conditions.
Definition: AuxKernel.h:33