https://mooseframework.inl.gov
SideSetsGeneratorBase.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 #include "libmesh/fe_base.h"
14 
15 // libMesh forward declarations
16 namespace libMesh
17 {
18 class QGauss;
19 class Elem;
20 }
21 
22 /*
23  * Base class for mesh generators that add sidesets to the mesh
24  */
26 {
27 public:
29 
31  virtual ~SideSetsGeneratorBase(); // dtor required for unique_ptr with forward declarations
32 
33 protected:
39  void setup(MeshBase & mesh);
40 
45  void finalize();
46 
51  void
52  flood(const Elem * elem, const Point & normal, const boundary_id_type & side_id, MeshBase & mesh);
53 
61  bool normalsWithinTol(const Point & normal_1, const Point & normal_2, const Real & tol) const;
62 
66  bool elementSubdomainIdInList(const Elem * const elem,
67  const std::vector<subdomain_id_type> & subdomain_id_list) const;
68 
73  bool elementSideInIncludedBoundaries(const Elem * const elem,
74  const unsigned int side,
75  const MeshBase & mesh) const;
76 
81  bool elementSideInExcludedBoundaries(const Elem * const elem,
82  const unsigned int side,
83  const MeshBase & mesh) const;
84 
89  bool elemSideSatisfiesRequirements(const Elem * const elem,
90  const unsigned int side,
91  const MeshBase & mesh,
92  const Point & normal,
93  const Point & face_normal);
94 
96  std::unique_ptr<MeshBase> & _input;
97 
99  std::vector<BoundaryName> _boundary_names;
100 
102  const bool _fixed_normal;
103 
105  const bool _replace;
106 
109 
112 
114  const bool _check_subdomains;
115 
118 
120  std::vector<boundary_id_type> _included_boundary_ids;
121 
123  std::vector<boundary_id_type> _excluded_boundary_ids;
124 
126  std::vector<subdomain_id_type> _included_subdomain_ids;
127 
129  std::vector<subdomain_id_type> _included_neighbor_subdomain_ids;
130 
133 
136 
138  Point _normal;
139 
146 
147  std::unique_ptr<libMesh::FEBase> _fe_face;
148  std::unique_ptr<libMesh::QGauss> _qface;
149  std::map<boundary_id_type, std::set<const Elem *>> _visited;
150 };
bool elementSubdomainIdInList(const Elem *const elem, const std::vector< subdomain_id_type > &subdomain_id_list) const
Determines whether the given element&#39;s subdomain id is in the given subdomain_id_list.
const bool _fixed_normal
Whether to fix the normal or allow it to vary to "paint" around curves.
bool elemSideSatisfiesRequirements(const Elem *const elem, const unsigned int side, const MeshBase &mesh, const Point &normal, const Point &face_normal)
Determines whether the given element&#39;s side satisfies the following parameters: include_only_external...
std::unique_ptr< MeshBase > & _input
the mesh to add the sidesets to
const Real _normal_tol
if normal is specified, then faces are only added if face_normal.normal_hat <= 1 - normal_tol where n...
Point _normal
if specified, then faces are only added if their normal is close to this
std::vector< subdomain_id_type > _included_neighbor_subdomain_ids
A list of included neighbor subdomain ids that the sides&#39; neighbor element must be a part of...
const boundary_id_type side_id
SideSetsGeneratorBase(const InputParameters &parameters)
MeshBase & mesh
const bool _check_included_boundaries
whether to check boundary ids against the included boundary list when adding sides or not ...
const bool _replace
Whether or not to remove the old sidesets (all of them, if any) when adding sidesets.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
bool normalsWithinTol(const Point &normal_1, const Point &normal_2, const Real &tol) const
Determines whether two normal vectors are within normal_tol of each other.
std::vector< BoundaryName > _boundary_names
The list of new boundary names.
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
std::vector< subdomain_id_type > _included_subdomain_ids
A list of included subdomain ids that the side has to be part of, extracted from the included_subdoma...
const bool _include_only_external_sides
Whether to only include external side when considering sides to add to the sideset.
int8_t boundary_id_type
const bool _check_excluded_boundaries
whether to check boundary ids against the excluded boundary list when adding sides or not ...
void flood(const Elem *elem, const Point &normal, const boundary_id_type &side_id, MeshBase &mesh)
This method implements a recursive flood routine to paint a sideset of mesh to neighboring faces give...
bool elementSideInIncludedBoundaries(const Elem *const elem, const unsigned int side, const MeshBase &mesh) const
Determines whether the given side of an element belongs to any boundaries in the included_boundaries ...
void finalize()
This method finalizes the object, setting names back in the boundary_info object and releasing memory...
static InputParameters validParams()
bool _using_normal
true if only faces close to "normal" will be added
std::vector< boundary_id_type > _included_boundary_ids
A list of boundary ids that the side has to be part of, extracted from the included_boundaries parame...
const bool _check_subdomains
whether to check subdomain ids of the element in the (element, side, boundary id) tuple when adding s...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const InputParameters & parameters() const
Get the parameters of the object.
std::vector< boundary_id_type > _excluded_boundary_ids
A list of boundary ids that the side must not be a part of, extracted from the excluded_boundaries pa...
std::unique_ptr< libMesh::QGauss > _qface
bool elementSideInExcludedBoundaries(const Elem *const elem, const unsigned int side, const MeshBase &mesh) const
Determines whether the given side of an element belongs to any boundaries in the excluded_boundaries ...
const bool _check_neighbor_subdomains
whether to check the subdomain ids of the neighbor element (on the other &#39;side&#39; of the side) when add...
std::map< boundary_id_type, std::set< const Elem * > > _visited
std::unique_ptr< libMesh::FEBase > _fe_face
MeshGenerators are objects that can modify or add to an existing mesh.
Definition: MeshGenerator.h:32
void setup(MeshBase &mesh)
This method is used to construct the FE object so we can compute normals of faces.