LCOV - code coverage report
Current view: top level - src/actions - MaterialVectorAuxKernelAction.C (source / functions) Hit Total Coverage
Test: idaholab/moose phase_field: #31405 (292dce) with base fef103 Lines: 16 32 50.0 %
Date: 2025-09-04 07:55:36 Functions: 2 3 66.7 %
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 "MaterialVectorAuxKernelAction.h"
      11             : #include "Factory.h"
      12             : #include "Conversion.h"
      13             : #include "FEProblem.h"
      14             : 
      15             : registerMooseAction("PhaseFieldApp", MaterialVectorAuxKernelAction, "add_aux_kernel");
      16             : 
      17             : InputParameters
      18          11 : MaterialVectorAuxKernelAction::validParams()
      19             : {
      20          11 :   InputParameters params = Action::validParams();
      21          11 :   params.addClassDescription(
      22             :       "Outputs all components of the standard vector-valued properties specified");
      23          22 :   params.addRequiredParam<unsigned int>(
      24             :       "grain_num", "Value that specifies the number of grains to create aux kernels for.");
      25          22 :   params.addRequiredParam<std::vector<std::string>>(
      26             :       "variable_base", "Vector specifies the base name of the variables.");
      27          22 :   params.addRequiredParam<std::vector<MaterialPropertyName>>("property",
      28             :                                                              "The material property names.");
      29          22 :   params.addParam<bool>(
      30          22 :       "use_displaced_mesh", false, "Whether to use displaced mesh in the kernels.");
      31          11 :   return params;
      32           0 : }
      33             : 
      34          11 : MaterialVectorAuxKernelAction::MaterialVectorAuxKernelAction(const InputParameters & params)
      35             :   : Action(params),
      36          11 :     _grain_num(getParam<unsigned int>("grain_num")),
      37          22 :     _var_name_base(getParam<std::vector<std::string>>("variable_base")),
      38          11 :     _num_var(_var_name_base.size()),
      39          22 :     _prop(getParam<std::vector<MaterialPropertyName>>("property")),
      40          22 :     _num_prop(_prop.size())
      41             : {
      42          11 : }
      43             : 
      44             : void
      45           0 : MaterialVectorAuxKernelAction::act()
      46             : {
      47           0 :   if (_num_prop != _num_var)
      48           0 :     paramError("property", "variable_base and property must be vectors of the same size");
      49             : 
      50           0 :   for (unsigned int gr = 0; gr < _grain_num; ++gr)
      51           0 :     for (unsigned int val = 0; val < _num_var; ++val)
      52             :     {
      53           0 :       std::string var_name = _var_name_base[val] + Moose::stringify(gr);
      54             : 
      55           0 :       InputParameters params = _factory.getValidParams("MaterialStdVectorAux");
      56           0 :       params.set<AuxVariableName>("variable") = var_name;
      57           0 :       params.set<MaterialPropertyName>("property") = _prop[val];
      58           0 :       params.set<unsigned int>("index") = gr;
      59           0 :       params.set<bool>("use_displaced_mesh") = getParam<bool>("use_displaced_mesh");
      60             : 
      61           0 :       std::string aux_kernel_name = var_name;
      62           0 :       _problem->addAuxKernel("MaterialStdVectorAux", aux_kernel_name, params);
      63           0 :     }
      64           0 : }

Generated by: LCOV version 1.14