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 "FeatureFloodCountAux.h" 11 : #include "FeatureFloodCount.h" 12 : #include "GrainTrackerInterface.h" 13 : #include "MooseEnum.h" 14 : 15 : #include <algorithm> 16 : 17 : registerMooseObject("PhaseFieldApp", FeatureFloodCountAux); 18 : 19 : InputParameters 20 7439 : FeatureFloodCountAux::validParams() 21 : { 22 7439 : InputParameters params = AuxKernel::validParams(); 23 7439 : params.addClassDescription("Feature detection by connectivity analysis"); 24 14878 : params.addDeprecatedParam<UserObjectName>("bubble_object", 25 : "The FeatureFloodCount UserObject to get values from.", 26 : "Use \"flood_counter\" instead."); 27 14878 : params.addRequiredParam<UserObjectName>("flood_counter", 28 : "The FeatureFloodCount UserObject to get values from."); 29 14878 : params.addParam<unsigned int>("map_index", 30 : "The index of which map to retrieve values from when " 31 : "using FeatureFloodCount with multiple maps."); 32 : MooseEnum field_display("UNIQUE_REGION VARIABLE_COLORING GHOSTED_ENTITIES HALOS CENTROID " 33 : "ACTIVE_BOUNDS INTERSECTS_SPECIFIED_BOUNDARY", 34 14878 : "UNIQUE_REGION"); 35 14878 : params.addParam<MooseEnum>("field_display", 36 : field_display, 37 : "Determines how the auxilary field should be colored. " 38 : "(UNIQUE_REGION and VARIABLE_COLORING are nodal, CENTROID is " 39 : "elemental, default: UNIQUE_REGION)"); 40 : 41 29756 : params.set<ExecFlagEnum>("execute_on") = {EXEC_INITIAL, EXEC_TIMESTEP_END}; 42 : 43 7439 : return params; 44 14878 : } 45 : 46 4030 : FeatureFloodCountAux::FeatureFloodCountAux(const InputParameters & parameters) 47 : : AuxKernel(parameters), 48 4030 : _flood_counter(getUserObject<FeatureFloodCount>("flood_counter")), 49 12370 : _var_idx(isParamValid("map_index") ? getParam<unsigned int>("map_index") 50 : : std::numeric_limits<std::size_t>::max()), 51 8060 : _field_type(getParam<MooseEnum>("field_display").getEnum<FieldType>()), 52 4030 : _var_coloring(_field_type == FeatureFloodCount::FieldType::VARIABLE_COLORING) 53 : { 54 4030 : if (_flood_counter.isElemental() == isNodal() && 55 : (_field_type == FieldType::UNIQUE_REGION || _field_type == FieldType::VARIABLE_COLORING || 56 4 : _field_type == FieldType::GHOSTED_ENTITIES || _field_type == FieldType::HALOS)) 57 2 : paramError("field_display", 58 : "UNIQUE_REGION, VARIABLE_COLORING, GHOSTED_ENTITIES and HALOS must be on variable " 59 : "types that match the entity mode of the FeatureFloodCounter"); 60 : 61 4028 : if (isNodal() && (_field_type == FieldType::ACTIVE_BOUNDS || _field_type == FieldType::CENTROID || 62 : _field_type == FieldType::INTERSECTS_SPECIFIED_BOUNDARY)) 63 2 : paramError("field_display", 64 : "The selected option is only available for elemental aux variables"); 65 4026 : } 66 : 67 : void 68 4809751 : FeatureFloodCountAux::precalculateValue() 69 : { 70 4809751 : switch (_field_type) 71 : { 72 4809751 : case FieldType::UNIQUE_REGION: 73 : case FieldType::VARIABLE_COLORING: 74 : case FieldType::GHOSTED_ENTITIES: 75 : case FieldType::HALOS: 76 : case FieldType::CENTROID: 77 : case FieldType::INTERSECTS_SPECIFIED_BOUNDARY: 78 4809751 : _value = _flood_counter.getEntityValue( 79 4809751 : (isNodal() ? _current_node->id() : _current_elem->id()), _field_type, _var_idx); 80 4809751 : break; 81 : 82 0 : case FieldType::ACTIVE_BOUNDS: 83 : { 84 0 : const auto & var_to_features = _flood_counter.getVarToFeatureVector(_current_elem->id()); 85 0 : _value = std::count_if(var_to_features.begin(), 86 : var_to_features.end(), 87 : [](unsigned int feature_id) 88 0 : { return feature_id != FeatureFloodCount::invalid_id; }); 89 : 90 0 : break; 91 : } 92 : 93 0 : default: 94 0 : paramError("field_display", "Unimplemented type"); 95 : } 96 4809751 : } 97 : 98 : Real 99 17514487 : FeatureFloodCountAux::computeValue() 100 : { 101 17514487 : return _value; 102 : }