https://mooseframework.inl.gov
Loading...
Searching...
No Matches
PolycrystalRandomICAction.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
16
19{
21 params.addClassDescription("Sets random polycrystal initial conditions for each order parameter");
22 params.addRequiredParam<unsigned int>("op_num", "number of order parameters to create");
23 params.addRequiredParam<std::string>("var_name_base", "specifies the base name of the variables");
24 MooseEnum typ_options("continuous discrete");
25 params.addRequiredParam<MooseEnum>("random_type",
26 typ_options,
27 "The type of random polycrystal initial condition. Whether "
28 "one order parameter is chosen to be 1 at each node or if "
29 "each other parameter continuously varies from 0 to 1");
30 params.addParam<std::vector<SubdomainName>>(
31 "block", {}, "Block restriction for the initial condition");
32
33 return params;
34}
35
37 : Action(params),
38 _op_num(getParam<unsigned int>("op_num")),
39 _var_name_base(getParam<std::string>("var_name_base")),
40 _random_type(getParam<MooseEnum>("random_type"))
41{
42}
43
44void
46{
47#ifdef DEBUG
48 Moose::err << "Inside the PolycrystalRandomICAction Object" << std::endl;
49#endif
50
51 // Loop through the number of order parameters
52 for (unsigned int op = 0; op < _op_num; op++)
53 {
54 // Set parameters for BoundingBoxIC
55 InputParameters poly_params = _factory.getValidParams("PolycrystalRandomIC");
56 poly_params.set<VariableName>("variable") = _var_name_base + Moose::stringify(op);
57 poly_params.set<unsigned int>("op_index") = op;
58 poly_params.set<unsigned int>("random_type") = _random_type;
59 poly_params.applySpecificParameters(parameters(), {"op_num", "block"});
60
61 // Add initial condition
62 _problem->addInitialCondition("PolycrystalRandomIC",
63 "ICs/PolycrystalICs/PolycrystalRandomIC_" + Moose::stringify(op),
64 poly_params);
65 }
66}
registerMooseAction("PhaseFieldApp", PolycrystalRandomICAction, "add_ic")
void ErrorVector unsigned int
static InputParameters validParams()
std::shared_ptr< FEProblemBase > & _problem
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)
T & set(const std::string &name, bool quiet_mode=false)
const InputParameters & parameters() const
Factory & _factory
Automatically generates all variables to model a polycrystal with op_num orderparameters.
PolycrystalRandomICAction(const InputParameters &params)
static InputParameters validParams()
std::string stringify(const T &t)