https://mooseframework.inl.gov
Loading...
Searching...
No Matches
BicrystalBoundingBoxICAction.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("Constructs a bicrystal, where one grain is on the inside of "
22 "the box and the other grain is the outside of the box");
23 params.addRequiredParam<std::string>("var_name_base", "specifies the base name of the variables");
24 params.addRequiredParam<unsigned int>("op_num", "Number of grains, should be 2");
25 params.addRequiredParam<Real>("x1", "The x coordinate of the lower left-hand corner of the box");
26 params.addRequiredParam<Real>("y1", "The y coordinate of the lower left-hand corner of the box");
27 params.addParam<Real>("z1", 0.0, "The z coordinate of the lower left-hand corner of the box");
28 params.addRequiredParam<Real>("x2", "The x coordinate of the upper right-hand corner of the box");
29 params.addRequiredParam<Real>("y2", "The y coordinate of the upper right-hand corner of the box");
30 params.addParam<Real>("z2", 0.0, "The z coordinate of the upper right-hand corner of the box");
31 params.addParam<std::vector<SubdomainName>>("block",
32 "Block restriction for the initial condition");
33
34 return params;
35}
36
38 : Action(params),
39 _var_name_base(getParam<std::string>("var_name_base")),
40 _op_num(getParam<unsigned int>("op_num"))
41{
42 if (_op_num != 2)
43 paramError("op_num", "Must equal 2 for bicrystal ICs");
44}
45
46void
48{
49#ifdef DEBUG
50 Moose::err << "Inside the BicrystalBoundingBoxICAction Object" << std::endl;
51#endif
52
53 // Loop through the number of order parameters
54 for (unsigned int op = 0; op < _op_num; ++op)
55 {
56 // Create variable names
57 const std::string var_name = _var_name_base + Moose::stringify(op);
58
59 // Set parameters for BoundingBoxIC
60 InputParameters poly_params = _factory.getValidParams("BoundingBoxIC");
61 poly_params.applyParameters(parameters());
62 poly_params.set<VariableName>("variable") = var_name;
63 if (op == 0)
64 {
65 // Values for bounding box grain
66 poly_params.set<Real>("inside") = 1.0;
67 poly_params.set<Real>("outside") = 0.0;
68 }
69 else
70 {
71 // Values for matrix grain
72 poly_params.set<Real>("inside") = 0.0;
73 poly_params.set<Real>("outside") = 1.0;
74 }
75
76 // Add initial condition
77 _problem->addInitialCondition(
78 "BoundingBoxIC", "BicrystalBoundingBoxIC_" + Moose::stringify(op), poly_params);
79 }
80}
registerMooseAction("PhaseFieldApp", BicrystalBoundingBoxICAction, "add_ic")
void ErrorVector unsigned int
static InputParameters validParams()
std::shared_ptr< FEProblemBase > & _problem
Bicrystal using a bounding box.
BicrystalBoundingBoxICAction(const InputParameters &params)
InputParameters getValidParams(const std::string &name) const
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)
void applyParameters(const InputParameters &common, const std::vector< std::string > &exclude={}, const bool allow_private=false)
const InputParameters & parameters() const
void paramError(const std::string &param, Args... args) const
Factory & _factory
std::string stringify(const T &t)