LCOV - code coverage report
Current view: top level - src/actions - PolycrystalRandomICAction.C (source / functions) Hit Total Coverage
Test: idaholab/moose phase_field: #31405 (292dce) with base fef103 Lines: 26 26 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 "PolycrystalRandomICAction.h"
      11             : #include "Factory.h"
      12             : #include "FEProblem.h"
      13             : #include "Conversion.h"
      14             : 
      15             : registerMooseAction("PhaseFieldApp", PolycrystalRandomICAction, "add_ic");
      16             : 
      17             : InputParameters
      18          13 : PolycrystalRandomICAction::validParams()
      19             : {
      20          13 :   InputParameters params = Action::validParams();
      21          13 :   params.addClassDescription("Sets random polycrystal initial conditions for each order parameter");
      22          26 :   params.addRequiredParam<unsigned int>("op_num", "number of order parameters to create");
      23          26 :   params.addRequiredParam<std::string>("var_name_base", "specifies the base name of the variables");
      24          26 :   MooseEnum typ_options("continuous discrete");
      25          26 :   params.addRequiredParam<MooseEnum>("random_type",
      26             :                                      typ_options,
      27             :                                      "The type of random polycrystal initial condition. Whether "
      28             :                                      "one order parameter is chosen to be 1 at each node or if "
      29             :                                      "each other parameter continuously varies from 0 to 1");
      30          26 :   params.addParam<std::vector<SubdomainName>>(
      31             :       "block", {}, "Block restriction for the initial condition");
      32             : 
      33          13 :   return params;
      34          13 : }
      35             : 
      36          13 : PolycrystalRandomICAction::PolycrystalRandomICAction(const InputParameters & params)
      37             :   : Action(params),
      38          13 :     _op_num(getParam<unsigned int>("op_num")),
      39          26 :     _var_name_base(getParam<std::string>("var_name_base")),
      40          39 :     _random_type(getParam<MooseEnum>("random_type"))
      41             : {
      42          13 : }
      43             : 
      44             : void
      45          13 : PolycrystalRandomICAction::act()
      46             : {
      47             : #ifdef DEBUG
      48             :   Moose::err << "Inside the PolycrystalRandomICAction Object" << std::endl;
      49             : #endif
      50             : 
      51             :   // Loop through the number of order parameters
      52         103 :   for (unsigned int op = 0; op < _op_num; op++)
      53             :   {
      54             :     // Set parameters for BoundingBoxIC
      55         180 :     InputParameters poly_params = _factory.getValidParams("PolycrystalRandomIC");
      56         270 :     poly_params.set<VariableName>("variable") = _var_name_base + Moose::stringify(op);
      57          90 :     poly_params.set<unsigned int>("op_index") = op;
      58          90 :     poly_params.set<unsigned int>("random_type") = _random_type;
      59          90 :     poly_params.applySpecificParameters(parameters(), {"op_num", "block"});
      60             : 
      61             :     // Add initial condition
      62         270 :     _problem->addInitialCondition("PolycrystalRandomIC",
      63          90 :                                   "ICs/PolycrystalICs/PolycrystalRandomIC_" + Moose::stringify(op),
      64             :                                   poly_params);
      65          90 :   }
      66          13 : }

Generated by: LCOV version 1.14