https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ElementValueSampler.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
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 variables on elements.");
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'
36 for (unsigned int i = 0; i < _coupled_moose_vars.size(); i++)
37 {
39 paramError("variable",
40 "The variable '",
42 "' is a nodal variable. Nodal variables can be sampled using a "
43 "'NodalValueSampler'.");
45 }
46 std::vector<std::string> var_names(_coupled_moose_vars.size());
47 _values.resize(_coupled_moose_vars.size());
48
49 for (unsigned int i = 0; i < _coupled_moose_vars.size(); i++)
50 var_names[i] = _coupled_moose_vars[i]->name();
51
52 // Initialize the data structures in SamplerBase
54}
55
56void
61
62void
64{
65 unsigned int i_fe = 0, i_fv = 0;
66 for (unsigned int i = 0; i < _coupled_moose_vars.size(); i++)
67 if (_coupled_moose_vars[i]->isFV())
68 {
69 const auto state = determineState();
70 const Moose::ElemArg elem_arg = {_current_elem, /*correct_skewness*/ false};
71 _values[i] = MetaPhysicL::raw_value((*_coupled_fv_moose_vars[i_fv++])(elem_arg, state));
72 }
73 else
74 _values[i] = _coupled_standard_moose_vars[i_fe++]->getElementalValue(_current_elem);
75
77}
78
79void
84
85void
87{
88 const auto & vpp = static_cast<const ElementValueSampler &>(y);
89
91}
registerMooseObject("MooseApp", ElementValueSampler)
std::vector< MooseVariable * > _coupled_standard_moose_vars
Vector of standard coupled variables.
std::vector< MooseVariableFieldBase * > _coupled_moose_vars
Vector of all coupled variables.
std::vector< MooseVariableField< Real > * > _coupled_fv_moose_vars
Vector of all finite volume coupled variables.
const Elem *const & _current_elem
The current element pointer (available during execute())
Samples values of elemental variable(s).
static InputParameters validParams()
virtual void threadJoin(const UserObject &y) override
Must override.
std::vector< Real > _values
So we don't have to create and destroy this vector over and over again.
virtual void execute() override
Execute method.
ElementValueSampler(const InputParameters &parameters)
virtual void finalize() override
Finalize.
virtual void initialize() override
Called before execute() is ever called so that data can be cleared.
Base class VectorPostprocessors operating on elemental variables.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
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.
const std::string & name() const
Get the name of the class.
Definition MooseBase.h:103
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 ...
Definition MooseBase.h:457
bool isNodal() const
Base class for VectorPostprocessors that need to do "sampling" of values in the domain.
Definition SamplerBase.h:38
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:91
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:69
virtual void initialize()
Initialize the datastructures.
virtual void threadJoin(const SamplerBase &y)
Join the values.
virtual void finalize()
Finalize the values.
void checkForStandardFieldVariableType(const MooseVariableFieldBase *const var_ptr, const std::string &var_param_name="variable") const
Checks whether the passed variable pointer corresponds to a regular single-valued field variable.
static InputParameters validParams()
Definition SamplerBase.C:24
Moose::StateArg determineState() const
Create a functor state argument that corresponds to the implicit state of this object.
Base class for user-specific data.
Definition UserObject.h:20
auto raw_value(const Eigen::Map< T > &in)
A structure that is used to evaluate Moose functors logically at an element/cell center.