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

Generated by: LCOV version 1.14