https://mooseframework.inl.gov
VectorPostprocessorVisualizationAux.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
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 
16 {
18 
19  params.addClassDescription("Read values from a VectorPostprocessor that is producing vectors "
20  "that are 'number of processors' * in length. Puts the value for "
21  "each processor into an elemental auxiliary field.");
22 
23  params.addRequiredParam<VectorPostprocessorName>(
24  "vpp", "The name of the VectorPostprocessor to pull the data from.");
25  params.addRequiredParam<std::string>(
26  "vector_name", "The name of the vector to use from the VectorPostprocessor");
27 
28  params.addParam<bool>("use_broadcast",
29  false,
30  "Causes this AuxKernel to use a broadcasted version of the vector instead "
31  "of a scattered version of the vector (the default). This is slower - but "
32  "is useful for debugging and testing");
33 
34  return params;
35 }
36 
38  const InputParameters & parameters)
39  : AuxKernel(parameters),
40  _use_broadcast(getParam<bool>("use_broadcast")),
41  _vpp_scatter(getScatterVectorPostprocessorValue("vpp", getParam<std::string>("vector_name"))),
42  _vpp_vector(
43  getVectorPostprocessorValue("vpp", getParam<std::string>("vector_name"), _use_broadcast)),
44  _my_pid(processor_id())
45 {
46 }
47 
48 void
50 {
51  if (_my_pid == 0 && _vpp_vector.size() != n_processors())
52  mooseError("Error in AuxKernel ",
53  name(),
54  ". Vector ",
55  getParam<std::string>("vector_name"),
56  " in VectorPostprocessor ",
57  getParam<VectorPostprocessorName>("vpp"),
58  " does not contain num_procs number of entries. num_procs: ",
59  n_processors(),
60  " num_entries: ",
61  _vpp_vector.size());
62 }
63 
64 Real
66 {
67  if (_use_broadcast)
68  {
69  mooseAssert(_vpp_vector.size() > _my_pid,
70  "Vector does not contain enough entries in VectorPostprocessorVisualization named "
71  << name());
72  return _vpp_vector[_my_pid];
73  }
74  return _vpp_scatter;
75 }
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)
Read values from a VectorPostprocessor that is producing vectors that are "number of processors" in l...
virtual const std::string & name() const
Get the name of the class.
Definition: MooseBase.h:57
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...
processor_id_type n_processors() const
registerMooseObject("MooseApp", VectorPostprocessorVisualizationAux)
const VectorPostprocessorValue & _vpp_vector
Holds the values we want to display.
const ScatterVectorPostprocessorValue & _vpp_scatter
Holds the values we want to display.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
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 optional parameter and a documentation string to the InputParameters object...
static InputParameters validParams()
Definition: AuxKernel.C:27
Base class for creating new auxiliary kernels and auxiliary boundary conditions.
Definition: AuxKernel.h:36