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 "CHPFCRFFSplitKernelAction.h" 11 : #include "Factory.h" 12 : #include "Conversion.h" 13 : #include "FEProblem.h" 14 : 15 : registerMooseAction("PhaseFieldApp", CHPFCRFFSplitKernelAction, "add_kernel"); 16 : 17 : InputParameters 18 11 : CHPFCRFFSplitKernelAction::validParams() 19 : { 20 11 : InputParameters params = Action::validParams(); 21 11 : params.addClassDescription("Creates the kernels for the transient Cahn-Hilliard equation for the " 22 : "RFF form of the phase field crystal model"); 23 22 : params.addRequiredParam<unsigned int>( 24 : "num_L", "specifies the number of complex L variables will be solved for"); 25 22 : params.addRequiredParam<NonlinearVariableName>("n_name", "Variable name used for the n variable"); 26 22 : params.addRequiredParam<std::string>("L_name_base", "Base name for the complex L variables"); 27 22 : params.addParam<MaterialPropertyName>("mob_name", "M", "The mobility used for n in this model"); 28 22 : MooseEnum log_options("tolerance cancelation expansion"); 29 22 : params.addRequiredParam<MooseEnum>( 30 : "log_approach", log_options, "Which approach will be used to handle the natural log"); 31 22 : params.addParam<Real>("tol", 1.0e-9, "Tolerance used when the tolerance approach is chosen"); 32 22 : params.addParam<Real>( 33 22 : "n_exp_terms", 4.0, "Number of terms used in the Taylor expansion of the natural log term"); 34 22 : params.addParam<bool>( 35 22 : "use_displaced_mesh", false, "Whether to use displaced mesh in the kernels"); 36 11 : return params; 37 11 : } 38 : 39 11 : CHPFCRFFSplitKernelAction::CHPFCRFFSplitKernelAction(const InputParameters & params) 40 : : Action(params), 41 11 : _num_L(getParam<unsigned int>("num_L")), 42 22 : _L_name_base(getParam<std::string>("L_name_base")), 43 22 : _n_name(getParam<NonlinearVariableName>("n_name")) 44 : { 45 11 : } 46 : 47 : void 48 11 : CHPFCRFFSplitKernelAction::act() 49 : { 50 : // Create the two kernels required for the n_variable, starting with the time derivative 51 11 : InputParameters poly_params = _factory.getValidParams("TimeDerivative"); 52 11 : poly_params.set<NonlinearVariableName>("variable") = _n_name; 53 22 : poly_params.set<bool>("use_displaced_mesh") = getParam<bool>("use_displaced_mesh"); 54 22 : _problem->addKernel("TimeDerivative", "IE_n", poly_params); 55 : 56 : // First, we have to create the vector containing the names of the real L variables 57 11 : std::vector<VariableName> real_v(_num_L); 58 66 : for (unsigned int l = 0; l < _num_L; ++l) 59 165 : real_v[l] = _L_name_base + Moose::stringify(l) + "_real"; 60 : 61 : // CHPFCRFF kernel 62 22 : poly_params = _factory.getValidParams("CHPFCRFF"); 63 11 : poly_params.applyParameters(parameters()); 64 11 : poly_params.set<NonlinearVariableName>("variable") = _n_name; 65 11 : poly_params.set<std::vector<VariableName>>("v") = real_v; 66 22 : _problem->addKernel("CHPFCRFF", "CH_bulk_n", poly_params); 67 11 : }