LCOV - code coverage report
Current view: top level - src/actions - PolycrystalKernelAction.C (source / functions) Hit Total Coverage
Test: idaholab/moose phase_field: #31405 (292dce) with base fef103 Lines: 57 58 98.3 %
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 "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         728 : PolycrystalKernelAction::validParams()
      19             : {
      20         728 :   InputParameters params = Action::validParams();
      21         728 :   params.addClassDescription(
      22             :       "Set up ACGrGrPoly, ACInterface, TimeDerivative, and ACGBPoly kernels");
      23        1456 :   params.addRequiredParam<unsigned int>(
      24             :       "op_num", "specifies the total number of grains (deformed + recrystallized) to create");
      25        1456 :   params.addRequiredParam<std::string>("var_name_base", "specifies the base name of the variables");
      26        1456 :   params.addParam<VariableName>("c", "Name of coupled concentration variable");
      27        1456 :   params.addParam<Real>("en_ratio", 1.0, "Ratio of surface to GB energy");
      28        1456 :   params.addParam<unsigned int>("ndef", 0, "specifies the number of deformed grains to create");
      29        1456 :   params.addParam<bool>("implicit", true, "Whether kernels are implicit or not");
      30        1456 :   params.addParam<bool>(
      31        1456 :       "use_displaced_mesh", false, "Whether to use displaced mesh in the kernels");
      32        1456 :   params.addParam<bool>("variable_mobility",
      33        1456 :                         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        1456 :   params.addCoupledVar("args", "Vector of nonlinear variable arguments that L depends on");
      38        1456 :   params.deprecateCoupledVar("args", "coupled_variables", "02/27/2024");
      39             : 
      40         728 :   return params;
      41           0 : }
      42             : 
      43         728 : PolycrystalKernelAction::PolycrystalKernelAction(const InputParameters & params)
      44             :   : Action(params),
      45         728 :     _op_num(getParam<unsigned int>("op_num")),
      46        2184 :     _var_name_base(getParam<std::string>("var_name_base"))
      47             : {
      48         728 : }
      49             : 
      50             : void
      51         728 : PolycrystalKernelAction::act()
      52             : {
      53        5132 :   for (unsigned int op = 0; op < _op_num; ++op)
      54             :   {
      55             :     //
      56             :     // Create variable names
      57             :     //
      58             : 
      59        8808 :     std::string var_name = _var_name_base + Moose::stringify(op);
      60             :     std::vector<VariableName> v;
      61        4404 :     v.resize(_op_num - 1);
      62             : 
      63             :     unsigned int ind = 0;
      64       37510 :     for (unsigned int j = 0; j < _op_num; ++j)
      65       33106 :       if (j != op)
      66       86106 :         v[ind++] = _var_name_base + Moose::stringify(j);
      67             : 
      68             :     //
      69             :     // Set up ACGrGrPoly kernels
      70             :     //
      71             : 
      72             :     {
      73        8808 :       InputParameters params = _factory.getValidParams("ACGrGrPoly");
      74        8808 :       params.set<NonlinearVariableName>("variable") = var_name;
      75        8808 :       params.set<std::vector<VariableName>>("v") = v;
      76        4404 :       params.applyParameters(parameters());
      77             : 
      78        4404 :       std::string kernel_name = "ACBulk_" + var_name;
      79        8808 :       _problem->addKernel("ACGrGrPoly", kernel_name, params);
      80        4404 :     }
      81             : 
      82             :     //
      83             :     // Set up ACInterface kernels
      84             :     //
      85             : 
      86             :     {
      87        8808 :       InputParameters params = _factory.getValidParams("ACInterface");
      88        8808 :       params.set<NonlinearVariableName>("variable") = var_name;
      89        4404 :       params.applyParameters(parameters());
      90             : 
      91        4404 :       std::string kernel_name = "ACInt_" + var_name;
      92        8808 :       _problem->addKernel("ACInterface", kernel_name, params);
      93        4404 :     }
      94             : 
      95             :     //
      96             :     // Set up TimeDerivative kernels
      97             :     //
      98             : 
      99             :     {
     100        8808 :       InputParameters params = _factory.getValidParams("TimeDerivative");
     101        8808 :       params.set<NonlinearVariableName>("variable") = var_name;
     102        4404 :       params.set<bool>("implicit") = true;
     103        4404 :       params.applyParameters(parameters());
     104             : 
     105        4404 :       std::string kernel_name = "IE_" + var_name;
     106        8808 :       _problem->addKernel("TimeDerivative", kernel_name, params);
     107        4404 :     }
     108             : 
     109             :     //
     110             :     // Set up optional ACGBPoly bubble interaction kernels
     111             :     //
     112             : 
     113        8808 :     if (isParamValid("c"))
     114             :     {
     115         220 :       InputParameters params = _factory.getValidParams("ACGBPoly");
     116         220 :       params.set<NonlinearVariableName>("variable") = var_name;
     117         330 :       params.set<std::vector<VariableName>>("c") = {getParam<VariableName>("c")};
     118         110 :       params.applyParameters(parameters());
     119             : 
     120         110 :       std::string kernel_name = "ACBubInteraction_" + var_name;
     121         220 :       _problem->addKernel("ACGBPoly", kernel_name, params);
     122         110 :     }
     123        4404 :   }
     124         948 : }

Generated by: LCOV version 1.14