https://mooseframework.inl.gov
Loading...
Searching...
No Matches
BoundaryMarker.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 "BoundaryMarker.h"
11#include "MooseMesh.h"
12
14
17{
20 "Marks all elements with sides on a given boundary for refinement/coarsening");
21 MooseEnum marker_states = Marker::markerStates();
22
24 "mark", marker_states, "How to mark elements adjacent to the boundary.");
25 params.addRequiredParam<std::vector<BoundaryName>>("next_to",
26 "Boundaries to refine elements along");
27 params.addParam<Real>("distance", 0.0, "Distance from the boundary to refine within");
28 return params;
29}
30
32 : Marker(parameters),
33 _distance(getParam<Real>("distance")),
34 _bnd_elem_ids(_mesh.getBoundariesToActiveSemiLocalElemIds()),
35 _mark(parameters.get<MooseEnum>("mark").getEnum<MarkerValue>()),
36 _boundary_ids(_mesh.getBoundaryIDs(getParam<std::vector<BoundaryName>>("next_to")))
37{
39 mooseWarning("Elements with in `distance ` of a boundary segment on a different processor "
40 "might not get marked when running with a distributed mesh.");
41}
42
45{
46 if (_distance == 0.0)
47 {
48 // is the current element member of any selected boundary element set?
49 for (const auto boundary : _boundary_ids)
50 if (_mesh.isBoundaryElem(_current_elem->id(), boundary))
51 return _mark;
52
53 return DONT_MARK;
54 }
55 else
56 {
57 for (const auto boundary : _boundary_ids)
58 {
59 const auto it = _bnd_elem_ids.find(boundary);
60 if (it != _bnd_elem_ids.end())
61 for (const auto id : it->second)
62 {
63 // shortcut if we are checing the current element itself
64 if (id == _current_elem->id())
65 return _mark;
66
67 // otherwise compute distance to the boundary elements
68 const auto elem = _mesh.elemPtr(id);
69 const auto r = _current_elem->vertex_average() - elem->vertex_average();
70 if (r.norm() < _distance)
71 return _mark;
72 }
73 }
74 return DONT_MARK;
75 }
76}
registerMooseObject("MooseApp", BoundaryMarker)
Marks all elements near a given boundary for refinement/coarsening.
static InputParameters validParams()
BoundaryMarker(const InputParameters &parameters)
virtual MarkerValue computeElementMarker() override
const MarkerValue _mark
which way to mark elements near the boundary
const Real _distance
distance from the boundary (centroid of boundary element to centroid of marked element)
const std::vector< BoundaryID > _boundary_ids
boundary near which to mark elements
const std::unordered_map< boundary_id_type, std::unordered_set< dof_id_type > > & _bnd_elem_ids
lists of boundary elements for all boundaries
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object.
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...
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
const Elem *const & _current_elem
Pointer to the current element being considered in the marker element-based loop.
Definition Marker.h:122
MarkerValue
This mirrors the main refinement flag values in libMesh in Elem::RefinementState but adds "dont_mark"...
Definition Marker.h:60
@ DONT_MARK
Definition Marker.h:61
MooseMesh & _mesh
Reference to the mesh, obtained from the subproblem.
Definition Marker.h:125
static MooseEnum markerStates()
Helper function for getting the valid refinement flag states a marker can use as a MooseEnum.
Definition Marker.C:62
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition MooseEnum.h:55
bool isBoundaryElem(dof_id_type elem_id) const
Returns true if the requested element is in the list of boundary elements, false otherwise.
Definition MooseMesh.C:3692
virtual Elem * elemPtr(const dof_id_type i)
Definition MooseMesh.C:3214
virtual bool isDistributedMesh() const
Returns the final Mesh distribution type.
Definition MooseMesh.h:1143
void mooseWarning(Args &&... args) const