https://mooseframework.inl.gov
Loading...
Searching...
No Matches
FeatureFloodCountAux.C
Go to the documentation of this file.
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
11#include "FeatureFloodCount.h"
13#include "MooseEnum.h"
14
15#include <algorithm>
16
18
21{
23 params.addClassDescription("Feature detection by connectivity analysis");
24 params.addDeprecatedParam<UserObjectName>("bubble_object",
25 "The FeatureFloodCount UserObject to get values from.",
26 "Use \"flood_counter\" instead.");
27 params.addRequiredParam<UserObjectName>("flood_counter",
28 "The FeatureFloodCount UserObject to get values from.");
29 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 "UNIQUE_REGION");
35 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 params.set<ExecFlagEnum>("execute_on") = {EXEC_INITIAL, EXEC_TIMESTEP_END};
42
43 return params;
44}
45
47 : AuxKernel(parameters),
48 _flood_counter(getUserObject<FeatureFloodCount>("flood_counter")),
49 _var_idx(isParamValid("map_index") ? getParam<unsigned int>("map_index")
50 : std::numeric_limits<std::size_t>::max()),
51 _field_type(getParam<MooseEnum>("field_display").getEnum<FieldType>()),
52 _var_coloring(_field_type == FeatureFloodCount::FieldType::VARIABLE_COLORING)
53{
55 (_field_type == FieldType::UNIQUE_REGION || _field_type == FieldType::VARIABLE_COLORING ||
56 _field_type == FieldType::GHOSTED_ENTITIES || _field_type == FieldType::HALOS))
57 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 if (isNodal() && (_field_type == FieldType::ACTIVE_BOUNDS || _field_type == FieldType::CENTROID ||
62 _field_type == FieldType::INTERSECTS_SPECIFIED_BOUNDARY))
63 paramError("field_display",
64 "The selected option is only available for elemental aux variables");
65}
66
67void
69{
70 switch (_field_type)
71 {
72 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:
80 break;
81
82 case FieldType::ACTIVE_BOUNDS:
83 {
84 const auto & var_to_features = _flood_counter.getVarToFeatureVector(_current_elem->id());
85 _value = std::count_if(var_to_features.begin(),
86 var_to_features.end(),
87 [](unsigned int feature_id)
88 { return feature_id != FeatureFloodCount::invalid_id; });
89
90 break;
91 }
92
93 default:
94 paramError("field_display", "Unimplemented type");
95 }
96}
97
98Real
registerMooseObject("PhaseFieldApp", FeatureFloodCountAux)
const ExecFlagType EXEC_TIMESTEP_END
const ExecFlagType EXEC_INITIAL
void ErrorVector unsigned int
const Elem *const & _current_elem
const Node *const & _current_node
static InputParameters validParams()
Function auxiliary value.
virtual void precalculateValue() override
Real _value
precalculated element value
virtual Real computeValue() override
FeatureFloodCountAux(const InputParameters &parameters)
const std::size_t _var_idx
static InputParameters validParams()
Factory constructor, takes parameters so that all derived classes can be built using the same constru...
const FeatureFloodCount & _flood_counter
Function being used to compute the value of this kernel.
This object will mark nodes or elements of continuous regions all with a unique number for the purpos...
virtual Real getEntityValue(dof_id_type entity_id, FieldType field_type, std::size_t var_index=0) 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.
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addDeprecatedParam(const std::string &name, const T &value, const std::string &doc_string, const std::string &deprecation_message)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
T & set(const std::string &name, bool quiet_mode=false)
void paramError(const std::string &param, Args... args) const