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 "PolycrystalElasticDrivingForceAction.h" 11 : #include "Factory.h" 12 : #include "FEProblem.h" 13 : #include "Conversion.h" 14 : 15 : registerMooseAction("PhaseFieldApp", PolycrystalElasticDrivingForceAction, "add_kernel"); 16 : 17 : InputParameters 18 0 : PolycrystalElasticDrivingForceAction::validParams() 19 : { 20 0 : InputParameters params = Action::validParams(); 21 0 : params.addClassDescription("Action that adds the elastic driving force for each order parameter"); 22 0 : params.addRequiredParam<unsigned int>("op_num", "specifies the number of grains to create"); 23 0 : params.addRequiredParam<std::string>("var_name_base", "specifies the base name of the variables"); 24 0 : params.addParam<bool>( 25 0 : "use_displaced_mesh", false, "Whether to use displaced mesh in the kernels"); 26 0 : params.addParam<std::string>("base_name", 27 : "Optional parameter that allows the user to define " 28 : "multiple mechanics material systems on the same " 29 : "block, i.e. for multiple phases"); 30 0 : return params; 31 0 : } 32 : 33 0 : PolycrystalElasticDrivingForceAction::PolycrystalElasticDrivingForceAction( 34 0 : const InputParameters & params) 35 : : Action(params), 36 0 : _op_num(getParam<unsigned int>("op_num")), 37 0 : _var_name_base(getParam<std::string>("var_name_base")), 38 0 : _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""), 39 0 : _elasticity_tensor_name(_base_name + "elasticity_tensor") 40 : { 41 0 : } 42 : 43 : void 44 0 : PolycrystalElasticDrivingForceAction::act() 45 : { 46 : #ifdef DEBUG 47 : Moose::err << "Inside the PolycrystalElasticDrivingForceAction Object\n"; 48 : Moose::err << "var name base:" << _var_name_base << std::flush; 49 : #endif 50 : 51 0 : for (unsigned int op = 0; op < _op_num; ++op) 52 : { 53 : // Create variable name 54 0 : std::string var_name = _var_name_base + Moose::stringify(op); 55 : 56 : // Create Stiffness derivative name 57 : MaterialPropertyName D_stiff_name = 58 0 : derivativePropertyNameFirst(_elasticity_tensor_name, var_name); 59 : 60 : // Set name of kernel being created 61 0 : std::string kernel_type = "ACGrGrElasticDrivingForce"; 62 : 63 : // Set the actual parameters for the kernel 64 0 : InputParameters poly_params = _factory.getValidParams(kernel_type); 65 0 : poly_params.set<NonlinearVariableName>("variable") = var_name; 66 0 : poly_params.set<MaterialPropertyName>("D_tensor_name") = D_stiff_name; 67 0 : poly_params.set<bool>("use_displaced_mesh") = getParam<bool>("use_displaced_mesh"); 68 : 69 0 : std::string kernel_name = "AC_ElasticDrivingForce_" + var_name; 70 : 71 : // Create kernel 72 0 : _problem->addKernel(kernel_type, kernel_name, poly_params); 73 0 : } 74 0 : }