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 "BicrystalCircleGrainICAction.h" 11 : #include "Factory.h" 12 : #include "FEProblem.h" 13 : #include "Conversion.h" 14 : 15 : registerMooseAction("PhaseFieldApp", BicrystalCircleGrainICAction, "add_ic"); 16 : 17 : InputParameters 18 108 : BicrystalCircleGrainICAction::validParams() 19 : { 20 108 : InputParameters params = Action::validParams(); 21 108 : params.addClassDescription("Bicrystal with a circular grain and an embedding outer grain"); 22 216 : params.addRequiredParam<std::string>("var_name_base", "specifies the base name of the variables"); 23 216 : params.addRequiredParam<unsigned int>("op_num", "Number of grains, should be 2"); 24 216 : params.addRequiredParam<Real>("radius", "Void radius"); 25 216 : params.addRequiredParam<Real>("x", "The x coordinate of the circle grain center"); 26 216 : params.addRequiredParam<Real>("y", "The y coordinate of the circle grain center"); 27 216 : params.addParam<Real>("z", 0.0, "The z coordinate of the circle grain center"); 28 216 : params.addParam<Real>( 29 216 : "int_width", 0.0, "The interfacial width of the void surface. Defaults to sharp interface"); 30 216 : params.addParam<bool>( 31 216 : "3D_sphere", true, "in 3D, whether the smaller grain is a spheres or columnar grain"); 32 216 : params.addParam<std::vector<SubdomainName>>("block", 33 : "Block restriction for the initial condition"); 34 : 35 108 : return params; 36 0 : } 37 : 38 108 : BicrystalCircleGrainICAction::BicrystalCircleGrainICAction(const InputParameters & params) 39 : : Action(params), 40 108 : _var_name_base(getParam<std::string>("var_name_base")), 41 216 : _op_num(getParam<unsigned int>("op_num")), 42 216 : _radius(getParam<Real>("radius")), 43 216 : _x(getParam<Real>("x")), 44 216 : _y(getParam<Real>("y")), 45 216 : _z(getParam<Real>("z")), 46 216 : _int_width(getParam<Real>("int_width")), 47 324 : _3D_sphere(getParam<bool>("3D_sphere")) 48 : { 49 108 : if (_op_num != 2) 50 0 : paramError("op_num", "op_num must equal 2 for bicrystal ICs"); 51 108 : } 52 : 53 : void 54 108 : BicrystalCircleGrainICAction::act() 55 : { 56 : // Loop through the number of order parameters 57 324 : for (unsigned int op = 0; op < _op_num; op++) 58 : { 59 : // Create variable names 60 216 : std::string var_name = _var_name_base + Moose::stringify(op); 61 : 62 : // Set parameters for SmoothCircleIC 63 432 : InputParameters poly_params = _factory.getValidParams("SmoothCircleIC"); 64 432 : poly_params.set<VariableName>("variable") = var_name; 65 216 : poly_params.set<Real>("x1") = _x; 66 216 : poly_params.set<Real>("y1") = _y; 67 216 : poly_params.set<Real>("z1") = _z; 68 216 : poly_params.set<Real>("radius") = _radius; 69 216 : poly_params.set<Real>("int_width") = _int_width; 70 216 : poly_params.set<bool>("3D_spheres") = _3D_sphere; 71 216 : if (op == 0) 72 : { 73 : // Values for circle grain 74 108 : poly_params.set<Real>("invalue") = 1.0; 75 108 : poly_params.set<Real>("outvalue") = 0.0; 76 : } 77 : else 78 : { 79 : // Values for matrix grain 80 108 : poly_params.set<Real>("invalue") = 0.0; 81 108 : poly_params.set<Real>("outvalue") = 1.0; 82 : } 83 216 : poly_params.applySpecificParameters(_pars, {"block"}); 84 : 85 : // Add initial condition 86 648 : _problem->addInitialCondition( 87 216 : "SmoothCircleIC", "BicrystalCircleGrainIC_" + Moose::stringify(op), poly_params); 88 216 : } 89 108 : }