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