LCOV - code coverage report
Current view: top level - src/actions - MaterialVectorGradAuxKernelAction.C (source / functions) Hit Total Coverage
Test: idaholab/moose phase_field: #31405 (292dce) with base fef103 Lines: 25 27 92.6 %
Date: 2025-09-04 07:55:36 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 "MaterialVectorGradAuxKernelAction.h"
      11             : #include "Factory.h"
      12             : #include "Parser.h"
      13             : #include "Conversion.h"
      14             : #include "FEProblem.h"
      15             : #include "MooseMesh.h"
      16             : 
      17             : registerMooseAction("PhaseFieldApp", MaterialVectorGradAuxKernelAction, "add_aux_kernel");
      18             : 
      19             : InputParameters
      20          11 : MaterialVectorGradAuxKernelAction::validParams()
      21             : {
      22          11 :   InputParameters params = MaterialVectorAuxKernelAction::validParams();
      23          11 :   params.addClassDescription("Outputs all components of the gradient of the real standard "
      24             :                              "vector-valued properties specified");
      25          11 :   return params;
      26           0 : }
      27             : 
      28          11 : MaterialVectorGradAuxKernelAction::MaterialVectorGradAuxKernelAction(const InputParameters & params)
      29          11 :   : MaterialVectorAuxKernelAction(params)
      30             : {
      31          11 : }
      32             : 
      33             : void
      34          11 : MaterialVectorGradAuxKernelAction::act()
      35             : {
      36          11 :   if (_num_prop != _num_var)
      37           0 :     paramError("property", "variable_base and property must be vectors of the same size");
      38             : 
      39             :   // mesh dimension required for gradient variables
      40          11 :   unsigned int dim = _mesh->dimension();
      41             :   // For Specifying the components of the gradient terms
      42          11 :   const std::vector<char> suffix = {'x', 'y', 'z'};
      43             : 
      44          33 :   for (unsigned int gr = 0; gr < _grain_num; ++gr)
      45          44 :     for (unsigned int val = 0; val < _num_var; ++val)
      46          66 :       for (unsigned int x = 0; x < dim; ++x)
      47             :       {
      48          88 :         std::string var_name = _var_name_base[val] + Moose::stringify(gr) + "_" + suffix[x];
      49             : 
      50          88 :         InputParameters params = _factory.getValidParams("MaterialStdVectorRealGradientAux");
      51          88 :         params.set<AuxVariableName>("variable") = var_name;
      52          44 :         params.set<MaterialPropertyName>("property") = _prop[val];
      53          44 :         params.set<unsigned int>("component") = x;
      54          44 :         params.set<unsigned int>("index") = gr;
      55          88 :         params.set<bool>("use_displaced_mesh") = getParam<bool>("use_displaced_mesh");
      56             : 
      57          44 :         std::string aux_kernel_name = var_name;
      58          88 :         _problem->addAuxKernel("MaterialStdVectorRealGradientAux", aux_kernel_name, params);
      59          44 :       }
      60          11 : }

Generated by: LCOV version 1.14