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 39 : PolycrystalVoronoiVoidICAction::validParams() 20 : { 21 39 : InputParameters params = Action::validParams(); 22 39 : params.addClassDescription( 23 : "Sets polycrystal Voronoi void initial conditions for each order parameter"); 24 39 : params += PolycrystalVoronoiVoidIC::actionParameters(); 25 78 : params.addRequiredParam<std::string>("var_name_base", "specifies the base name of the variables"); 26 39 : params.suppressParameter<VariableName>("variable"); 27 78 : params.addRequiredParam<UserObjectName>( 28 : "polycrystal_ic_uo", "UserObject for obtaining the polycrystal grain structure."); 29 78 : 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 78 : params.addParam<std::vector<SubdomainName>>( 35 : "block", {}, "Block restriction for the initial condition"); 36 : 37 39 : return params; 38 0 : } 39 : 40 39 : PolycrystalVoronoiVoidICAction::PolycrystalVoronoiVoidICAction(const InputParameters & params) 41 : : Action(params), 42 39 : _op_num(getParam<unsigned int>("op_num")), 43 78 : _var_name_base(getParam<std::string>("var_name_base")), 44 78 : _file_name(getParam<FileName>("file_name")) 45 : { 46 39 : } 47 : 48 : void 49 39 : PolycrystalVoronoiVoidICAction::act() 50 : { 51 : // Loop through the number of order parameters 52 285 : for (unsigned int op = 0; op < _op_num; op++) 53 : { 54 : // Set parameters for BoundingBoxIC 55 492 : InputParameters poly_params = _factory.getValidParams("PolycrystalVoronoiVoidIC"); 56 246 : poly_params.applyParameters(parameters()); 57 246 : poly_params.set<unsigned int>("op_index") = op; 58 738 : poly_params.set<VariableName>("variable") = _var_name_base + Moose::stringify(op); 59 492 : poly_params.set<MooseEnum>("structure_type") = "grains"; 60 492 : poly_params.set<UserObjectName>("polycrystal_ic_uo") = 61 246 : getParam<UserObjectName>("polycrystal_ic_uo"); 62 : 63 : // Add initial condition 64 738 : _problem->addInitialCondition( 65 492 : "PolycrystalVoronoiVoidIC", name() + "_" + Moose::stringify(op), poly_params); 66 246 : } 67 39 : }