LCOV - code coverage report
Current view: top level - src/actions - PolycrystalVoronoiVoidICAction.C (source / functions) Hit Total Coverage
Test: idaholab/moose phase_field: #31405 (292dce) with base fef103 Lines: 28 29 96.6 %
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 "PolycrystalVoronoiVoidICAction.h"
      11             : #include "PolycrystalVoronoiVoidIC.h"
      12             : #include "Factory.h"
      13             : #include "FEProblem.h"
      14             : #include "Conversion.h"
      15             : 
      16             : registerMooseAction("PhaseFieldApp", PolycrystalVoronoiVoidICAction, "add_ic");
      17             : 
      18             : InputParameters
      19          47 : PolycrystalVoronoiVoidICAction::validParams()
      20             : {
      21          47 :   InputParameters params = Action::validParams();
      22          47 :   params.addClassDescription(
      23             :       "Sets polycrystal Voronoi void initial conditions for each order parameter");
      24          47 :   params += PolycrystalVoronoiVoidIC::actionParameters();
      25          94 :   params.addRequiredParam<std::string>("var_name_base", "specifies the base name of the variables");
      26          47 :   params.suppressParameter<VariableName>("variable");
      27          94 :   params.addRequiredParam<UserObjectName>(
      28             :       "polycrystal_ic_uo", "UserObject for obtaining the polycrystal grain structure.");
      29          94 :   params.addParam<FileName>(
      30             :       "file_name",
      31             :       "",
      32             :       "File containing grain centroids, if file_name is provided, the centroids "
      33             :       "from the file will be used.");
      34          94 :   params.addParam<std::vector<SubdomainName>>(
      35             :       "block", {}, "Block restriction for the initial condition");
      36             : 
      37          47 :   return params;
      38           0 : }
      39             : 
      40          47 : PolycrystalVoronoiVoidICAction::PolycrystalVoronoiVoidICAction(const InputParameters & params)
      41             :   : Action(params),
      42          47 :     _op_num(getParam<unsigned int>("op_num")),
      43          94 :     _var_name_base(getParam<std::string>("var_name_base")),
      44          94 :     _file_name(getParam<FileName>("file_name"))
      45             : {
      46          47 : }
      47             : 
      48             : void
      49          47 : PolycrystalVoronoiVoidICAction::act()
      50             : {
      51             :   // Loop through the number of order parameters
      52         325 :   for (unsigned int op = 0; op < _op_num; op++)
      53             :   {
      54             :     // Set parameters for BoundingBoxIC
      55         556 :     InputParameters poly_params = _factory.getValidParams("PolycrystalVoronoiVoidIC");
      56         278 :     poly_params.applyParameters(parameters());
      57         278 :     poly_params.set<unsigned int>("op_index") = op;
      58         834 :     poly_params.set<VariableName>("variable") = _var_name_base + Moose::stringify(op);
      59         556 :     poly_params.set<MooseEnum>("structure_type") = "grains";
      60         556 :     poly_params.set<UserObjectName>("polycrystal_ic_uo") =
      61         278 :         getParam<UserObjectName>("polycrystal_ic_uo");
      62             : 
      63             :     // Add initial condition
      64         834 :     _problem->addInitialCondition(
      65         556 :         "PolycrystalVoronoiVoidIC", name() + "_" + Moose::stringify(op), poly_params);
      66         278 :   }
      67          47 : }

Generated by: LCOV version 1.14