https://mooseframework.inl.gov
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 
10 #include "BuildArrayVariableAux.h"
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 
43 void
45 {
46  const auto n_local_dofs = _var.numberOfDofs();
47  _local_sol.resize(n_local_dofs);
48  for (MooseIndex(n_local_dofs) j = 0; j < n_local_dofs; ++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 }
const libMesh::FEType & feType() const
Get the type of finite element object.
virtual unsigned int numberOfDofs() const
Get the number of local DoFs.
static InputParameters validParams()
virtual void compute() override final
Computes the value and stores it in the solution vector.
registerMooseObject("MooseApp", BuildArrayVariableAux)
unsigned int count() const
Get the number of components Note: For standard and vector variables, the number is one...
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
BuildArrayVariableAux(const InputParameters &parameters)
DenseVector< OutputData > _local_sol
for holding local solution
Definition: AuxKernel.h:240
const std::vector< const VariableValue * > _component_dofs
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 ...
void addCoupledVar(const std::string &name, const std::string &doc_string)
This method adds a coupled variable name pair.
const std::vector< MooseVariableFieldBase * > & getCoupledMooseVars() const
Get the list of all coupled variables.
Definition: Coupleable.h:70
MooseVariableField< ComputeValueType > & _var
This is a regular kernel so we cast to a regular MooseVariable.
Definition: AuxKernel.h:174
virtual void setDofValues(const DenseVector< OutputData > &values)=0
Set local DOF values and evaluate the values on quadrature points.
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...
static InputParameters validParams()
Definition: AuxKernel.C:27
Base class for creating new auxiliary kernels and auxiliary boundary conditions.
Definition: AuxKernel.h:36