www.mooseframework.org
PolycrystalColoringICAction.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 "PolycrystalICTools.h"
15 
16 registerMooseAction("PhaseFieldApp", PolycrystalColoringICAction, "add_ic");
17 
20 {
22  params.addClassDescription("Action to create ICs for polycrystal variables from a UserObject");
23  params.addRequiredParam<unsigned int>("op_num", "number of order parameters to create");
24  params.addRequiredParam<std::string>("var_name_base", "specifies the base name of the variables");
25  params.addRequiredParam<UserObjectName>("polycrystal_ic_uo", "Optional: TODO");
26  params.addParam<std::vector<SubdomainName>>(
27  "block", {}, "Block restriction for the initial condition");
28  params.addParam<bool>(
29  "linearized_interface", false, "Whether to use linearized interface or the standard model");
30  params.addParam<Real>("bound_value",
31  5.0,
32  "Bound value used to keep variable "
33  "between +/-bound. Must be positive.");
34  params.addParamNamesToGroup("linearized_interface", "LinearizedInterface");
35  params.addParamNamesToGroup("bound_value", "LinearizedInterface");
36 
37  return params;
38 }
39 
41  : Action(params),
42  _op_num(getParam<unsigned int>("op_num")),
43  _var_name_base(getParam<std::string>("var_name_base")),
44  _linearized_interface(getParam<bool>("linearized_interface"))
45 {
46 }
47 
48 void
50 {
51  // Loop through the number of order parameters
52  for (unsigned int op = 0; op < _op_num; op++)
53  {
54  std::string IC_type = "PolycrystalColoringIC";
56  IC_type = "PolycrystalColoringICLinearizedInterface";
57 
58  // Set parameters for IC
59  InputParameters poly_params = _factory.getValidParams(IC_type);
60  poly_params.set<VariableName>("variable") = _var_name_base + Moose::stringify(op);
61  poly_params.set<unsigned int>("op_index") = op;
62  poly_params.applySpecificParameters(parameters(), {"polycrystal_ic_uo", "block"});
63  poly_params.set<UserObjectName>("polycrystal_ic_uo") =
64  getParam<UserObjectName>("polycrystal_ic_uo");
66  poly_params.applySpecificParameters(parameters(),
67  {"polycrystal_ic_uo", "block", "bound_value"});
68  else
69  poly_params.applySpecificParameters(parameters(), {"polycrystal_ic_uo", "block"});
70 
71  // Add initial condition
72  _problem->addInitialCondition(IC_type, IC_type + Moose::stringify(op), poly_params);
73  }
74 }
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)
PolycrystalColoringICAction(const InputParameters &params)
T & set(const std::string &name, bool quiet_mode=false)
InputParameters getValidParams(const std::string &name) const
static InputParameters validParams()
void addRequiredParam(const std::string &name, const std::string &doc_string)
Factory & _factory
static InputParameters validParams()
registerMooseAction("PhaseFieldApp", PolycrystalColoringICAction, "add_ic")
std::string stringify(const T &t)
Random Voronoi tesselation polycrystal action.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void addClassDescription(const std::string &doc_string)
std::shared_ptr< FEProblemBase > & _problem
const InputParameters & parameters() const
void ErrorVector unsigned int
void addParamNamesToGroup(const std::string &space_delim_names, const std::string group_name)