https://mooseframework.inl.gov
ReconPhaseVarIC.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 
10 #include "ReconPhaseVarIC.h"
11 
12 registerMooseObject("PhaseFieldApp", ReconPhaseVarIC);
13 
16 {
18  params.addClassDescription(
19  "Sets the initial condition of the phase weights from the EBSD reader");
20  params.addRequiredParam<UserObjectName>("ebsd_reader",
21  "The EBSDReader object holding the EBSD data");
22  params.addRequiredParam<unsigned int>("phase", "EBSD phase number this variable is to represent");
23  return params;
24 }
25 
27  : InitialCondition(parameters),
28  _mesh(_fe_problem.mesh()),
29  _ebsd_reader(getUserObject<EBSDReader>("ebsd_reader")),
30  _phase(getParam<unsigned int>("phase")),
31  _node_to_phase_weight_map(_ebsd_reader.getNodeToPhaseWeightMap())
32 {
33 }
34 
35 Real
36 ReconPhaseVarIC::value(const Point & /*p*/)
37 {
38  // Return error if current node is NULL
39  if (_current_node == nullptr)
40  mooseError("_current_node is reporting NULL");
41 
42  // Make sure the _current_node is in the _node_to_phase_weight_map (return error if not in map)
43  std::map<dof_id_type, std::vector<Real>>::const_iterator it =
45  if (it == _node_to_phase_weight_map.end())
46  mooseError("The following node id is not in the node map: ", _current_node->id());
47 
48  // make sure we have enough phase weights
49  if (_phase >= it->second.size())
50  mooseError("Requested an out-of-range phase number");
51 
52  return it->second[_phase];
53 }
virtual Real value(const Point &)
ReconPhaseVarIC initializes a single order parameter to represent a phase obtained form an EBSDReader...
MeshBase & mesh
static InputParameters validParams()
void addRequiredParam(const std::string &name, const std::string &doc_string)
ReconPhaseVarIC(const InputParameters &parameters)
const Node * _current_node
const std::map< dof_id_type, std::vector< Real > > & _node_to_phase_weight_map
A GeneralUserObject that reads an EBSD file and stores the centroid data in a data structure which in...
Definition: EBSDReader.h:31
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
registerMooseObject("PhaseFieldApp", ReconPhaseVarIC)
void mooseError(Args &&... args) const
void addClassDescription(const std::string &doc_string)
unsigned int _phase
void ErrorVector unsigned int
static InputParameters validParams()