https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
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
18registerMooseAction("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
52void
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);
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}
registerMooseAction("PhaseFieldApp", PFCRFFVariablesAction, "add_variable")
void ErrorVector unsigned int
static InputParameters validParams()
std::shared_ptr< FEProblemBase > & _problem
static MooseEnum getNonlinearVariableFamilies()
static libMesh::FEType feType(const InputParameters &params)
static MooseEnum getNonlinearVariableOrders()
static std::string variableType(const libMesh::FEType &fe_type, const bool is_fv=false, const bool is_array=false)
InputParameters getValidParams(const std::string &name) const
void applySpecificParameters(const InputParameters &common, const std::vector< std::string > &include, bool allow_private=false)
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
const std::string & type() const
const InputParameters & _pars
Automatically generates all the L variables for the RFF phase field crystal model.
static InputParameters validParams()
PFCRFFVariablesAction(const InputParameters &params)
const std::string _L_name_base
Factory & _factory
std::string stringify(const T &t)