www.mooseframework.org
ReconPhaseVarIC.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
7 #include "ReconPhaseVarIC.h"
8 
9 template <>
10 InputParameters
12 {
13  InputParameters params = validParams<InitialCondition>();
14  params.addRequiredParam<UserObjectName>("ebsd_reader",
15  "The EBSDReader object holding the EBSD data");
16  params.addRequiredParam<unsigned int>("phase", "EBSD phase number this variable is to represent");
17  return params;
18 }
19 
20 ReconPhaseVarIC::ReconPhaseVarIC(const InputParameters & parameters)
21  : InitialCondition(parameters),
22  _mesh(_fe_problem.mesh()),
23  _ebsd_reader(getUserObject<EBSDReader>("ebsd_reader")),
24  _phase(getParam<unsigned int>("phase")),
25  _node_to_phase_weight_map(_ebsd_reader.getNodeToPhaseWeightMap())
26 {
27 }
28 
29 Real
30 ReconPhaseVarIC::value(const Point & /*p*/)
31 {
32  // Return error if current node is NULL
33  if (_current_node == nullptr)
34  mooseError("_current_node is reporting NULL");
35 
36  // Make sure the _current_node is in the _node_to_phase_weight_map (return error if not in map)
37  std::map<dof_id_type, std::vector<Real>>::const_iterator it =
38  _node_to_phase_weight_map.find(_current_node->id());
39  if (it == _node_to_phase_weight_map.end())
40  mooseError("The following node id is not in the node map: ", _current_node->id());
41 
42  // make sure we have enough ophase weights
43  if (_phase >= it->second.size())
44  mooseError("Requested an out-of-range phase number");
45 
46  return it->second[_phase];
47 }
virtual Real value(const Point &)
ReconPhaseVarIC(const InputParameters &parameters)
const std::map< dof_id_type, std::vector< Real > > & _node_to_phase_weight_map
InputParameters validParams< ReconPhaseVarIC >()
A GeneralUserObject that reads an EBSD file and stores the centroid data in a data structure which in...
Definition: EBSDReader.h:34
unsigned int _phase