www.mooseframework.org
FeatureFloodCountAux.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 "FeatureFloodCountAux.h"
8 #include "FeatureFloodCount.h"
10 #include "MooseEnum.h"
11 
12 #include <algorithm>
13 
14 template <>
15 InputParameters
17 {
18  InputParameters params = validParams<AuxKernel>();
19  params.addClassDescription("Feature detection by connectivity analysis");
20  params.addDeprecatedParam<UserObjectName>("bubble_object",
21  "The FeatureFloodCount UserObject to get values from.",
22  "Use \"flood_counter\" instead.");
23  params.addRequiredParam<UserObjectName>("flood_counter",
24  "The FeatureFloodCount UserObject to get values from.");
25  params.addParam<unsigned int>("map_index",
26  "The index of which map to retrieve values from when "
27  "using FeatureFloodCount with multiple maps.");
28  MooseEnum field_display(
29  "UNIQUE_REGION VARIABLE_COLORING GHOSTED_ENTITIES HALOS CENTROID ACTIVE_BOUNDS",
30  "UNIQUE_REGION");
31  params.addParam<MooseEnum>("field_display",
32  field_display,
33  "Determines how the auxilary field should be colored. "
34  "(UNIQUE_REGION and VARIABLE_COLORING are nodal, CENTROID is "
35  "elemental, default: UNIQUE_REGION)");
36 
37  MultiMooseEnum execute_options(SetupInterface::getExecuteOptions());
38  execute_options = "initial timestep_end";
39  params.set<MultiMooseEnum>("execute_on") = execute_options;
40 
41  return params;
42 }
43 
44 FeatureFloodCountAux::FeatureFloodCountAux(const InputParameters & parameters)
45  : AuxKernel(parameters),
46  _flood_counter(getUserObject<FeatureFloodCount>("flood_counter")),
47  _var_idx(isParamValid("map_index") ? getParam<unsigned int>("map_index")
48  : std::numeric_limits<std::size_t>::max()),
49  _field_display(getParam<MooseEnum>("field_display")),
50  _var_coloring(_field_display == "VARIABLE_COLORING"),
51  _field_type(_field_display.getEnum<FeatureFloodCount::FieldType>())
52 {
53  if (_flood_counter.isElemental() == isNodal() &&
54  (_field_display == "UNIQUE_REGION" || _field_display == "VARIABLE_COLORING" ||
55  _field_display == "GHOSTED_ENTITIES" || _field_display == "HALOS"))
56  mooseError("UNIQUE_REGION, VARIABLE_COLORING, GHOSTED_ENTITIES and HALOS must be on variable "
57  "types that match the entity mode of the FeatureFloodCounter");
58 
59  if (isNodal())
60  {
61  if (_field_display == "ACTIVE_BOUNDS")
62  mooseError("ACTIVE_BOUNDS is only available for elemental aux variables");
63 
64  if (_field_display == "CENTROID")
65  mooseError("CENTROID is only available for elemental aux variables");
66  }
67 }
68 
69 void
71 {
72  switch (_field_display)
73  {
74  case 0: // UNIQUE_REGION
75  case 1: // VARIABLE_COLORING
76  case 2: // GHOSTED_ENTITIES
77  case 3: // HALOS
78  case 4: // CENTROID
80  (isNodal() ? _current_node->id() : _current_elem->id()), _field_type, _var_idx);
81  break;
82  case 5: // ACTIVE_BOUNDS
83  {
84  const auto & var_to_features = _flood_counter.getVarToFeatureVector(_current_elem->id());
85  _value = std::count_if(
86  var_to_features.begin(), var_to_features.end(), [](unsigned int feature_id) {
87  return feature_id != FeatureFloodCount::invalid_id;
88  });
89 
90  break;
91  }
92  default:
93  mooseError("Unimplemented \"field_display\" type");
94  }
95 }
96 
97 Real
99 {
100  return _value;
101 }
virtual Real getEntityValue(dof_id_type entity_id, FieldType field_type, std::size_t var_index=0) const
FeatureFloodCountAux(const InputParameters &parameters)
Factory constructor, takes parameters so that all derived classes can be built using the same constru...
InputParameters validParams< FeatureFloodCountAux >()
const MooseEnum _field_display
Real _value
precalculated element value
const std::size_t _var_idx
This object will mark nodes or elements of continuous regions all with a unique number for the purpos...
const FeatureFloodCount::FieldType _field_type
static const unsigned int invalid_id
bool isElemental() const
virtual const std::vector< unsigned int > & getVarToFeatureVector(dof_id_type elem_id) const
Returns a list of active unique feature ids for a particular element.
virtual void precalculateValue()
const FeatureFloodCount & _flood_counter
Function being used to compute the value of this kernel.