www.mooseframework.org
HHPFCRFFSplitVariablesAction.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 
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", HHPFCRFFSplitVariablesAction, "add_variable");
19 
22 {
25  params.addParam<MooseEnum>(
26  "family",
27  familyEnum,
28  "Specifies the family of FE shape functions to use for the L variables");
30  params.addParam<MooseEnum>(
31  "order",
32  orderEnum,
33  "Specifies the order of the FE shape function to use for the L variables");
34  params.addParam<Real>("scaling", 1.0, "Specifies a scaling factor to apply to the L variables");
35  params.addRequiredParam<unsigned int>(
36  "num_L", "specifies the number of complex L variables will be solved for");
37  params.addRequiredParam<std::string>("L_name_base", "Base name for the complex L variables");
38  params.addParam<std::vector<SubdomainName>>(
39  "block", {}, "Block restriction for the variables and kernels");
40  return params;
41 }
42 
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 HHPFCRFFSplitVariablesAction Object\n";
55  Moose::err << "VariableBase: " << _L_name_base << "\torder: " << getParam<MooseEnum>("order")
56  << "\tfamily: " << getParam<MooseEnum>("family") << std::endl;
57 #endif
58 
59  // Loop through the number of L variables
60  for (unsigned int l = 0; l < _num_L; ++l)
61  {
62  // Create L base name
63  std::string L_name = _L_name_base + Moose::stringify(l);
64 
65  // Create real L variable
66  std::string real_name = L_name + "_real";
67 
68  const auto type = "MooseVariable";
69  auto params = _factory.getValidParams(type);
70  params.applySpecificParameters(_pars, {"family", "order", "block"});
71  params.set<std::vector<Real>>("scaling") = {getParam<Real>("scaling")};
72 
73  _problem->addVariable(type, real_name, params);
74 
75  if (l > 0)
76  {
77  // Create imaginary L variable IF l > 0
78  std::string imag_name = L_name + "_imag";
79 
80  _problem->addVariable(type, imag_name, params);
81  }
82  }
83 }
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)
HHPFCRFFSplitVariablesAction(const InputParameters &params)
InputParameters getValidParams(const std::string &name) const
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()
registerMooseAction("PhaseFieldApp", HHPFCRFFSplitVariablesAction, "add_variable")
const std::string & type() const
std::string stringify(const T &t)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const InputParameters & _pars
std::shared_ptr< FEProblemBase > & _problem
void ErrorVector unsigned int