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 "BicrystalBoundingBoxICAction.h" 11 : #include "Factory.h" 12 : #include "FEProblem.h" 13 : #include "Conversion.h" 14 : 15 : registerMooseAction("PhaseFieldApp", BicrystalBoundingBoxICAction, "add_ic"); 16 : 17 : InputParameters 18 38 : BicrystalBoundingBoxICAction::validParams() 19 : { 20 38 : InputParameters params = Action::validParams(); 21 38 : params.addClassDescription("Constructs a bicrystal, where one grain is on the inside of " 22 : "the box and the other grain is the outside of the box"); 23 76 : params.addRequiredParam<std::string>("var_name_base", "specifies the base name of the variables"); 24 76 : params.addRequiredParam<unsigned int>("op_num", "Number of grains, should be 2"); 25 76 : params.addRequiredParam<Real>("x1", "The x coordinate of the lower left-hand corner of the box"); 26 76 : params.addRequiredParam<Real>("y1", "The y coordinate of the lower left-hand corner of the box"); 27 76 : params.addParam<Real>("z1", 0.0, "The z coordinate of the lower left-hand corner of the box"); 28 76 : params.addRequiredParam<Real>("x2", "The x coordinate of the upper right-hand corner of the box"); 29 76 : params.addRequiredParam<Real>("y2", "The y coordinate of the upper right-hand corner of the box"); 30 76 : params.addParam<Real>("z2", 0.0, "The z coordinate of the upper right-hand corner of the box"); 31 76 : params.addParam<std::vector<SubdomainName>>("block", 32 : "Block restriction for the initial condition"); 33 : 34 38 : return params; 35 0 : } 36 : 37 38 : BicrystalBoundingBoxICAction::BicrystalBoundingBoxICAction(const InputParameters & params) 38 : : Action(params), 39 38 : _var_name_base(getParam<std::string>("var_name_base")), 40 114 : _op_num(getParam<unsigned int>("op_num")) 41 : { 42 38 : if (_op_num != 2) 43 0 : paramError("op_num", "Must equal 2 for bicrystal ICs"); 44 38 : } 45 : 46 : void 47 38 : BicrystalBoundingBoxICAction::act() 48 : { 49 : #ifdef DEBUG 50 : Moose::err << "Inside the BicrystalBoundingBoxICAction Object" << std::endl; 51 : #endif 52 : 53 : // Loop through the number of order parameters 54 114 : for (unsigned int op = 0; op < _op_num; ++op) 55 : { 56 : // Create variable names 57 76 : const std::string var_name = _var_name_base + Moose::stringify(op); 58 : 59 : // Set parameters for BoundingBoxIC 60 152 : InputParameters poly_params = _factory.getValidParams("BoundingBoxIC"); 61 76 : poly_params.applyParameters(parameters()); 62 152 : poly_params.set<VariableName>("variable") = var_name; 63 76 : if (op == 0) 64 : { 65 : // Values for bounding box grain 66 38 : poly_params.set<Real>("inside") = 1.0; 67 38 : poly_params.set<Real>("outside") = 0.0; 68 : } 69 : else 70 : { 71 : // Values for matrix grain 72 38 : poly_params.set<Real>("inside") = 0.0; 73 38 : poly_params.set<Real>("outside") = 1.0; 74 : } 75 : 76 : // Add initial condition 77 228 : _problem->addInitialCondition( 78 76 : "BoundingBoxIC", "BicrystalBoundingBoxIC_" + Moose::stringify(op), poly_params); 79 76 : } 80 38 : }