www.mooseframework.org
ElementValueSampler.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 
10 #include "ElementValueSampler.h"
11 
12 // MOOSE includes
13 #include "MooseVariableFE.h"
14 
15 // C++ includes
16 #include <numeric>
17 
19 
22 {
24 
25  params.addClassDescription("Samples values of elemental variable(s).");
26 
27  params += SamplerBase::validParams();
28 
29  return params;
30 }
31 
33  : ElementVariableVectorPostprocessor(parameters), SamplerBase(parameters, this, _communicator)
34 {
35  // ensure that variables are elemental, i.e., not scalar and and not nodal
36  for (unsigned int i = 0; i < _coupled_moose_vars.size(); i++)
37  if (_coupled_moose_vars[i]->feType().family == SCALAR || _coupled_moose_vars[i]->isNodal())
38  paramError(
39  "variable", "The variable '", _coupled_moose_vars[i]->name(), "' is not elemental.");
40 
41  std::vector<std::string> var_names(_coupled_moose_vars.size());
42  _values.resize(_coupled_moose_vars.size());
43 
44  for (unsigned int i = 0; i < _coupled_moose_vars.size(); i++)
45  var_names[i] = _coupled_moose_vars[i]->name();
46 
47  // Initialize the data structures in SamplerBase
48  SamplerBase::setupVariables(var_names);
49 }
50 
51 void
53 {
55 }
56 
57 void
59 {
60  unsigned int i_fe = 0, i_fv = 0;
61  for (unsigned int i = 0; i < _coupled_moose_vars.size(); i++)
62  if (_coupled_moose_vars[i]->isFV())
63  _values[i] = _coupled_standard_fv_moose_vars[i_fv++]->getElementalValue(_current_elem);
64  else
65  _values[i] = _coupled_standard_moose_vars[i_fe++]->getElementalValue(_current_elem);
66 
67  SamplerBase::addSample(_current_elem->vertex_average(), _current_elem->id(), _values);
68 }
69 
70 void
72 {
74 }
75 
76 void
78 {
79  const auto & vpp = static_cast<const ElementValueSampler &>(y);
80 
82 }
Base class for VectorPostprocessors that need to do "sampling" of values in the domain.
Definition: SamplerBase.h:36
virtual void threadJoin(const UserObject &y) override
Must override.
virtual void initialize()
Initialize the datastructures.
Definition: SamplerBase.C:75
SCALAR
std::vector< MooseVariableFV< Real > * > _coupled_standard_fv_moose_vars
Vector of standard finite volume coupled variables.
Definition: Coupleable.h:1339
ElementValueSampler(const InputParameters &parameters)
virtual void execute() override
Execute method.
std::vector< Real > _values
So we don&#39;t have to create and destroy this vector over and over again.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
virtual void initialize() override
Initialize the datastructures.
virtual const std::string & name() const
Get the name of the class.
Definition: MooseBase.h:56
virtual void finalize() override
Finalize the values.
std::vector< MooseVariable * > _coupled_standard_moose_vars
Vector of standard coupled variables.
Definition: Coupleable.h:1330
Base class VectorPostprocessors operating on elemental variables.
void setupVariables(const std::vector< std::string > &variable_names)
You MUST call this in the constructor of the child class and pass down the name of the variables...
Definition: SamplerBase.C:51
virtual void threadJoin(const SamplerBase &y)
Join the values.
Definition: SamplerBase.C:145
void paramError(const std::string &param, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
static InputParameters validParams()
static InputParameters validParams()
Definition: SamplerBase.C:22
std::vector< MooseVariableFieldBase * > _coupled_moose_vars
Vector of all coupled variables.
Definition: Coupleable.h:1327
virtual void finalize()
Finalize the values.
Definition: SamplerBase.C:91
virtual void addSample(const Point &p, const Real &id, const std::vector< Real > &values)
Call this with the value of every variable at each point you want to sample at.
Definition: SamplerBase.C:61
const Elem *const & _current_elem
The current element pointer (available during execute())
Samples values of elemental variable(s).
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...
registerMooseObject("MooseApp", ElementValueSampler)
Base class for user-specific data.
Definition: UserObject.h:39