LCOV - code coverage report
Current view: top level - src/actions - PolycrystalStoredEnergyAction.C (source / functions) Hit Total Coverage
Test: idaholab/moose phase_field: #30119 (aa6062) with base 79f9bd Lines: 35 36 97.2 %
Date: 2025-03-20 17:26:41 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://www.mooseframework.org
       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 "PolycrystalStoredEnergyAction.h"
      11             : #include "Factory.h"
      12             : #include "Conversion.h"
      13             : #include "FEProblem.h"
      14             : 
      15             : registerMooseAction("PhaseFieldApp", PolycrystalStoredEnergyAction, "add_kernel");
      16             : 
      17             : InputParameters
      18           4 : PolycrystalStoredEnergyAction::validParams()
      19             : {
      20           4 :   InputParameters params = Action::validParams();
      21           4 :   params.addClassDescription("Action that adds the contribution of stored energy associated with "
      22             :                              "dislocations to grain growth models");
      23           8 :   params.addRequiredParam<unsigned int>("op_num",
      24             :                                         "specifies the total number of OPs representing "
      25             :                                         "all grains (deformed + undeformed "
      26             :                                         "(recrystallized)) to create");
      27           8 :   params.addRequiredParam<std::string>("var_name_base", "specifies the base name of the variables");
      28           8 :   params.addParam<VariableName>("c", "Name of coupled concentration variable");
      29           8 :   params.addRequiredParam<unsigned int>("deformed_grain_num",
      30             :                                         "specifies the number of deformed grains to create");
      31           8 :   params.addParam<VariableName>("T", "Name of temperature variable");
      32           8 :   params.addParam<bool>(
      33           8 :       "use_displaced_mesh", false, "Whether to use displaced mesh in the kernels");
      34           8 :   params.addRequiredParam<UserObjectName>("grain_tracker",
      35             :                                           "The GrainTracker UserObject to get values from.");
      36           4 :   return params;
      37           0 : }
      38             : 
      39           4 : PolycrystalStoredEnergyAction::PolycrystalStoredEnergyAction(const InputParameters & params)
      40             :   : Action(params),
      41           4 :     _op_num(getParam<unsigned int>("op_num")),
      42           8 :     _var_name_base(getParam<std::string>("var_name_base")),
      43          12 :     _deformed_grain_num(getParam<unsigned int>("deformed_grain_num"))
      44             : {
      45           4 : }
      46             : 
      47             : void
      48           4 : PolycrystalStoredEnergyAction::act()
      49             : {
      50          36 :   for (unsigned int op = 0; op < _op_num; ++op)
      51             :   {
      52             :     //
      53             :     // Create variable names
      54             :     //
      55             : 
      56          64 :     std::string var_name = _var_name_base + Moose::stringify(op);
      57             :     std::vector<VariableName> v;
      58          32 :     v.resize(_op_num - 1);
      59             : 
      60             :     unsigned int ind = 0;
      61         288 :     for (unsigned int j = 0; j < _op_num; ++j)
      62         256 :       if (j != op)
      63         672 :         v[ind++] = _var_name_base + Moose::stringify(j);
      64             : 
      65             :     //
      66             :     // Set up ACSEDGPoly Stored Energy in Deformed Grains kernels
      67             :     //
      68             : 
      69          64 :     InputParameters params = _factory.getValidParams("ACSEDGPoly");
      70          64 :     params.set<NonlinearVariableName>("variable") = var_name;
      71          32 :     params.set<std::vector<VariableName>>("v") = v;
      72          96 :     params.set<UserObjectName>("grain_tracker") = getParam<UserObjectName>("grain_tracker");
      73          64 :     params.set<bool>("use_displaced_mesh") = getParam<bool>("use_displaced_mesh");
      74          64 :     params.set<unsigned int>("deformed_grain_num") = getParam<unsigned int>("deformed_grain_num");
      75          32 :     params.set<unsigned int>("op_index") = op;
      76             : 
      77          32 :     std::string kernel_name = "ACStoredEnergy_" + var_name;
      78          64 :     _problem->addKernel("ACSEDGPoly", kernel_name, params);
      79          32 :   }
      80           4 : }

Generated by: LCOV version 1.14