LCOV - code coverage report
Current view: top level - src/actions - HHPFCRFFSplitKernelAction.C (source / functions) Hit Total Coverage
Test: idaholab/moose phase_field: #32971 (54bef8) with base c6cf66 Lines: 79 79 100.0 %
Date: 2026-05-29 20:38:39 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 "HHPFCRFFSplitKernelAction.h"
      11             : #include "Factory.h"
      12             : #include "FEProblem.h"
      13             : #include "Conversion.h"
      14             : 
      15             : registerMooseAction("PhaseFieldApp", HHPFCRFFSplitKernelAction, "add_kernel");
      16             : 
      17             : InputParameters
      18          27 : HHPFCRFFSplitKernelAction::validParams()
      19             : {
      20          27 :   InputParameters params = Action::validParams();
      21          27 :   params.addClassDescription(
      22             :       "Set up kernels for the rational function fit (RFF) phase field crystal model");
      23          54 :   params.addRequiredParam<unsigned int>(
      24             :       "num_L", "specifies the number of complex L variables will be solved for");
      25          54 :   params.addRequiredParam<VariableName>("n_name", "Variable name used for the n variable");
      26          54 :   params.addRequiredParam<std::string>("L_name_base", "Base name for the complex L variables");
      27          54 :   params.addParam<MaterialPropertyName>("mob_name", "M", "The mobility used for n in this model");
      28          54 :   MooseEnum log_options("tolerance cancelation expansion");
      29          54 :   params.addRequiredParam<MooseEnum>(
      30             :       "log_approach", log_options, "Which approach will be used to handle the natural log");
      31          54 :   params.addParam<Real>("tol", 1.0e-9, "Tolerance used when the tolerance approach is chosen");
      32          54 :   params.addParam<Real>(
      33          54 :       "n_exp_terms", 4, "Number of terms used in the Taylor expansion of the natural log term");
      34          54 :   params.addParam<bool>(
      35          54 :       "use_displaced_mesh", false, "Whether to use displaced mesh in the kernels");
      36          27 :   return params;
      37          27 : }
      38             : 
      39          27 : HHPFCRFFSplitKernelAction::HHPFCRFFSplitKernelAction(const InputParameters & params)
      40             :   : Action(params),
      41          27 :     _num_L(getParam<unsigned int>("num_L")),
      42          54 :     _L_name_base(getParam<std::string>("L_name_base")),
      43          54 :     _n_name(getParam<VariableName>("n_name"))
      44             : {
      45          27 : }
      46             : 
      47             : void
      48          27 : HHPFCRFFSplitKernelAction::act()
      49             : {
      50             :   // Loop over the L_variables
      51         162 :   for (unsigned int l = 0; l < _num_L; ++l)
      52             :   {
      53             :     // Create L base name
      54         135 :     std::string L_name = _L_name_base + Moose::stringify(l);
      55             : 
      56             :     // Create real  and imaginary L variable names
      57         135 :     std::string real_name = L_name + "_real";
      58         135 :     std::string imag_name = L_name + "_imag";
      59             : 
      60             :     //
      61             :     // Create the kernels for the real L variable
      62             :     //
      63             : 
      64             :     // Create the diffusion kernel for L_real_l
      65         270 :     InputParameters poly_params = _factory.getValidParams("Diffusion");
      66         270 :     poly_params.set<NonlinearVariableName>("variable") = real_name;
      67         270 :     poly_params.set<bool>("use_displaced_mesh") = getParam<bool>("use_displaced_mesh");
      68         270 :     _problem->addKernel("Diffusion", "diff_" + real_name, poly_params);
      69             : 
      70             :     // Create the (alpha^R_m L^R_m) term
      71         270 :     poly_params = _factory.getValidParams("HHPFCRFF");
      72         270 :     poly_params.set<NonlinearVariableName>("variable") = real_name;
      73         135 :     poly_params.set<bool>("positive") = true;
      74         405 :     poly_params.set<MaterialPropertyName>("prop_name") = "alpha_R_" + Moose::stringify(l);
      75         270 :     poly_params.set<bool>("use_displaced_mesh") = getParam<bool>("use_displaced_mesh");
      76         270 :     _problem->addKernel("HHPFCRFF", "HH1_" + real_name, poly_params);
      77             : 
      78             :     // **Create the -(alpha^I_m L^I_m) term
      79         135 :     if (l > 0)
      80             :     {
      81         216 :       poly_params = _factory.getValidParams("HHPFCRFF");
      82         216 :       poly_params.set<NonlinearVariableName>("variable") = real_name;
      83         108 :       poly_params.set<bool>("positive") = false;
      84         216 :       poly_params.set<std::vector<VariableName>>("coupled_var").push_back(imag_name);
      85         216 :       poly_params.set<bool>("use_displaced_mesh") = getParam<bool>("use_displaced_mesh");
      86         324 :       poly_params.set<MaterialPropertyName>("prop_name") = "alpha_I_" + Moose::stringify(l);
      87         216 :       _problem->addKernel("HHPFCRFF", "HH2_" + real_name, poly_params);
      88             :     }
      89             : 
      90             :     // **Create the -(A^R_m n) term
      91         270 :     poly_params = _factory.getValidParams("HHPFCRFF");
      92         270 :     poly_params.set<NonlinearVariableName>("variable") = real_name;
      93         135 :     poly_params.set<bool>("positive") = false;
      94         135 :     poly_params.set<std::vector<VariableName>>("coupled_var").push_back(_n_name);
      95         270 :     poly_params.set<bool>("use_displaced_mesh") = getParam<bool>("use_displaced_mesh");
      96         405 :     poly_params.set<MaterialPropertyName>("prop_name") = "A_R_" + Moose::stringify(l);
      97         270 :     _problem->addKernel("HHPFCRFF", "HH3_" + real_name, poly_params);
      98             : 
      99             :     //
     100             :     // Create the kernels for the imaginary L variable, l > 0
     101             :     //
     102         135 :     if (l > 0)
     103             :     {
     104             :       // Create the diffusion kernel for L_imag_l
     105         216 :       InputParameters poly_params = _factory.getValidParams("Diffusion");
     106         216 :       poly_params.set<NonlinearVariableName>("variable") = imag_name;
     107         216 :       poly_params.set<bool>("use_displaced_mesh") = getParam<bool>("use_displaced_mesh");
     108         216 :       _problem->addKernel("Diffusion", "diff_" + imag_name, poly_params);
     109             : 
     110             :       // **Create the (alpha^R_m L^I_m) term
     111         216 :       poly_params = _factory.getValidParams("HHPFCRFF");
     112         216 :       poly_params.set<NonlinearVariableName>("variable") = imag_name;
     113         108 :       poly_params.set<bool>("positive") = true;
     114         216 :       poly_params.set<bool>("use_displaced_mesh") = getParam<bool>("use_displaced_mesh");
     115         324 :       poly_params.set<MaterialPropertyName>("prop_name") = "alpha_R_" + Moose::stringify(l);
     116         216 :       _problem->addKernel("HHPFCRFF", "HH1_" + imag_name, poly_params);
     117             : 
     118             :       // **Create the (alpha^I_m L^R_m) term
     119         216 :       poly_params = _factory.getValidParams("HHPFCRFF");
     120         216 :       poly_params.set<NonlinearVariableName>("variable") = imag_name;
     121         108 :       poly_params.set<bool>("positive") = true;
     122         216 :       poly_params.set<std::vector<VariableName>>("coupled_var").push_back(real_name);
     123         216 :       poly_params.set<bool>("use_displaced_mesh") = getParam<bool>("use_displaced_mesh");
     124         324 :       poly_params.set<MaterialPropertyName>("prop_name") = "alpha_I_" + Moose::stringify(l);
     125         216 :       _problem->addKernel("HHPFCRFF", "HH2_" + imag_name, poly_params);
     126             : 
     127             :       // **Create the -(A^I_m n) term
     128         216 :       poly_params = _factory.getValidParams("HHPFCRFF");
     129         216 :       poly_params.set<NonlinearVariableName>("variable") = imag_name;
     130         108 :       poly_params.set<bool>("positive") = false;
     131         108 :       poly_params.set<std::vector<VariableName>>("coupled_var").push_back(_n_name);
     132         216 :       poly_params.set<bool>("use_displaced_mesh") = getParam<bool>("use_displaced_mesh");
     133         324 :       poly_params.set<MaterialPropertyName>("prop_name") = "A_I_" + Moose::stringify(l);
     134         216 :       _problem->addKernel("HHPFCRFF", "HH3_" + imag_name, poly_params);
     135         108 :     }
     136         135 :   }
     137          27 : }

Generated by: LCOV version 1.14