https://mooseframework.inl.gov
SurfaceMeshGeneratorBase.h
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 #pragma once
11 
12 #include "MeshGenerator.h"
13 
14 /*
15  * Base class for mesh generators that loop over elements in subdomains on a mesh
16  * - defines some common parameters
17  * - defines a useful flooding/painting algorithm to apply an operation on elements
18  */
20 {
21 public:
23 
25 
26 protected:
28  void setup(MeshBase & mesh);
29 
39  void flood(Elem * const elem,
40  const Point & normal,
41  const Elem & starting_elem,
42  const subdomain_id_type & sub_id,
43  MeshBase & mesh);
44 
51  virtual void actOnElem(Elem * const elem,
52  const Point & normal,
53  const subdomain_id_type & sub_id,
54  MeshBase & mesh) = 0;
55 
64  bool elementSatisfiesRequirements(const Elem * const elem,
65  const Point & desired_normal,
66  const Elem & base_elem,
67  const Point & face_normal) const;
68 
73  Point get2DElemNormal(const Elem * const elem) const;
74 
76  std::unique_ptr<MeshBase> & _input;
77 
79  std::vector<SubdomainName> _subdomain_names;
80 
82  const bool _check_subdomains;
83 
85  std::vector<subdomain_id_type> _included_subdomain_ids;
86 
89 
91  Point _normal;
110  std::unordered_map<subdomain_id_type, Real> _max_elem_distance;
111 
113  std::unordered_map<subdomain_id_type, std::unordered_set<Elem *>> _visited;
117  std::unordered_set<Elem *> _acted_upon_once;
119  const unsigned int _flood_max_recursion;
121  unsigned int _flood_recursion_count = 0;
126 };
void setup(MeshBase &mesh)
Sets up various data structures.
std::unordered_map< subdomain_id_type, std::unordered_set< Elem * > > _visited
Map used for the flooding algorithm to keep track of which elements have been visited for which subdo...
void flood(Elem *const elem, const Point &normal, const Elem &starting_elem, const subdomain_id_type &sub_id, MeshBase &mesh)
This method implements a recursive flood routine to paint (applying an operation) to elements on mesh...
const Real _normal_tol
Tolerance to group elements with normals such that face_normal.normal_hat <= 1 - normal_tol where nor...
bool _using_normal
true if only elements are only considered when their normal is close to either the "_normal" or a mov...
const InputParameters & parameters() const
Get the parameters of the object.
Definition: MooseBase.h:131
SurfaceMeshGeneratorBase(const InputParameters &parameters)
MeshBase & mesh
const bool _flip_inverted_normals
Whether to flip the normal of a surface element when they meet the criterion.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
std::vector< SubdomainName > _subdomain_names
The list of new subdomain names (useful for adding subdomains)
Point get2DElemNormal(const Elem *const elem) const
Get the normal of the 2D element.
virtual void actOnElem(Elem *const elem, const Point &normal, const subdomain_id_type &sub_id, MeshBase &mesh)=0
Action to perform when flooding.
unsigned int _flood_recursion_count
Current tally for the number of flood routine calls active.
const bool _check_painted_neighor_normals
Additional heuristic: check the element neighbors and if they have already been painted with the subd...
const Real _flipped_normal_tol
Tolerance but when using the flipped normal.
std::unordered_map< subdomain_id_type, Real > _max_elem_distance
Distance to use for max painting radius. This distance can be specified per subdomain.
Point _normal
if specified, then surface elements are only considered if their normal is close to this ...
static InputParameters validParams()
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const bool _consider_flipped_normals
Whether to also consider surface elements that have a flipped normal.
const bool _has_max_distance_criterion
Whether to painting beyond a certain radius.
const unsigned int _flood_max_recursion
Maximum amount of calls to the flood routine at once.
const bool _check_subdomains
whether to check the prior subdomain id of the element when choosing whether to change its subdomain ...
bool _flood_only_once
Only act on each element once.
std::unordered_set< Elem * > _acted_upon_once
Set used when flooding each element once. If the element pointer is in the set, it has been visited a...
const bool _fixed_flooding_normal
Whether to paint/flood using a fixed normal or a moving normal.
MeshGenerators are objects that can modify or add to an existing mesh.
Definition: MeshGenerator.h:33
std::unique_ptr< MeshBase > & _input
the mesh to add the subdomains to
std::vector< subdomain_id_type > _included_subdomain_ids
A list of included subdomain ids that the element has to be priorly a part of, extracted from the &#39;in...
bool elementSatisfiesRequirements(const Elem *const elem, const Point &desired_normal, const Elem &base_elem, const Point &face_normal) const
Determines whether the given element satisfies a set of criteria that are defined in this base class...