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(ReplicatedMesh & 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(ReplicatedMesh & 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(ReplicatedMesh & 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 
76 void nodeRotationHEX8(const unsigned int min_id_index,
77  const unsigned int sec_min_pos,
78  std::vector<unsigned int> & face_rotation,
79  std::vector<unsigned int> & node_rotation);
80 
87 std::vector<unsigned int> neighborNodeIndicesHEX8(unsigned int min_id_index);
88 
99 void hexNodesToTetNodesDeterminer(std::vector<const Node *> & hex_nodes,
100  std::vector<std::vector<unsigned int>> & rotated_tet_face_indices,
101  std::vector<std::vector<const Node *>> & tet_nodes_list);
102 
109 std::vector<bool> quadFaceDiagonalDirectionsHex(const std::vector<const Node *> & hex_nodes);
110 
117 bool quadFaceDiagonalDirection(const std::vector<const Node *> & quad_nodes);
118 
129 std::vector<std::vector<unsigned int>>
130 tetNodesForHex(const std::vector<bool> diagonal_directions,
131  std::vector<std::vector<unsigned int>> & tet_face_indices);
132 
139 void nodeRotationPRISM6(unsigned int min_id_index,
140  std::vector<unsigned int> & face_rotation,
141  std::vector<unsigned int> & node_rotation);
142 
153 void
154 prismNodesToTetNodesDeterminer(std::vector<const Node *> & prism_nodes,
155  std::vector<std::vector<unsigned int>> & rotated_tet_face_indices,
156  std::vector<std::vector<const Node *>> & tet_nodes_list);
157 
167 std::vector<std::vector<unsigned int>>
168 tetNodesForPrism(const bool diagonal_direction,
169  std::vector<std::vector<unsigned int>> & tet_face_indices);
170 
179 void nodeRotationPYRAMID5(unsigned int min_id_index,
180  std::vector<unsigned int> & face_rotation,
181  std::vector<unsigned int> & node_rotation);
182 
193 void
194 pyramidNodesToTetNodesDeterminer(std::vector<const Node *> & pyramid_nodes,
195  std::vector<std::vector<unsigned int>> & rotated_tet_face_indices,
196  std::vector<std::vector<const Node *>> & tet_nodes_list);
197 
210 void convert3DMeshToAllTet4(ReplicatedMesh & mesh,
211  const std::vector<std::pair<dof_id_type, bool>> & elems_to_process,
212  std::vector<dof_id_type> & converted_elems_ids_to_track,
213  const subdomain_id_type block_id_to_remove,
214  const bool delete_block_to_remove);
215 
220 void convert3DMeshToAllTet4(ReplicatedMesh & mesh);
221 
229 void
230 elementBoundaryInfoCollector(const std::vector<libMesh::BoundaryInfo::BCTuple> & bdry_side_list,
231  const dof_id_type elem_id,
232  const unsigned short n_elem_sides,
233  std::vector<std::vector<boundary_id_type>> & elem_side_list);
234 
244 void convertElem(ReplicatedMesh & mesh,
245  const dof_id_type & elem_id,
246  const std::vector<unsigned int> & side_indices,
247  const std::vector<std::vector<boundary_id_type>> & elem_side_info,
248  const SubdomainID & subdomain_id_shift_base);
249 
258 void convertHex8Elem(ReplicatedMesh & mesh,
259  const dof_id_type & elem_id,
260  const std::vector<unsigned int> & side_indices,
261  const std::vector<std::vector<boundary_id_type>> & elem_side_info,
262  const SubdomainID & subdomain_id_shift_base);
263 
273 void createUnitPyramid5FromHex8(ReplicatedMesh & mesh,
274  const dof_id_type & elem_id,
275  const unsigned int & side_index,
276  const Node * new_node,
277  const std::vector<boundary_id_type> & side_info,
278  const SubdomainID & subdomain_id_shift_base);
279 
289 void createUnitTet4FromHex8(ReplicatedMesh & mesh,
290  const dof_id_type & elem_id,
291  const unsigned int & side_index,
292  const Node * new_node,
293  const std::vector<boundary_id_type> & side_info,
294  const SubdomainID & subdomain_id_shift_base);
295 
304 void convertPrism6Elem(ReplicatedMesh & mesh,
305  const dof_id_type & elem_id,
306  const std::vector<unsigned int> & side_indices,
307  const std::vector<std::vector<boundary_id_type>> & elem_side_info,
308  const SubdomainID & subdomain_id_shift_base);
318 void createUnitTet4FromPrism6(ReplicatedMesh & mesh,
319  const dof_id_type & elem_id,
320  const unsigned int & side_index,
321  const Node * new_node,
322  const std::vector<boundary_id_type> & side_info,
323  const SubdomainID & subdomain_id_shift_base);
324 
335 void createUnitPyramid5FromPrism6(ReplicatedMesh & mesh,
336  const dof_id_type & elem_id,
337  const unsigned int & side_index,
338  const Node * new_node,
339  const std::vector<boundary_id_type> & side_info,
340  const SubdomainID & subdomain_id_shift_base);
341 
349 void convertPyramid5Elem(ReplicatedMesh & mesh,
350  const dof_id_type & elem_id,
351  const std::vector<std::vector<boundary_id_type>> & elem_side_info,
352  const SubdomainID & subdomain_id_shift_base);
353 
360 void retainEEID(ReplicatedMesh & mesh, const dof_id_type & elem_id, Elem * new_elem_ptr);
361 
372 void transitionLayerGenerator(ReplicatedMesh & mesh,
373  const std::vector<BoundaryName> & boundary_names,
374  const unsigned int conversion_element_layer_number,
375  const bool external_boundaries_checking);
388  ReplicatedMesh & mesh,
389  const std::set<subdomain_id_type> & original_subdomain_ids,
390  const subdomain_id_type sid_shift_base,
391  const SubdomainName & tet_suffix,
392  const SubdomainName & pyramid_suffix);
393 }
std::tuple< dof_id_type, unsigned short int, boundary_id_type > BCTuple
void convertPyramid5Elem(ReplicatedMesh &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 pyramidElemSplitter(ReplicatedMesh &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.
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 createUnitTet4FromHex8(ReplicatedMesh &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.
void createUnitPyramid5FromPrism6(ReplicatedMesh &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 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 retainEEID(ReplicatedMesh &mesh, const dof_id_type &elem_id, Elem *new_elem_ptr)
Retain the extra integer of the original element in a new element.
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 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(ReplicatedMesh &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 convert3DMeshToAllTet4(ReplicatedMesh &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...
bool operator()(const libMesh::BoundaryInfo::BCTuple &s, dof_id_type i) const
void convertElem(ReplicatedMesh &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 prismElemSplitter(ReplicatedMesh &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.
void assignConvertedElementsSubdomainNameSuffix(ReplicatedMesh &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...
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 hexElemSplitter(ReplicatedMesh &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.
void convertPrism6Elem(ReplicatedMesh &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)...
void convertHex8Elem(ReplicatedMesh &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)...
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 createUnitPyramid5FromHex8(ReplicatedMesh &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. ...
void transitionLayerGenerator(ReplicatedMesh &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