https://mooseframework.inl.gov
Loading...
Searching...
No Matches
BuildArrayVariableAux.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 params.addCoupledVar("component_variables",
19 "The variables that make up each component of the output array variable.");
20 params.addClassDescription("Combines multiple standard variables into an array variable.");
21 return params;
22}
23
25 : ArrayAuxKernel(parameters), _component_dofs(coupledAllDofValues("component_variables"))
26{
27 // Check the number of component variables
28 if (_component_dofs.size() != _var.count())
29 paramError("variable",
30 "The array variable has ",
31 _var.count(),
32 " components, but ",
33 _component_dofs.size(),
34 " component variables were specified.");
35
36 // Make sure the FEType of each input variable matches the output type
37 for (const auto & var : getCoupledMooseVars())
38 if (var->feType() != _var.feType())
39 paramError("component_variables",
40 "The input and output variables must have the same FE type");
41}
42
43void
45{
46 const auto n_shapes = _var.numberOfDofs() / _var.count();
47 _local_sol.resize(n_shapes);
48 for (MooseIndex(n_shapes) j = 0; j < n_shapes; ++j)
49 {
50 _local_sol(j).resize(_var.count());
51 for (MooseIndex(_var.count()) i = 0; i < _var.count(); ++i)
52 _local_sol(j)(i) = (*_component_dofs[i])[j];
53 }
55}
registerMooseObject("MooseApp", BuildArrayVariableAux)
Base class for creating new auxiliary kernels and auxiliary boundary conditions.
Definition AuxKernel.h:28
DenseVector< OutputData > _local_sol
for holding local solution
Definition AuxKernel.h:165
MooseVariableField< ComputeValueType > & _var
This is a regular kernel so we cast to a regular MooseVariable, hides base _var.
Definition AuxKernel.h:113
static InputParameters validParams()
Definition AuxKernel.C:27
const std::vector< const VariableValue * > _component_dofs
static InputParameters validParams()
virtual void compute() override final
Computes the value and stores it in the solution vector.
BuildArrayVariableAux(const InputParameters &parameters)
const std::vector< MooseVariableFieldBase * > & getCoupledMooseVars() const
Get the list of all coupled variables.
Definition Coupleable.h:84
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.
void addCoupledVar(const std::string &name, const std::string &doc_string)
This method adds a coupled variable name pair.
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
const libMesh::FEType & feType() const
Get the type of finite element object.
virtual unsigned int numberOfDofs() const
Get the number of local DoFs.
unsigned int count() const
Get the number of components Note: For standard and vector variables, the number is one.
virtual void setDofValues(const DenseVector< DofValue > &values)=0
Set local DOF values and evaluate the values on quadrature points.