https://mooseframework.inl.gov
ComboMarker.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 
10 #include "ComboMarker.h"
11 #include "FEProblemBase.h"
12 
13 registerMooseObject("MooseApp", ComboMarker);
14 
17 {
19  params.addRequiredParam<std::vector<MarkerName>>(
20  "markers", "A list of marker names to combine into a single marker.");
21  params.addClassDescription("A marker that converts many markers into a single marker by "
22  "considering the maximum value of the listed markers (i.e., "
23  "refinement takes precedent).");
24  return params;
25 }
26 
28  : Marker(parameters),
29  _names(getParam<std::vector<MarkerName>>("markers")),
30  _block_restriction_mismatch(false)
31 {
32  for (const auto & marker_name : _names)
33  _markers.push_back(&getMarkerValue(marker_name));
34 
35  std::string other_block_restricted = "";
36  for (const auto & marker_name : _names)
37  {
38  const auto var_ptr = &_subproblem.getVariable(_tid, marker_name);
39  _marker_variables.push_back(var_ptr);
40 
41  // Check block restrictions
42  if (blockIDs() != var_ptr->blockIDs())
43  other_block_restricted += (other_block_restricted == "" ? "" : ", ") + marker_name;
44  }
45 
46  if (other_block_restricted != "")
47  {
49  paramInfo(
50  "markers",
51  "Combo marker and markers '" + other_block_restricted +
52  "' do not share the same block restrictions. Markers outside their block restriction "
53  "will not mark.");
54  }
55 }
56 
59 {
60  // We start with DONT_MARK because it's -1
61  MarkerValue marker_value = DONT_MARK;
62 
63  // No need to check block restrictions if they all match
65  for (const auto & var : _markers)
66  marker_value = std::max(marker_value, static_cast<MarkerValue>((*var)[0]));
67  else
68  for (const auto i : index_range(_markers))
69  if (_marker_variables[i]->hasBlocks(_current_elem->subdomain_id()))
70  marker_value = std::max(marker_value, static_cast<MarkerValue>((*_markers[i])[0]));
71 
72  return marker_value;
73 }
std::vector< const MooseVariableFieldBase * > _marker_variables
Pointers to the variables for the markers.
Definition: ComboMarker.h:37
THREAD_ID _tid
Definition: Marker.h:115
virtual MarkerValue computeElementMarker() override
Definition: ComboMarker.C:58
SubProblem & _subproblem
Definition: Marker.h:110
Definition: Marker.h:41
registerMooseObject("MooseApp", ComboMarker)
const Elem *const & _current_elem
Pointer to the current element being considered in the marker element-based loop. ...
Definition: Marker.h:122
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
MarkerValue
This mirrors the main refinement flag values in libMesh in Elem::RefinementState but adds "dont_mark"...
Definition: Marker.h:59
virtual const std::set< SubdomainID > & blockIDs() const
Return the block subdomain ids for this object Note, if this is not block restricted, this function returns all mesh subdomain ids.
Combines multiple marker fields.
Definition: ComboMarker.h:17
void addRequiredParam(const std::string &name, const std::string &doc_string)
This method adds a parameter and documentation string to the InputParameters object that will be extr...
auto max(const L &left, const R &right)
ComboMarker(const InputParameters &parameters)
Definition: ComboMarker.C:27
std::vector< const VariableValue * > _markers
Pointers to the markers contributing to the Combo marker.
Definition: ComboMarker.h:31
virtual const MooseVariableFieldBase & getVariable(const THREAD_ID tid, const std::string &var_name, Moose::VarKindType expected_var_type=Moose::VarKindType::VAR_ANY, Moose::VarFieldType expected_var_field_type=Moose::VarFieldType::VAR_FIELD_ANY) const =0
Returns the variable reference for requested variable which must be of the expected_var_type (Nonline...
const std::vector< MarkerName > & _names
Names of the markers contributing to the combo.
Definition: ComboMarker.h:28
const MooseArray< Real > & getMarkerValue(std::string name)
This is used to get the values of other Markers.
Definition: Marker.C:83
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump...
static InputParameters validParams()
Definition: Marker.C:19
bool _block_restriction_mismatch
Boolean to keep track of whether any marker does not have the same block restriction.
Definition: ComboMarker.h:34
bool hasBlocks(const SubdomainName &name) const
Test if the supplied block name is valid for this object.
void paramInfo(const std::string &param, Args... args) const
Emits an informational message prefixed with the file and line number of the given param (from the in...
auto index_range(const T &sizable)
static InputParameters validParams()
Definition: ComboMarker.C:16