Line data Source code
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 : 14 : InputParameters 15 45 : ReconPhaseVarIC::validParams() 16 : { 17 45 : InputParameters params = InitialCondition::validParams(); 18 45 : params.addClassDescription( 19 : "Sets the initial condition of the phase weights from the EBSD reader"); 20 90 : params.addRequiredParam<UserObjectName>("ebsd_reader", 21 : "The EBSDReader object holding the EBSD data"); 22 90 : params.addRequiredParam<unsigned int>("phase", "EBSD phase number this variable is to represent"); 23 45 : return params; 24 0 : } 25 : 26 24 : ReconPhaseVarIC::ReconPhaseVarIC(const InputParameters & parameters) 27 : : InitialCondition(parameters), 28 48 : _mesh(_fe_problem.mesh()), 29 24 : _ebsd_reader(getUserObject<EBSDReader>("ebsd_reader")), 30 48 : _phase(getParam<unsigned int>("phase")), 31 48 : _node_to_phase_weight_map(_ebsd_reader.getNodeToPhaseWeightMap()) 32 : { 33 24 : } 34 : 35 : Real 36 92504 : ReconPhaseVarIC::value(const Point & /*p*/) 37 : { 38 : // Return error if current node is NULL 39 92504 : if (_current_node == nullptr) 40 0 : 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 = 44 92504 : _node_to_phase_weight_map.find(_current_node->id()); 45 92504 : if (it == _node_to_phase_weight_map.end()) 46 0 : mooseError("The following node id is not in the node map: ", _current_node->id()); 47 : 48 : // make sure we have enough phase weights 49 92504 : if (_phase >= it->second.size()) 50 0 : mooseError("Requested an out-of-range phase number"); 51 : 52 92504 : return it->second[_phase]; 53 : }