Line data Source code
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 : 12 : registerMooseObject("MooseApp", BuildArrayVariableAux); 13 : 14 : InputParameters 15 3123 : BuildArrayVariableAux::validParams() 16 : { 17 3123 : InputParameters params = ArrayAuxKernel::validParams(); 18 12492 : params.addCoupledVar("component_variables", 19 : "The variables that make up each component of the output array variable."); 20 3123 : params.addClassDescription("Combines multiple standard variables into an array variable."); 21 3123 : return params; 22 0 : } 23 : 24 32 : BuildArrayVariableAux::BuildArrayVariableAux(const InputParameters & parameters) 25 64 : : ArrayAuxKernel(parameters), _component_dofs(coupledAllDofValues("component_variables")) 26 : { 27 : // Check the number of component variables 28 32 : if (_component_dofs.size() != _var.count()) 29 6 : paramError("variable", 30 : "The array variable has ", 31 3 : _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 81 : for (const auto & var : getCoupledMooseVars()) 38 55 : if (var->feType() != _var.feType()) 39 6 : paramError("component_variables", 40 : "The input and output variables must have the same FE type"); 41 26 : } 42 : 43 : void 44 312 : BuildArrayVariableAux::compute() 45 : { 46 312 : const auto n_shapes = _var.numberOfDofs() / _var.count(); 47 312 : _local_sol.resize(n_shapes); 48 624 : for (MooseIndex(n_shapes) j = 0; j < n_shapes; ++j) 49 : { 50 312 : _local_sol(j).resize(_var.count()); 51 936 : for (MooseIndex(_var.count()) i = 0; i < _var.count(); ++i) 52 624 : _local_sol(j)(i) = (*_component_dofs[i])[j]; 53 : } 54 312 : _var.setDofValues(_local_sol); 55 312 : }