https://mooseframework.inl.gov
PFCRFFVariablesAction.C
Go to the documentation of this file.
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 "PFCRFFVariablesAction.h"
11 #include "Factory.h"
12 #include "FEProblem.h"
13 #include "Conversion.h"
14 #include "AddVariableAction.h"
15 
16 #include "libmesh/string_to_enum.h"
17 
18 registerMooseAction("PhaseFieldApp", PFCRFFVariablesAction, "add_variable");
19 
22 {
25  params.addClassDescription("Creates the L nonlinear variables for the Cahn-Hilliard equation for "
26  "the RFF form of the phase field crystal model");
27  params.addParam<MooseEnum>(
28  "family",
29  familyEnum,
30  "Specifies the family of FE shape functions to use for the L variables");
32  params.addParam<MooseEnum>(
33  "order",
34  orderEnum,
35  "Specifies the order of the FE shape function to use for the L variables");
36  params.addParam<Real>("scaling", 1.0, "Specifies a scaling factor to apply to the L variables");
37  params.addRequiredParam<unsigned int>(
38  "num_L", "specifies the number of complex L variables will be solved for");
39  params.addRequiredParam<std::string>("L_name_base", "Base name for the complex L variables");
40  params.addParam<std::vector<SubdomainName>>(
41  "block", {}, "Block restriction for the variables and kernels");
42  return params;
43 }
44 
46  : Action(params),
47  _num_L(getParam<unsigned int>("num_L")),
48  _L_name_base(getParam<std::string>("L_name_base"))
49 {
50 }
51 
52 void
54 {
55 #ifdef DEBUG
56  Moose::err << "Inside the PFCRFFVariablesAction Object\n";
57  Moose::err << "VariableBase: " << _L_name_base << "\torder: " << getParam<MooseEnum>("order")
58  << "\tfamily: " << getParam<MooseEnum>("family") << std::endl;
59 #endif
60 
61  auto fe_type = AddVariableAction::feType(_pars);
62  auto type = AddVariableAction::variableType(fe_type);
63  auto var_params = _factory.getValidParams(type);
64 
65  var_params.applySpecificParameters(_pars, {"family", "order", "block"});
66  var_params.set<std::vector<Real>>("scaling") = {getParam<Real>("scaling")};
67 
68  // Loop through the number of L variables
69  for (unsigned int l = 0; l < _num_L; ++l)
70  {
71  // Create L base name
72  std::string L_name = _L_name_base + Moose::stringify(l);
73 
74  // Create real L variable
75  const std::string real_name = L_name + "_real";
76  _problem->addVariable(type, real_name, var_params);
77 
78  if (l > 0)
79  {
80  // Create imaginary L variable IF l > 0
81  std::string imag_name = L_name + "_imag";
82  _problem->addVariable(type, imag_name, var_params);
83  }
84  }
85 }
const std::string _L_name_base
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void applySpecificParameters(const InputParameters &common, const std::vector< std::string > &include, bool allow_private=false)
registerMooseAction("PhaseFieldApp", PFCRFFVariablesAction, "add_variable")
const unsigned int _num_L
InputParameters getValidParams(const std::string &name) const
PFCRFFVariablesAction(const InputParameters &params)
static InputParameters validParams()
void addRequiredParam(const std::string &name, const std::string &doc_string)
static MooseEnum getNonlinearVariableFamilies()
Factory & _factory
Automatically generates all the L variables for the RFF phase field crystal model.
static InputParameters validParams()
static MooseEnum getNonlinearVariableOrders()
const std::string & type() const
static std::string variableType(const libMesh::FEType &fe_type, const bool is_fv=false, const bool is_array=false)
std::string stringify(const T &t)
static libMesh::FEType feType(const InputParameters &params)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const InputParameters & _pars
void addClassDescription(const std::string &doc_string)
std::shared_ptr< FEProblemBase > & _problem
void ErrorVector unsigned int