LCOV - code coverage report
Current view: top level - src/actions - PolycrystalKernelAction.C (source / functions) Hit Total Coverage
Test: idaholab/moose phase_field: #33358 (34476d) with base 4fcf7b Lines: 56 57 98.2 %
Date: 2026-07-17 19:54:19 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 "PolycrystalKernelAction.h"
      11             : #include "Factory.h"
      12             : #include "Conversion.h"
      13             : #include "FEProblem.h"
      14             : 
      15             : registerMooseAction("PhaseFieldApp", PolycrystalKernelAction, "add_kernel");
      16             : 
      17             : InputParameters
      18         442 : PolycrystalKernelAction::validParams()
      19             : {
      20         442 :   InputParameters params = Action::validParams();
      21         442 :   params.addClassDescription(
      22             :       "Set up ACGrGrPoly, ACInterface, TimeDerivative, and ACGBPoly kernels");
      23         884 :   params.addRequiredParam<unsigned int>(
      24             :       "op_num", "specifies the total number of grains (deformed + recrystallized) to create");
      25         884 :   params.addRequiredParam<std::string>("var_name_base", "specifies the base name of the variables");
      26         884 :   params.addParam<VariableName>("c", "Name of coupled concentration variable");
      27         884 :   params.addParam<Real>("en_ratio", 1.0, "Ratio of surface to GB energy");
      28         884 :   params.addParam<unsigned int>("ndef", 0, "specifies the number of deformed grains to create");
      29         884 :   params.addParam<bool>("implicit", true, "Whether kernels are implicit or not");
      30         884 :   params.addParam<bool>(
      31         884 :       "use_displaced_mesh", false, "Whether to use displaced mesh in the kernels");
      32         884 :   params.addParam<bool>("variable_mobility",
      33         884 :                         true,
      34             :                         "The mobility is a function of any MOOSE variable (if "
      35             :                         "this is set to false, L must be constant over the "
      36             :                         "entire domain!)");
      37         884 :   params.addCoupledVar("coupled_variables",
      38             :                        "Vector of nonlinear variable arguments that L depends on");
      39             : 
      40         442 :   return params;
      41           0 : }
      42             : 
      43         442 : PolycrystalKernelAction::PolycrystalKernelAction(const InputParameters & params)
      44             :   : Action(params),
      45         442 :     _op_num(getParam<unsigned int>("op_num")),
      46        1326 :     _var_name_base(getParam<std::string>("var_name_base"))
      47             : {
      48         442 : }
      49             : 
      50             : void
      51         442 : PolycrystalKernelAction::act()
      52             : {
      53        3028 :   for (unsigned int op = 0; op < _op_num; ++op)
      54             :   {
      55             :     //
      56             :     // Create variable names
      57             :     //
      58             : 
      59        5172 :     std::string var_name = _var_name_base + Moose::stringify(op);
      60             :     std::vector<VariableName> v;
      61        2586 :     v.resize(_op_num - 1);
      62             : 
      63             :     unsigned int ind = 0;
      64       21900 :     for (unsigned int j = 0; j < _op_num; ++j)
      65       19314 :       if (j != op)
      66       50184 :         v[ind++] = _var_name_base + Moose::stringify(j);
      67             : 
      68             :     //
      69             :     // Set up ACGrGrPoly kernels
      70             :     //
      71             : 
      72             :     {
      73        5172 :       InputParameters params = _factory.getValidParams("ACGrGrPoly");
      74        5172 :       params.set<NonlinearVariableName>("variable") = var_name;
      75        5172 :       params.set<std::vector<VariableName>>("v") = v;
      76        2586 :       params.applyParameters(parameters());
      77             : 
      78        2586 :       std::string kernel_name = "ACBulk_" + var_name;
      79        5172 :       _problem->addKernel("ACGrGrPoly", kernel_name, params);
      80        2586 :     }
      81             : 
      82             :     //
      83             :     // Set up ACInterface kernels
      84             :     //
      85             : 
      86             :     {
      87        5172 :       InputParameters params = _factory.getValidParams("ACInterface");
      88        5172 :       params.set<NonlinearVariableName>("variable") = var_name;
      89        2586 :       params.applyParameters(parameters());
      90             : 
      91        2586 :       std::string kernel_name = "ACInt_" + var_name;
      92        5172 :       _problem->addKernel("ACInterface", kernel_name, params);
      93        2586 :     }
      94             : 
      95             :     //
      96             :     // Set up TimeDerivative kernels
      97             :     //
      98             : 
      99             :     {
     100        5172 :       InputParameters params = _factory.getValidParams("TimeDerivative");
     101        5172 :       params.set<NonlinearVariableName>("variable") = var_name;
     102        2586 :       params.set<bool>("implicit") = true;
     103        2586 :       params.applyParameters(parameters());
     104             : 
     105        2586 :       std::string kernel_name = "IE_" + var_name;
     106        5172 :       _problem->addKernel("TimeDerivative", kernel_name, params);
     107        2586 :     }
     108             : 
     109             :     //
     110             :     // Set up optional ACGBPoly bubble interaction kernels
     111             :     //
     112             : 
     113        5172 :     if (isParamValid("c"))
     114             :     {
     115         140 :       InputParameters params = _factory.getValidParams("ACGBPoly");
     116         140 :       params.set<NonlinearVariableName>("variable") = var_name;
     117         210 :       params.set<std::vector<VariableName>>("c") = {getParam<VariableName>("c")};
     118          70 :       params.applyParameters(parameters());
     119             : 
     120          70 :       std::string kernel_name = "ACBubInteraction_" + var_name;
     121         140 :       _problem->addKernel("ACGBPoly", kernel_name, params);
     122          70 :     }
     123        2586 :   }
     124         582 : }

Generated by: LCOV version 1.14