LCOV - code coverage report
Current view: top level - src/auxkernels - BuildArrayVariableAux.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 23 24 95.8 %
Date: 2025-07-17 01:28:37 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          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       14331 : BuildArrayVariableAux::validParams()
      16             : {
      17       14331 :   InputParameters params = ArrayAuxKernel::validParams();
      18       14331 :   params.addCoupledVar("component_variables",
      19             :                        "The variables that make up each component of the output array variable.");
      20       14331 :   params.addClassDescription("Combines multiple standard variables into an array variable.");
      21       14331 :   return params;
      22           0 : }
      23             : 
      24          34 : BuildArrayVariableAux::BuildArrayVariableAux(const InputParameters & parameters)
      25          34 :   : ArrayAuxKernel(parameters), _component_dofs(coupledAllDofValues("component_variables"))
      26             : {
      27             :   // Check the number of component variables
      28          34 :   if (_component_dofs.size() != _var.count())
      29           8 :     paramError("variable",
      30             :                "The array variable has ",
      31           4 :                _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          82 :   for (const auto & var : getCoupledMooseVars())
      38          56 :     if (var->feType() != _var.feType())
      39           4 :       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_local_dofs = _var.numberOfDofs();
      47         312 :   _local_sol.resize(n_local_dofs);
      48         624 :   for (MooseIndex(n_local_dofs) j = 0; j < n_local_dofs; ++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 : }

Generated by: LCOV version 1.14