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 11 : PolycrystalRandomICAction::validParams() 19 : { 20 11 : InputParameters params = Action::validParams(); 21 11 : params.addClassDescription("Sets random polycrystal initial conditions for each order parameter"); 22 22 : params.addRequiredParam<unsigned int>("op_num", "number of order parameters to create"); 23 22 : params.addRequiredParam<std::string>("var_name_base", "specifies the base name of the variables"); 24 22 : MooseEnum typ_options("continuous discrete"); 25 22 : 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 22 : params.addParam<std::vector<SubdomainName>>( 31 : "block", {}, "Block restriction for the initial condition"); 32 : 33 11 : return params; 34 11 : } 35 : 36 11 : PolycrystalRandomICAction::PolycrystalRandomICAction(const InputParameters & params) 37 : : Action(params), 38 11 : _op_num(getParam<unsigned int>("op_num")), 39 22 : _var_name_base(getParam<std::string>("var_name_base")), 40 33 : _random_type(getParam<MooseEnum>("random_type")) 41 : { 42 11 : } 43 : 44 : void 45 11 : 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 81 : for (unsigned int op = 0; op < _op_num; op++) 53 : { 54 : // Set parameters for BoundingBoxIC 55 140 : InputParameters poly_params = _factory.getValidParams("PolycrystalRandomIC"); 56 210 : poly_params.set<VariableName>("variable") = _var_name_base + Moose::stringify(op); 57 70 : poly_params.set<unsigned int>("op_index") = op; 58 70 : poly_params.set<unsigned int>("random_type") = _random_type; 59 70 : poly_params.applySpecificParameters(parameters(), {"op_num", "block"}); 60 : 61 : // Add initial condition 62 210 : _problem->addInitialCondition("PolycrystalRandomIC", 63 70 : "ICs/PolycrystalICs/PolycrystalRandomIC_" + Moose::stringify(op), 64 : poly_params); 65 70 : } 66 11 : }