www.mooseframework.org
PolycrystalStoredEnergyAction.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 "Conversion.h"
13 #include "FEProblem.h"
14 
15 registerMooseAction("PhaseFieldApp", PolycrystalStoredEnergyAction, "add_kernel");
16 
19 {
21  params.addClassDescription("Action that adds the contribution of stored energy associated with "
22  "dislocations to grain growth models");
23  params.addRequiredParam<unsigned int>("op_num",
24  "specifies the total number of OPs representing "
25  "all grains (deformed + undeformed "
26  "(recrystallized)) to create");
27  params.addRequiredParam<std::string>("var_name_base", "specifies the base name of the variables");
28  params.addParam<VariableName>("c", "Name of coupled concentration variable");
29  params.addRequiredParam<unsigned int>("deformed_grain_num",
30  "specifies the number of deformed grains to create");
31  params.addParam<VariableName>("T", "Name of temperature variable");
32  params.addParam<bool>(
33  "use_displaced_mesh", false, "Whether to use displaced mesh in the kernels");
34  params.addRequiredParam<UserObjectName>("grain_tracker",
35  "The GrainTracker UserObject to get values from.");
36  return params;
37 }
38 
40  : Action(params),
41  _op_num(getParam<unsigned int>("op_num")),
42  _var_name_base(getParam<std::string>("var_name_base")),
43  _deformed_grain_num(getParam<unsigned int>("deformed_grain_num"))
44 {
45 }
46 
47 void
49 {
50  for (unsigned int op = 0; op < _op_num; ++op)
51  {
52  //
53  // Create variable names
54  //
55 
56  std::string var_name = _var_name_base + Moose::stringify(op);
57  std::vector<VariableName> v;
58  v.resize(_op_num - 1);
59 
60  unsigned int ind = 0;
61  for (unsigned int j = 0; j < _op_num; ++j)
62  if (j != op)
63  v[ind++] = _var_name_base + Moose::stringify(j);
64 
65  //
66  // Set up ACSEDGPoly Stored Energy in Deformed Grains kernels
67  //
68 
69  InputParameters params = _factory.getValidParams("ACSEDGPoly");
70  params.set<NonlinearVariableName>("variable") = var_name;
71  params.set<std::vector<VariableName>>("v") = v;
72  params.set<UserObjectName>("grain_tracker") = getParam<UserObjectName>("grain_tracker");
73  params.set<bool>("use_displaced_mesh") = getParam<bool>("use_displaced_mesh");
74  params.set<unsigned int>("deformed_grain_num") = getParam<unsigned int>("deformed_grain_num");
75  params.set<unsigned int>("op_index") = op;
76 
77  std::string kernel_name = "ACStoredEnergy_" + var_name;
78  _problem->addKernel("ACSEDGPoly", kernel_name, params);
79  }
80 }
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
T & set(const std::string &name, bool quiet_mode=false)
InputParameters getValidParams(const std::string &name) const
void addRequiredParam(const std::string &name, const std::string &doc_string)
Factory & _factory
static InputParameters validParams()
const unsigned int _op_num
number of grains to create
std::string stringify(const T &t)
const std::string _var_name_base
base name for the order parameter variables
static const std::string v
Definition: NS.h:82
void addClassDescription(const std::string &doc_string)
std::shared_ptr< FEProblemBase > & _problem
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
registerMooseAction("PhaseFieldApp", PolycrystalStoredEnergyAction, "add_kernel")
void ErrorVector unsigned int
PolycrystalStoredEnergyAction(const InputParameters &params)
Action that sets up ACSEDGPoly Kernels that adds the stored energy contribution to grain growth model...