parameters: (self,
                                              side_set_ids,
                                              new_element_block_id='auto')
docstring: Create a new 'tri3' element block composed of the given side set.
  
          The side set must contain faces of three dimensional elements.
docstring_summary: Create a new 'tri3' element block composed of the given side set.
docstring_tokens: Create a new tri3 element block composed of the given side set .
function: def _convert_side_set_to_triangle_block(self,
                                              side_set_ids,
                                              new_element_block_id='auto'):
          """
          Create a new 'tri3' element block composed of the given side set.
  
          The side set must contain faces of three dimensional elements.
  
          """
          side_set_ids = self._format_side_set_id_list(side_set_ids)
          if new_element_block_id == 'auto':
              new_element_block_id = self._new_element_block_id()
          new_nodes = []
          # find members of all the given side sets by block
          members_by_block = self._order_element_faces_by_block(
              itertools.chain(*[self.get_side_set_members(x)
                                for x in side_set_ids]))
          # ensure all blocks are 3D
          for id_ in members_by_block.keys():
              element_type = self._get_element_type(id_)
              dimension = self._get_dimension(element_type)
              if dimension != 3:
                  self._error('Incompatible element dimension.',
                              'We expect the side set to contain faces of 3D '
                              'elements.  However, the side set contains at '
                              'least one face from element block %d which '
                              'contains %dD elements of type "%s".' %
                              (id_, dimension, element_type))
          # Now we need to create the triangles from each member of the side set.
          faces = dict()
          for element_block_id, members in members_by_block.items():
              connectivity = self.get_connectivity(element_block_id)
              nodes_per_element = self.get_nodes_per_element(element_block_id)
              face_mapping = self._get_face_mapping_from_id(element_block_id)
              for element_index, face_index in members:
                  face_element_map = face_mapping[face_index]
                  local_node = connectivity[
                      element_index * nodes_per_element:
                      (element_index + 1) * nodes_per_element]
                  local_node = tuple(local_node[x] for x in face_element_map[1])
                  if not face_element_map[0] in faces:
                      faces[face_element_map[0]] = [local_node]
                  else:
                      faces[face_element_map[0]].append(local_node)
          # now triangulate each face
          connectivity = []
          next_node_index = len(self.nodes)
          new_nodes = []
          for element_type, connectivity_list in faces.items():
              triangulated_faces = self._get_triangulated_faces(element_type)
              for local_face_indices in connectivity_list:
                  for face_indices in triangulated_faces:
                      for index in face_indices:
                          if isinstance(index, int):
                              connectivity.append(local_face_indices[index])
                              continue
                          averaged_nodes = tuple(local_face_indices[x]
                                                 for x in index)
                          if not new_nodes or new_nodes[-1] != averaged_nodes:
                              new_nodes.append(averaged_nodes)
                              next_node_index += 1
                          connectivity.append(next_node_index - 1)
          # create the new nodes
          self._create_averaged_nodes(new_nodes, [])
          # create the new element block
          self.create_element_block(new_element_block_id,
                                    ['tri3', len(connectivity) / 3, 3, 0],
                                    connectivity)
function_tokens: def _convert_side_set_to_triangle_block ( self , side_set_ids , new_element_block_id = 'auto' ) : side_set_ids = self . _format_side_set_id_list ( side_set_ids ) if new_element_block_id == 'auto' : new_element_block_id = self . _new_element_block_id ( ) new_nodes = [ ] # find members of all the given side sets by block members_by_block = self . _order_element_faces_by_block ( itertools . chain ( * [ self . get_side_set_members ( x ) for x in side_set_ids ] ) ) # ensure all blocks are 3D for id_ in members_by_block . keys ( ) : element_type = self . _get_element_type ( id_ ) dimension = self . _get_dimension ( element_type ) if dimension != 3 : self . _error ( 'Incompatible element dimension.' , 'We expect the side set to contain faces of 3D ' 'elements.  However, the side set contains at ' 'least one face from element block %d which ' 'contains %dD elements of type "%s".' % ( id_ , dimension , element_type ) ) # Now we need to create the triangles from each member of the side set. faces = dict ( ) for element_block_id , members in members_by_block . items ( ) : connectivity = self . get_connectivity ( element_block_id ) nodes_per_element = self . get_nodes_per_element ( element_block_id ) face_mapping = self . _get_face_mapping_from_id ( element_block_id ) for element_index , face_index in members : face_element_map = face_mapping [ face_index ] local_node = connectivity [ element_index * nodes_per_element : ( element_index + 1 ) * nodes_per_element ] local_node = tuple ( local_node [ x ] for x in face_element_map [ 1 ] ) if not face_element_map [ 0 ] in faces : faces [ face_element_map [ 0 ] ] = [ local_node ] else : faces [ face_element_map [ 0 ] ] . append ( local_node ) # now triangulate each face connectivity = [ ] next_node_index = len ( self . nodes ) new_nodes = [ ] for element_type , connectivity_list in faces . items ( ) : triangulated_faces = self . _get_triangulated_faces ( element_type ) for local_face_indices in connectivity_list : for face_indices in triangulated_faces : for index in face_indices : if isinstance ( index , int ) : connectivity . append ( local_face_indices [ index ] ) continue averaged_nodes = tuple ( local_face_indices [ x ] for x in index ) if not new_nodes or new_nodes [ - 1 ] != averaged_nodes : new_nodes . append ( averaged_nodes ) next_node_index += 1 connectivity . append ( next_node_index - 1 ) # create the new nodes self . _create_averaged_nodes ( new_nodes , [ ] ) # create the new element block self . create_element_block ( new_element_block_id , [ 'tri3' , len ( connectivity ) / 3 , 3 , 0 ] , connectivity )