https://mooseframework.inl.gov
MooseMeshElementConversionUtils.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 "libmesh/replicated_mesh.h"
13 
14 #include "MooseTypes.h"
15 
17 {
18 // Define for comparing the key value of BCTuple
20 {
22  {
23  return std::get<0>(s) < i;
24  }
26  {
27  return i < std::get<0>(s);
28  }
29 };
30 
38 void hexElemSplitter(MeshBase & mesh,
39  const std::vector<libMesh::BoundaryInfo::BCTuple> & bdry_side_list,
40  const dof_id_type elem_id,
41  std::vector<dof_id_type> & converted_elems_ids);
42 
50 void pyramidElemSplitter(MeshBase & mesh,
51  const std::vector<libMesh::BoundaryInfo::BCTuple> & bdry_side_list,
52  const dof_id_type elem_id,
53  std::vector<dof_id_type> & converted_elems_ids);
54 
62 void prismElemSplitter(MeshBase & mesh,
63  const std::vector<libMesh::BoundaryInfo::BCTuple> & bdry_side_list,
64  const dof_id_type elem_id,
65  std::vector<dof_id_type> & converted_elems_ids);
66 
74 void polyhedronElemSplitter(MeshBase & mesh,
75  const std::vector<libMesh::BoundaryInfo::BCTuple> & bdry_side_list,
76  const dof_id_type elem_id,
77  std::vector<dof_id_type> & converted_elems_ids);
78 
88 void nodeRotationHEX8(const unsigned int min_id_index,
89  const unsigned int sec_min_pos,
90  std::vector<unsigned int> & face_rotation,
91  std::vector<unsigned int> & node_rotation);
92 
99 std::vector<unsigned int> neighborNodeIndicesHEX8(unsigned int min_id_index);
100 
111 void hexNodesToTetNodesDeterminer(std::vector<const Node *> & hex_nodes,
112  std::vector<std::vector<unsigned int>> & rotated_tet_face_indices,
113  std::vector<std::vector<const Node *>> & tet_nodes_list);
114 
121 std::vector<bool> quadFaceDiagonalDirectionsHex(const std::vector<const Node *> & hex_nodes);
122 
129 bool quadFaceDiagonalDirection(const std::vector<const Node *> & quad_nodes);
130 
141 std::vector<std::vector<unsigned int>>
142 tetNodesForHex(const std::vector<bool> diagonal_directions,
143  std::vector<std::vector<unsigned int>> & tet_face_indices);
144 
151 void nodeRotationPRISM6(unsigned int min_id_index,
152  std::vector<unsigned int> & face_rotation,
153  std::vector<unsigned int> & node_rotation);
154 
165 void
166 prismNodesToTetNodesDeterminer(std::vector<const Node *> & prism_nodes,
167  std::vector<std::vector<unsigned int>> & rotated_tet_face_indices,
168  std::vector<std::vector<const Node *>> & tet_nodes_list);
169 
179 std::vector<std::vector<unsigned int>>
180 tetNodesForPrism(const bool diagonal_direction,
181  std::vector<std::vector<unsigned int>> & tet_face_indices);
182 
191 void nodeRotationPYRAMID5(unsigned int min_id_index,
192  std::vector<unsigned int> & face_rotation,
193  std::vector<unsigned int> & node_rotation);
194 
205 void
206 pyramidNodesToTetNodesDeterminer(std::vector<const Node *> & pyramid_nodes,
207  std::vector<std::vector<unsigned int>> & rotated_tet_face_indices,
208  std::vector<std::vector<const Node *>> & tet_nodes_list);
209 
222 void convert3DMeshToAllTet4(MeshBase & mesh,
223  const std::vector<std::pair<dof_id_type, bool>> & elems_to_process,
224  std::vector<dof_id_type> & converted_elems_ids_to_track,
225  const subdomain_id_type block_id_to_remove,
226  const bool delete_block_to_remove);
227 
232 void convert3DMeshToAllTet4(MeshBase & mesh);
233 
241 void
242 elementBoundaryInfoCollector(const std::vector<libMesh::BoundaryInfo::BCTuple> & bdry_side_list,
243  const dof_id_type elem_id,
244  const unsigned short n_elem_sides,
245  std::vector<std::vector<boundary_id_type>> & elem_side_list);
246 
256 void convertElem(MeshBase & mesh,
257  const dof_id_type & elem_id,
258  const std::vector<unsigned int> & side_indices,
259  const std::vector<std::vector<boundary_id_type>> & elem_side_info,
260  const SubdomainID & subdomain_id_shift_base);
261 
270 void convertHex8Elem(MeshBase & mesh,
271  const dof_id_type & elem_id,
272  const std::vector<unsigned int> & side_indices,
273  const std::vector<std::vector<boundary_id_type>> & elem_side_info,
274  const SubdomainID & subdomain_id_shift_base);
275 
285 void createUnitPyramid5FromHex8(MeshBase & mesh,
286  const dof_id_type & elem_id,
287  const unsigned int & side_index,
288  const Node * new_node,
289  const std::vector<boundary_id_type> & side_info,
290  const SubdomainID & subdomain_id_shift_base);
291 
301 void createUnitTet4FromHex8(MeshBase & mesh,
302  const dof_id_type & elem_id,
303  const unsigned int & side_index,
304  const Node * new_node,
305  const std::vector<boundary_id_type> & side_info,
306  const SubdomainID & subdomain_id_shift_base);
307 
316 void convertPrism6Elem(MeshBase & mesh,
317  const dof_id_type & elem_id,
318  const std::vector<unsigned int> & side_indices,
319  const std::vector<std::vector<boundary_id_type>> & elem_side_info,
320  const SubdomainID & subdomain_id_shift_base);
330 void createUnitTet4FromPrism6(MeshBase & mesh,
331  const dof_id_type & elem_id,
332  const unsigned int & side_index,
333  const Node * new_node,
334  const std::vector<boundary_id_type> & side_info,
335  const SubdomainID & subdomain_id_shift_base);
336 
347 void createUnitPyramid5FromPrism6(MeshBase & mesh,
348  const dof_id_type & elem_id,
349  const unsigned int & side_index,
350  const Node * new_node,
351  const std::vector<boundary_id_type> & side_info,
352  const SubdomainID & subdomain_id_shift_base);
353 
361 void convertPyramid5Elem(MeshBase & mesh,
362  const dof_id_type & elem_id,
363  const std::vector<std::vector<boundary_id_type>> & elem_side_info,
364  const SubdomainID & subdomain_id_shift_base);
365 
372 void retainEEID(MeshBase & mesh, const dof_id_type & elem_id, Elem * new_elem_ptr);
373 
384 void transitionLayerGenerator(MeshBase & mesh,
385  const std::vector<BoundaryName> & boundary_names,
386  const unsigned int conversion_element_layer_number,
387  const bool external_boundaries_checking);
388 
401  MeshBase & mesh,
402  const std::set<subdomain_id_type> & original_subdomain_ids,
403  const subdomain_id_type sid_shift_base,
404  const SubdomainName & tet_suffix,
405  const SubdomainName & pyramid_suffix);
406 }
void assignConvertedElementsSubdomainNameSuffix(MeshBase &mesh, const std::set< subdomain_id_type > &original_subdomain_ids, const subdomain_id_type sid_shift_base, const SubdomainName &tet_suffix, const SubdomainName &pyramid_suffix)
Assign a subdomain name suffix to the converted elements created during transition layer generation...
void createUnitPyramid5FromHex8(MeshBase &mesh, const dof_id_type &elem_id, const unsigned int &side_index, const Node *new_node, const std::vector< boundary_id_type > &side_info, const SubdomainID &subdomain_id_shift_base)
Create one PYRAMID5 element based on a side and the centroid of the HEX8 element. ...
std::tuple< dof_id_type, unsigned short int, boundary_id_type > BCTuple
void createUnitTet4FromHex8(MeshBase &mesh, const dof_id_type &elem_id, const unsigned int &side_index, const Node *new_node, const std::vector< boundary_id_type > &side_info, const SubdomainID &subdomain_id_shift_base)
Create two TET4 elements based on a side and the centroid of the HEX8 element.
std::vector< bool > quadFaceDiagonalDirectionsHex(const std::vector< const Node *> &hex_nodes)
For a HEX8 element, determine the direction of the diagonal line of each face that involves the node ...
void nodeRotationHEX8(const unsigned int min_id_index, const unsigned int sec_min_pos, std::vector< unsigned int > &face_rotation, std::vector< unsigned int > &node_rotation)
Rotate a HEX8 element&#39;s nodes to ensure that the node with the minimum id is the first node; and the ...
void createUnitPyramid5FromPrism6(MeshBase &mesh, const dof_id_type &elem_id, const unsigned int &side_index, const Node *new_node, const std::vector< boundary_id_type > &side_info, const SubdomainID &subdomain_id_shift_base)
Create a PYRAMID5 element opposite the sides converted to tets and the centroid of the PRISM6 element...
bool quadFaceDiagonalDirection(const std::vector< const Node *> &quad_nodes)
For a QUAD4 element, determine the direction of the diagonal line that involves the node with the min...
void polyhedronElemSplitter(MeshBase &mesh, const std::vector< libMesh::BoundaryInfo::BCTuple > &bdry_side_list, const dof_id_type elem_id, std::vector< dof_id_type > &converted_elems_ids)
Split a polyhedron element into n_sides TET4 elements.
void hexNodesToTetNodesDeterminer(std::vector< const Node *> &hex_nodes, std::vector< std::vector< unsigned int >> &rotated_tet_face_indices, std::vector< std::vector< const Node *>> &tet_nodes_list)
For a vector of rotated nodes that can form a HEX8 element, create a vector of four-node sets that ca...
void elementBoundaryInfoCollector(const std::vector< libMesh::BoundaryInfo::BCTuple > &bdry_side_list, const dof_id_type elem_id, const unsigned short n_elem_sides, std::vector< std::vector< boundary_id_type >> &elem_side_list)
Collect the boundary information of the given element in a mesh.
std::vector< unsigned int > neighborNodeIndicesHEX8(unsigned int min_id_index)
Calculate the indices (within the element nodes) of the three neighboring nodes of a node in a HEX8 e...
void convertHex8Elem(MeshBase &mesh, const dof_id_type &elem_id, const std::vector< unsigned int > &side_indices, const std::vector< std::vector< boundary_id_type >> &elem_side_info, const SubdomainID &subdomain_id_shift_base)
Convert a HEX8 element to elements with TRI3 surfaces on the given original QUAD4 side(s)...
void prismElemSplitter(MeshBase &mesh, const std::vector< libMesh::BoundaryInfo::BCTuple > &bdry_side_list, const dof_id_type elem_id, std::vector< dof_id_type > &converted_elems_ids)
Split a PRISM6 element into three TET4 elements.
std::vector< std::vector< unsigned int > > tetNodesForPrism(const bool diagonal_direction, std::vector< std::vector< unsigned int >> &tet_face_indices)
Creates sets of four nodes indices that can form TET4 elements to replace the original PRISM6 element...
void convert3DMeshToAllTet4(MeshBase &mesh, const std::vector< std::pair< dof_id_type, bool >> &elems_to_process, std::vector< dof_id_type > &converted_elems_ids_to_track, const subdomain_id_type block_id_to_remove, const bool delete_block_to_remove)
Convert all the elements in a 3D mesh, consisting of only linear elements, into TET4 elements...
void retainEEID(MeshBase &mesh, const dof_id_type &elem_id, Elem *new_elem_ptr)
Retain the extra integer of the original element in a new element.
void nodeRotationPRISM6(unsigned int min_id_index, std::vector< unsigned int > &face_rotation, std::vector< unsigned int > &node_rotation)
Rotate a PRISM6 element nodes to ensure that the node with the minimum id is the first node...
void createUnitTet4FromPrism6(MeshBase &mesh, const dof_id_type &elem_id, const unsigned int &side_index, const Node *new_node, const std::vector< boundary_id_type > &side_info, const SubdomainID &subdomain_id_shift_base)
Create one or two TET4 elements based on a side and the centroid of the PRISM6 element.
void nodeRotationPYRAMID5(unsigned int min_id_index, std::vector< unsigned int > &face_rotation, std::vector< unsigned int > &node_rotation)
Rotate a PYRAMID5 element nodes to ensure that the node with the minimum id is the first node for the...
void convertPyramid5Elem(MeshBase &mesh, const dof_id_type &elem_id, const std::vector< std::vector< boundary_id_type >> &elem_side_info, const SubdomainID &subdomain_id_shift_base)
Convert a PYRAMID5 element to elements with TRI3 surfaces on the original QUAD4 side.
void hexElemSplitter(MeshBase &mesh, const std::vector< libMesh::BoundaryInfo::BCTuple > &bdry_side_list, const dof_id_type elem_id, std::vector< dof_id_type > &converted_elems_ids)
Split a HEX8 element into six TET4 elements.
bool operator()(const libMesh::BoundaryInfo::BCTuple &s, dof_id_type i) const
void convertElem(MeshBase &mesh, const dof_id_type &elem_id, const std::vector< unsigned int > &side_indices, const std::vector< std::vector< boundary_id_type >> &elem_side_info, const SubdomainID &subdomain_id_shift_base)
Convert the element to an element with TRI3 side-elements on the user-specified sides by modifying th...
void pyramidElemSplitter(MeshBase &mesh, const std::vector< libMesh::BoundaryInfo::BCTuple > &bdry_side_list, const dof_id_type elem_id, std::vector< dof_id_type > &converted_elems_ids)
Split a PYRAMID5 element into two TET4 elements.
bool operator()(dof_id_type i, const libMesh::BoundaryInfo::BCTuple &s) const
void pyramidNodesToTetNodesDeterminer(std::vector< const Node *> &pyramid_nodes, std::vector< std::vector< unsigned int >> &rotated_tet_face_indices, std::vector< std::vector< const Node *>> &tet_nodes_list)
For a rotated nodes that can form a PYRAMID5 element, create a series of four-node set that can form ...
void convertPrism6Elem(MeshBase &mesh, const dof_id_type &elem_id, const std::vector< unsigned int > &side_indices, const std::vector< std::vector< boundary_id_type >> &elem_side_info, const SubdomainID &subdomain_id_shift_base)
Convert a PRISM6 element to elements with TRI3 surfaces on the given original QUAD4 side(s)...
std::vector< std::vector< unsigned int > > tetNodesForHex(const std::vector< bool > diagonal_directions, std::vector< std::vector< unsigned int >> &tet_face_indices)
Creates sets of four nodes indices that can form TET4 elements to replace the original HEX8 element...
void prismNodesToTetNodesDeterminer(std::vector< const Node *> &prism_nodes, std::vector< std::vector< unsigned int >> &rotated_tet_face_indices, std::vector< std::vector< const Node *>> &tet_nodes_list)
For a rotated nodes that can form a PRISM6 element, create a series of four-node set that can form TE...
void transitionLayerGenerator(MeshBase &mesh, const std::vector< BoundaryName > &boundary_names, const unsigned int conversion_element_layer_number, const bool external_boundaries_checking)
Generate a transition layer of elements with TRI3 surfaces on the given boundaries.
uint8_t dof_id_type