www.mooseframework.org
PFCRFFVariablesAction.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 
20 template <>
21 InputParameters
23 {
24  InputParameters params = validParams<Action>();
25  MooseEnum familyEnum = AddVariableAction::getNonlinearVariableFamilies();
26  params.addParam<MooseEnum>(
27  "family",
28  familyEnum,
29  "Specifies the family of FE shape functions to use for the L variables");
30  MooseEnum orderEnum = AddVariableAction::getNonlinearVariableOrders();
31  params.addParam<MooseEnum>(
32  "order",
33  orderEnum,
34  "Specifies the order of the FE shape function to use for the L variables");
35  params.addParam<Real>("scaling", 1.0, "Specifies a scaling factor to apply to the L variables");
36  params.addRequiredParam<unsigned int>(
37  "num_L", "specifies the number of complex L variables will be solved for");
38  params.addRequiredParam<std::string>("L_name_base", "Base name for the complex L variables");
39 
40  return params;
41 }
42 
43 PFCRFFVariablesAction::PFCRFFVariablesAction(const InputParameters & params)
44  : Action(params),
45  _num_L(getParam<unsigned int>("num_L")),
46  _L_name_base(getParam<std::string>("L_name_base"))
47 {
48 }
49 
50 void
52 {
53 #ifdef DEBUG
54  Moose::err << "Inside the PFCRFFVariablesAction Object\n";
55  Moose::err << "VariableBase: " << _L_name_base << "\torder: " << getParam<MooseEnum>("order")
56  << "\tfamily: " << getParam<MooseEnum>("family") << std::endl;
57 #endif
58 
59  auto fe_type = AddVariableAction::feType(_pars);
60  auto type = AddVariableAction::determineType(fe_type, 1);
61  auto var_params = _factory.getValidParams(type);
62 
63  var_params.applySpecificParameters(_pars, {"family", "order"});
64  var_params.set<std::vector<Real>>("scaling") = {getParam<Real>("scaling")};
65 
66  // Loop through the number of L variables
67  for (unsigned int l = 0; l < _num_L; ++l)
68  {
69  // Create L base name
70  std::string L_name = _L_name_base + Moose::stringify(l);
71 
72  // Create real L variable
73  const std::string real_name = L_name + "_real";
74  _problem->addVariable(type, real_name, var_params);
75 
76  if (l > 0)
77  {
78  // Create imaginary L variable IF l > 0
79  std::string imag_name = L_name + "_imag";
80  _problem->addVariable(type, imag_name, var_params);
81  }
82  }
83 }
registerMooseAction
registerMooseAction("PhaseFieldApp", PFCRFFVariablesAction, "add_variable")
PFCRFFVariablesAction.h
PFCRFFVariablesAction::_L_name_base
const std::string _L_name_base
Definition: PFCRFFVariablesAction.h:33
PFCRFFVariablesAction::_num_L
const unsigned int _num_L
Definition: PFCRFFVariablesAction.h:32
PFCRFFVariablesAction::PFCRFFVariablesAction
PFCRFFVariablesAction(const InputParameters &params)
Definition: PFCRFFVariablesAction.C:43
PFCRFFVariablesAction
Automatically generates all the L variables for the RFF phase field crystal model.
Definition: PFCRFFVariablesAction.h:24
PFCRFFVariablesAction::act
virtual void act()
Definition: PFCRFFVariablesAction.C:51
validParams< PFCRFFVariablesAction >
InputParameters validParams< PFCRFFVariablesAction >()
Definition: PFCRFFVariablesAction.C:22