LCOV - code coverage report
Current view: top level - src/actions - PolycrystalColoringICAction.C (source / functions) Hit Total Coverage
Test: idaholab/moose phase_field: #31405 (292dce) with base fef103 Lines: 35 36 97.2 %
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 "PolycrystalColoringICAction.h"
      11             : #include "Factory.h"
      12             : #include "FEProblem.h"
      13             : #include "Conversion.h"
      14             : #include "PolycrystalICTools.h"
      15             : 
      16             : registerMooseAction("PhaseFieldApp", PolycrystalColoringICAction, "add_ic");
      17             : 
      18             : InputParameters
      19         736 : PolycrystalColoringICAction::validParams()
      20             : {
      21         736 :   InputParameters params = Action::validParams();
      22         736 :   params.addClassDescription("Action to create ICs for polycrystal variables from a UserObject");
      23        1472 :   params.addRequiredParam<unsigned int>("op_num", "number of order parameters to create");
      24        1472 :   params.addRequiredParam<std::string>("var_name_base", "specifies the base name of the variables");
      25        1472 :   params.addRequiredParam<UserObjectName>("polycrystal_ic_uo", "Optional: TODO");
      26        1472 :   params.addParam<std::vector<SubdomainName>>(
      27             :       "block", {}, "Block restriction for the initial condition");
      28        1472 :   params.addParam<bool>(
      29        1472 :       "linearized_interface", false, "Whether to use linearized interface or the standard model");
      30        1472 :   params.addParam<Real>("bound_value",
      31        1472 :                         5.0,
      32             :                         "Bound value used to keep variable "
      33             :                         "between +/-bound. Must be positive.");
      34        1472 :   params.addParamNamesToGroup("linearized_interface", "LinearizedInterface");
      35        1472 :   params.addParamNamesToGroup("bound_value", "LinearizedInterface");
      36             : 
      37         736 :   return params;
      38           0 : }
      39             : 
      40         736 : PolycrystalColoringICAction::PolycrystalColoringICAction(const InputParameters & params)
      41             :   : Action(params),
      42         736 :     _op_num(getParam<unsigned int>("op_num")),
      43        1472 :     _var_name_base(getParam<std::string>("var_name_base")),
      44        2208 :     _linearized_interface(getParam<bool>("linearized_interface"))
      45             : {
      46         736 : }
      47             : 
      48             : void
      49         736 : PolycrystalColoringICAction::act()
      50             : {
      51             :   // Loop through the number of order parameters
      52        5732 :   for (unsigned int op = 0; op < _op_num; op++)
      53             :   {
      54        4996 :     std::string IC_type = "PolycrystalColoringIC";
      55        4996 :     if (_linearized_interface)
      56             :       IC_type = "PolycrystalColoringICLinearizedInterface";
      57             : 
      58             :     // Set parameters for IC
      59        4996 :     InputParameters poly_params = _factory.getValidParams(IC_type);
      60       14988 :     poly_params.set<VariableName>("variable") = _var_name_base + Moose::stringify(op);
      61        4996 :     poly_params.set<unsigned int>("op_index") = op;
      62        4996 :     poly_params.applySpecificParameters(parameters(), {"polycrystal_ic_uo", "block"});
      63        9992 :     poly_params.set<UserObjectName>("polycrystal_ic_uo") =
      64        4996 :         getParam<UserObjectName>("polycrystal_ic_uo");
      65        4996 :     if (_linearized_interface)
      66         143 :       poly_params.applySpecificParameters(parameters(),
      67             :                                           {"polycrystal_ic_uo", "block", "bound_value"});
      68             :     else
      69        4853 :       poly_params.applySpecificParameters(parameters(), {"polycrystal_ic_uo", "block"});
      70             : 
      71             :     // Add initial condition
      72        4996 :     _problem->addInitialCondition(IC_type, IC_type + Moose::stringify(op), poly_params);
      73        4996 :   }
      74         736 : }

Generated by: LCOV version 1.14