parameters: (self,
                       filename,
                       element_block_ids='all',
                       timesteps='all',
                       node_field_names='all',
                       element_field_names='all',
                       side_set_ids='all',
                       node_set_ids='all',
                       global_variable_names='all',
                       node_set_field_names='all',
                       side_set_field_names='all')
docstring: Import information from an ExodusII file.
  
          This will add to the current model in memory, so multiple calls will
          act to merge files.  As a shortcut, one may use the
          'exomerge.import_model' to create a new model from a file.
          >>> model = exomerge.import_model('output.e')
  
          By default, this will import all information from the given ExodusII
          results file.  To import only part of a mesh file, or to load only a
          particular timestep, one can use the following options.
          >>> model.import_model('output.e', element_block_ids=[1, 2])
          >>> model.import_model('output.e', timesteps='last')
          >>> model.import_model('output.e', node_field_names='disp_*')
  
          To import only the mesh without any field information, one can use the
          following syntax.
          >>> model.import_model('output.e', timesteps='none')
  
          Example:
          >>> model.import_model('mesh_file.g')
          >>> model.import_model('results_file.e')
docstring_summary: Import information from an ExodusII file.
docstring_tokens: Import information from an ExodusII file .
function: def import_model(self,
                       filename,
                       element_block_ids='all',
                       timesteps='all',
                       node_field_names='all',
                       element_field_names='all',
                       side_set_ids='all',
                       node_set_ids='all',
                       global_variable_names='all',
                       node_set_field_names='all',
                       side_set_field_names='all'):
          """
          Import information from an ExodusII file.
  
          This will add to the current model in memory, so multiple calls will
          act to merge files.  As a shortcut, one may use the
          'exomerge.import_model' to create a new model from a file.
          >>> model = exomerge.import_model('output.e')
  
          By default, this will import all information from the given ExodusII
          results file.  To import only part of a mesh file, or to load only a
          particular timestep, one can use the following options.
          >>> model.import_model('output.e', element_block_ids=[1, 2])
          >>> model.import_model('output.e', timesteps='last')
          >>> model.import_model('output.e', node_field_names='disp_*')
  
          To import only the mesh without any field information, one can use the
          following syntax.
          >>> model.import_model('output.e', timesteps='none')
  
          Example:
          >>> model.import_model('mesh_file.g')
          >>> model.import_model('results_file.e')
  
          """
          # open the file for read
          if not os.path.isfile(filename):
              self._error('File not found',
                          'The specified file "%s" was not found.' % filename)
          if SUPPRESS_EXODUS_OUTPUT:
              save_stdout = sys.stdout
              sys.stdout = DummyFile()
          exodus_file = exodus.exodus(filename, mode='r')
          if SUPPRESS_EXODUS_OUTPUT:
              sys.stdout = save_stdout
          # format timesteps to retrieve
          file_timesteps = list(exodus_file.get_times())
          if timesteps == 'last_if_any':
              if file_timesteps:
                  timesteps = 'last'
              else:
                  timesteps = 'none'
          timesteps = self._format_id_list(timesteps, file_timesteps, 'timestep')
          # format block id list
          file_element_block_ids = list(exodus_file.get_elem_blk_ids())
          file_element_block_names = []
          if file_element_block_ids:
              file_element_block_names = list(exodus_file.get_elem_blk_names())
          element_block_ids = self._format_id_list(
              element_block_ids, sorted(file_element_block_ids), 'element block')
          # format other id lists
          node_field_names = self._format_id_list(
              node_field_names,
              sorted(list(exodus_file.get_node_variable_names())), 'node field')
          file_element_field_names = list(
              exodus_file.get_element_variable_names())
          element_field_names = self._format_id_list(
              element_field_names, sorted(file_element_field_names),
              'element field')
          file_side_set_ids = list(exodus_file.get_side_set_ids())
          file_side_set_names = []
          if file_side_set_ids:
              file_side_set_names = list(exodus_file.get_side_set_names())
          side_set_ids = self._format_id_list(side_set_ids,
                                              sorted(file_side_set_ids),
                                              'side set')
          file_node_set_ids = list(exodus_file.get_node_set_ids())
          file_node_set_names = []
          if file_node_set_ids:
              file_node_set_names = list(exodus_file.get_node_set_names())
          node_set_ids = self._format_id_list(node_set_ids,
                                              sorted(file_node_set_ids),
                                              'node set')
          global_variable_names = self._format_id_list(
              global_variable_names,
              sorted(list(exodus_file.get_global_variable_names())),
              'global variable')
          file_node_set_field_names = list(
              exodus_file.get_node_set_variable_names())
          node_set_field_names = self._format_id_list(
              node_set_field_names, sorted(file_node_set_field_names),
              'node set field')
          file_side_set_field_names = list(
              exodus_file.get_side_set_variable_names())
          side_set_field_names = self._format_id_list(
              side_set_field_names, sorted(file_side_set_field_names),
              'node set field')
          # ensure element blocks in this file do not already exist
          for element_block_id in element_block_ids:
              if self.element_block_exists(element_block_id):
                  self._error(
                      'Element block already exists.',
                      'Cannot import element block \"%d\" since it already '
                      'exists in the model.' % element_block_id)
          # create new nodes used in this file
          node_offset = len(self.nodes)
          # store nodes we are going to import
          # if we're importing all element blocks, then import all nodes
          # else only import nodes in the element blocks we're choosing
          # note that if there are no element blocks, this means we import all
          # nodes
          # note: new_used_nodes is 1-based
          if element_block_ids == sorted(file_element_block_ids):
              new_used_nodes = list(range(1, exodus_file.num_nodes() + 1))
          else:
              new_used_nodes = [False] * exodus_file.num_nodes()
              # add nodes in blocks we are importing
              for element_block_id in element_block_ids:
                  connectivity = exodus_file.get_elem_connectivity(
                      element_block_id)[0]
                  for i in connectivity:
                      new_used_nodes[i - 1] = True
              # save indices for nodes we want to import
              new_used_nodes = [i + 1 for i, x in enumerate(new_used_nodes) if x]
          # get new node coordinates
          new_nodes = []
          file_coords = [list(x) for x in exodus_file.get_coords()]
          for i in new_used_nodes:
              new_nodes.append([file_coords[x][i - 1] for x in range(3)])
          # create node mapping
          # node i in the file refers to node node_map[i] in the model
          node_map = [None] * (exodus_file.num_nodes() + 1)
          for i, node in enumerate(new_used_nodes):
              node_map[node] = i + node_offset
          # create new nodes
          self.create_nodes(new_nodes)
          # find element mapping
          # element i in the file refers to
          # - element block id file_block_from_element[i]
          # - local element index file_index_from_element[i]
          # in the model
          elements_in_block = []
          for i in file_element_block_ids:
              elements_in_block.append(exodus_file.elem_blk_info(i)[1])
          file_block_from_element = [None]
          file_index_from_element = [None]
          for i, ebid in enumerate(file_element_block_ids):
              if ebid in element_block_ids:
                  file_block_from_element.extend([ebid] * elements_in_block[i])
                  file_index_from_element.extend(range(elements_in_block[i]))
              else:
                  file_block_from_element.extend([None] * elements_in_block[i])
                  file_index_from_element.extend([None] * elements_in_block[i])
          # create new element blocks
          for element_block_id in element_block_ids:
              new_connectivity = list(
                  exodus_file.get_elem_connectivity(element_block_id))[0]
              # apply node map
              new_connectivity = [node_map[x] for x in new_connectivity]
              # get the element block name
              element_block_name = file_element_block_names[
                  file_element_block_ids.index(element_block_id)]
              # create the element block
              self.create_element_block(
                  element_block_id,
                  list(exodus_file.elem_blk_info(element_block_id)),
                  connectivity=new_connectivity)
              if element_block_name:
                  self.rename_element_block(element_block_id, element_block_name)
          # get indices of each timestep and create new timesteps
          # list of (timestep_index_in_file, timestep_index_in_model)
          timestep_indices = []
          duplicate_timesteps = False
          for timestep in timesteps:
              if not self.timestep_exists(timestep):
                  self.create_timestep(timestep)
              else:
                  duplicate_timesteps = True
              timestep_indices.append(
                  (file_timesteps.index(timestep) + 1,
                   self._get_internal_timestep_index(timestep)))
          # get list of timestep indices present in the model but not included
          # in the import
          included_timestep_indices = [x[1] for x in timestep_indices]
          excluded_timestep_indices = []
          for i in range(len(self.timesteps)):
              if i not in included_timestep_indices:
                  excluded_timestep_indices.append(i)
          # create new node fields
          for node_field_name in node_field_names:
              if not self.node_field_exists(node_field_name):
                  self.create_node_field(node_field_name)
          # populate node field info
          for node_field_name in node_field_names:
              for timestep_index in timestep_indices:
                  file_node_field_values = list(
                      exodus_file.get_node_variable_values(
                          node_field_name, timestep_index[0]))
                  model_values = self.node_fields[node_field_name][
                      timestep_index[1]]
                  for i in new_used_nodes:
                      model_values[node_map[i]] = file_node_field_values[i - 1]
          # populate node sets
          for node_set_id in node_set_ids:
              file_node_set_members = exodus_file.get_node_set_nodes(node_set_id)
              model_node_set_members = []
              # add nodes which were included
              for i in file_node_set_members:
                  if node_map[i] is not None:
                      model_node_set_members.append(node_map[i])
              # create the node set or add to an existing set
              if not self.node_set_exists(node_set_id):
                  self.create_node_set(node_set_id, model_node_set_members)
              else:
                  self.add_nodes_to_node_set(node_set_id, model_node_set_members)
              node_set_name = file_node_set_names[file_node_set_ids.index(
                  node_set_id)]
              if node_set_name:
                  self.rename_node_set(node_set_id, node_set_name)
          # populate side sets
          for side_set_id in side_set_ids:
              file_side_set_members = exodus_file.get_side_set(side_set_id)
              model_side_set_members = []
              # add nodes which were included
              for element_index, side_number in zip(*file_side_set_members):
                  if file_block_from_element[element_index] is not None:
                      model_side_set_members.append(
                          (file_block_from_element[element_index],
                           file_index_from_element[element_index],
                           side_number - 1))
              # create the side set or add to an existing set
              if not self.side_set_exists(side_set_id):
                  self.create_side_set(side_set_id, model_side_set_members)
              else:
                  self.add_faces_to_side_set(side_set_id, model_side_set_members)
              side_set_name = file_side_set_names[file_side_set_ids.index(
                  side_set_id)]
              if side_set_name:
                  self.rename_side_set(side_set_id, side_set_name)
          # store truth table for node set field info
          if node_set_field_names:
              file_node_set_truth_table = []
              for file_node_set_id in file_node_set_ids:
                  file_node_set_truth_table.append(
                      exodus_file.get_node_set_variable_truth_table(
                          file_node_set_id))
          # populate node set fields
          for node_set_field_name in node_set_field_names:
              for node_set_id in node_set_ids:
                  # don't process if field does not exist in file
                  field_exists = file_node_set_truth_table[
                      file_node_set_ids.index(node_set_id)][
                          file_node_set_field_names.index(node_set_field_name)]
                  if not field_exists:
                      continue
                  # process each included timestep
                  model_values = [None] * len(self.timesteps)
                  for timestep_index in timestep_indices:
                      file_values = list(
                          exodus_file.get_node_set_variable_values(
                              node_set_id, node_set_field_name,
                              timestep_index[0]))
                      model_values[timestep_index[1]] = file_values
                  # add default field value to excluded timestep
                  for timestep_index in excluded_timestep_indices:
                      default_value = self._get_default_field_value(
                          node_set_field_name)
                      node_count = len(self.get_node_set_members(node_set_id))
                      field = [default_value] * node_count
                      model_values[timestep_index] = field
                  # assign all values
                  fields = self._get_node_set_fields(node_set_id)
                  fields[node_set_field_name] = model_values
          # store truth table for side set field info
          if side_set_field_names:
              file_side_set_truth_table = []
              for file_side_set_id in file_side_set_ids:
                  file_side_set_truth_table.append(
                      exodus_file.get_side_set_variable_truth_table(
                          file_side_set_id))
          # populate side set fields
          for side_set_field_name in side_set_field_names:
              for side_set_id in side_set_ids:
                  # don't process if field does not exist in file
                  field_exists = file_side_set_truth_table[
                      file_side_set_ids.index(side_set_id)][
                          file_side_set_field_names.index(side_set_field_name)]
                  if not field_exists:
                      continue
                  # process each included timestep
                  model_values = [None] * len(self.timesteps)
                  for timestep_index in timestep_indices:
                      file_values = list(
                          exodus_file.get_side_set_variable_values(
                              side_set_id, side_set_field_name,
                              timestep_index[0]))
                      model_values[timestep_index[1]] = file_values
                  # add default field value to excluded timestep
                  for timestep_index in excluded_timestep_indices:
                      default_value = self._get_default_field_value(
                          side_set_field_name)
                      side_count = len(self.get_side_set_members(side_set_id))
                      field = [default_value] * side_count
                      model_values[timestep_index] = field
                  # assign all values
                  fields = self._get_side_set_fields(side_set_id)
                  fields[side_set_field_name] = model_values
          # store truth table for element field info
          if element_field_names:
              file_truth_table = []
              for file_element_block_id in file_element_block_ids:
                  file_truth_table.append(
                      exodus_file.get_element_variable_truth_table(
                          file_element_block_id))
          # populate element fields
          for element_field_name in element_field_names:
              for element_block_id in element_block_ids:
                  # don't process if field does not exist in file
                  field_exists = file_truth_table[file_element_block_ids.index(
                      element_block_id)][file_element_field_names.index(
                          element_field_name)]
                  if not field_exists:
                      continue
                  # process each included timestep
                  model_values = [None] * len(self.timesteps)
                  for timestep_index in timestep_indices:
                      file_values = list(
                          exodus_file.get_element_variable_values(
                              element_block_id, element_field_name,
                              timestep_index[0]))
                      model_values[timestep_index[1]] = file_values
                  # add default field value to excluded timestep
                  for timestep_index in excluded_timestep_indices:
                      default_value = self._get_default_field_value(
                          element_field_name)
                      element_count = self.get_element_count(element_block_id)
                      field = [default_value] * element_count
                      model_values[timestep_index] = field
                  # assign all values
                  fields = self._get_element_block_fields(element_block_id)
                  fields[element_field_name] = model_values
          # get global variables
          for global_variable_name in global_variable_names:
              # create the variable
              if not self.global_variable_exists(global_variable_name):
                  self.create_global_variable(global_variable_name)
              else:
                  if duplicate_timesteps:
                      self._exists_warning(global_variable_name,
                                           'global variable')
              # get values
              model_values = self.global_variables[global_variable_name]
              for timestep_index in timestep_indices:
                  file_value = exodus_file.get_global_variable_value(
                      global_variable_name, timestep_index[0])
                  model_values[timestep_index[1]] = file_value
          # add info records
          if (exodus_file.num_info_records() > 0):
              self.info_records += exodus_file.get_info_records()
          # add qa records
          if (exodus_file.num_qa_records() > 0):
              self.qa_records += exodus_file.get_qa_records()
          # add title if one does not already exist
          # else add it to an info record
          if not self.title:
              self.title = exodus_file.title()
          else:
              self.info_records.append('Discarded title from the '
                                       'following file:')
              self.info_records.append(filename)
              self.info_records.append(exodus_file.title())
          # run a check on the model to ensure arrays are correct sizes
          self._verify()
          # close the file
          if SUPPRESS_EXODUS_OUTPUT:
              save_stdout = sys.stdout
              sys.stdout = DummyFile()
          exodus_file.close()
          if SUPPRESS_EXODUS_OUTPUT:
              sys.stdout = save_stdout
function_tokens: def import_model ( self , filename , element_block_ids = 'all' , timesteps = 'all' , node_field_names = 'all' , element_field_names = 'all' , side_set_ids = 'all' , node_set_ids = 'all' , global_variable_names = 'all' , node_set_field_names = 'all' , side_set_field_names = 'all' ) : # open the file for read if not os . path . isfile ( filename ) : self . _error ( 'File not found' , 'The specified file "%s" was not found.' % filename ) if SUPPRESS_EXODUS_OUTPUT : save_stdout = sys . stdout sys . stdout = DummyFile ( ) exodus_file = exodus . exodus ( filename , mode = 'r' ) if SUPPRESS_EXODUS_OUTPUT : sys . stdout = save_stdout # format timesteps to retrieve file_timesteps = list ( exodus_file . get_times ( ) ) if timesteps == 'last_if_any' : if file_timesteps : timesteps = 'last' else : timesteps = 'none' timesteps = self . _format_id_list ( timesteps , file_timesteps , 'timestep' ) # format block id list file_element_block_ids = list ( exodus_file . get_elem_blk_ids ( ) ) file_element_block_names = [ ] if file_element_block_ids : file_element_block_names = list ( exodus_file . get_elem_blk_names ( ) ) element_block_ids = self . _format_id_list ( element_block_ids , sorted ( file_element_block_ids ) , 'element block' ) # format other id lists node_field_names = self . _format_id_list ( node_field_names , sorted ( list ( exodus_file . get_node_variable_names ( ) ) ) , 'node field' ) file_element_field_names = list ( exodus_file . get_element_variable_names ( ) ) element_field_names = self . _format_id_list ( element_field_names , sorted ( file_element_field_names ) , 'element field' ) file_side_set_ids = list ( exodus_file . get_side_set_ids ( ) ) file_side_set_names = [ ] if file_side_set_ids : file_side_set_names = list ( exodus_file . get_side_set_names ( ) ) side_set_ids = self . _format_id_list ( side_set_ids , sorted ( file_side_set_ids ) , 'side set' ) file_node_set_ids = list ( exodus_file . get_node_set_ids ( ) ) file_node_set_names = [ ] if file_node_set_ids : file_node_set_names = list ( exodus_file . get_node_set_names ( ) ) node_set_ids = self . _format_id_list ( node_set_ids , sorted ( file_node_set_ids ) , 'node set' ) global_variable_names = self . _format_id_list ( global_variable_names , sorted ( list ( exodus_file . get_global_variable_names ( ) ) ) , 'global variable' ) file_node_set_field_names = list ( exodus_file . get_node_set_variable_names ( ) ) node_set_field_names = self . _format_id_list ( node_set_field_names , sorted ( file_node_set_field_names ) , 'node set field' ) file_side_set_field_names = list ( exodus_file . get_side_set_variable_names ( ) ) side_set_field_names = self . _format_id_list ( side_set_field_names , sorted ( file_side_set_field_names ) , 'node set field' ) # ensure element blocks in this file do not already exist for element_block_id in element_block_ids : if self . element_block_exists ( element_block_id ) : self . _error ( 'Element block already exists.' , 'Cannot import element block \"%d\" since it already ' 'exists in the model.' % element_block_id ) # create new nodes used in this file node_offset = len ( self . nodes ) # store nodes we are going to import # if we're importing all element blocks, then import all nodes # else only import nodes in the element blocks we're choosing # note that if there are no element blocks, this means we import all # nodes # note: new_used_nodes is 1-based if element_block_ids == sorted ( file_element_block_ids ) : new_used_nodes = list ( range ( 1 , exodus_file . num_nodes ( ) + 1 ) ) else : new_used_nodes = [ False ] * exodus_file . num_nodes ( ) # add nodes in blocks we are importing for element_block_id in element_block_ids : connectivity = exodus_file . get_elem_connectivity ( element_block_id ) [ 0 ] for i in connectivity : new_used_nodes [ i - 1 ] = True # save indices for nodes we want to import new_used_nodes = [ i + 1 for i , x in enumerate ( new_used_nodes ) if x ] # get new node coordinates new_nodes = [ ] file_coords = [ list ( x ) for x in exodus_file . get_coords ( ) ] for i in new_used_nodes : new_nodes . append ( [ file_coords [ x ] [ i - 1 ] for x in range ( 3 ) ] ) # create node mapping # node i in the file refers to node node_map[i] in the model node_map = [ None ] * ( exodus_file . num_nodes ( ) + 1 ) for i , node in enumerate ( new_used_nodes ) : node_map [ node ] = i + node_offset # create new nodes self . create_nodes ( new_nodes ) # find element mapping # element i in the file refers to # - element block id file_block_from_element[i] # - local element index file_index_from_element[i] # in the model elements_in_block = [ ] for i in file_element_block_ids : elements_in_block . append ( exodus_file . elem_blk_info ( i ) [ 1 ] ) file_block_from_element = [ None ] file_index_from_element = [ None ] for i , ebid in enumerate ( file_element_block_ids ) : if ebid in element_block_ids : file_block_from_element . extend ( [ ebid ] * elements_in_block [ i ] ) file_index_from_element . extend ( range ( elements_in_block [ i ] ) ) else : file_block_from_element . extend ( [ None ] * elements_in_block [ i ] ) file_index_from_element . extend ( [ None ] * elements_in_block [ i ] ) # create new element blocks for element_block_id in element_block_ids : new_connectivity = list ( exodus_file . get_elem_connectivity ( element_block_id ) ) [ 0 ] # apply node map new_connectivity = [ node_map [ x ] for x in new_connectivity ] # get the element block name element_block_name = file_element_block_names [ file_element_block_ids . index ( element_block_id ) ] # create the element block self . create_element_block ( element_block_id , list ( exodus_file . elem_blk_info ( element_block_id ) ) , connectivity = new_connectivity ) if element_block_name : self . rename_element_block ( element_block_id , element_block_name ) # get indices of each timestep and create new timesteps # list of (timestep_index_in_file, timestep_index_in_model) timestep_indices = [ ] duplicate_timesteps = False for timestep in timesteps : if not self . timestep_exists ( timestep ) : self . create_timestep ( timestep ) else : duplicate_timesteps = True timestep_indices . append ( ( file_timesteps . index ( timestep ) + 1 , self . _get_internal_timestep_index ( timestep ) ) ) # get list of timestep indices present in the model but not included # in the import included_timestep_indices = [ x [ 1 ] for x in timestep_indices ] excluded_timestep_indices = [ ] for i in range ( len ( self . timesteps ) ) : if i not in included_timestep_indices : excluded_timestep_indices . append ( i ) # create new node fields for node_field_name in node_field_names : if not self . node_field_exists ( node_field_name ) : self . create_node_field ( node_field_name ) # populate node field info for node_field_name in node_field_names : for timestep_index in timestep_indices : file_node_field_values = list ( exodus_file . get_node_variable_values ( node_field_name , timestep_index [ 0 ] ) ) model_values = self . node_fields [ node_field_name ] [ timestep_index [ 1 ] ] for i in new_used_nodes : model_values [ node_map [ i ] ] = file_node_field_values [ i - 1 ] # populate node sets for node_set_id in node_set_ids : file_node_set_members = exodus_file . get_node_set_nodes ( node_set_id ) model_node_set_members = [ ] # add nodes which were included for i in file_node_set_members : if node_map [ i ] is not None : model_node_set_members . append ( node_map [ i ] ) # create the node set or add to an existing set if not self . node_set_exists ( node_set_id ) : self . create_node_set ( node_set_id , model_node_set_members ) else : self . add_nodes_to_node_set ( node_set_id , model_node_set_members ) node_set_name = file_node_set_names [ file_node_set_ids . index ( node_set_id ) ] if node_set_name : self . rename_node_set ( node_set_id , node_set_name ) # populate side sets for side_set_id in side_set_ids : file_side_set_members = exodus_file . get_side_set ( side_set_id ) model_side_set_members = [ ] # add nodes which were included for element_index , side_number in zip ( * file_side_set_members ) : if file_block_from_element [ element_index ] is not None : model_side_set_members . append ( ( file_block_from_element [ element_index ] , file_index_from_element [ element_index ] , side_number - 1 ) ) # create the side set or add to an existing set if not self . side_set_exists ( side_set_id ) : self . create_side_set ( side_set_id , model_side_set_members ) else : self . add_faces_to_side_set ( side_set_id , model_side_set_members ) side_set_name = file_side_set_names [ file_side_set_ids . index ( side_set_id ) ] if side_set_name : self . rename_side_set ( side_set_id , side_set_name ) # store truth table for node set field info if node_set_field_names : file_node_set_truth_table = [ ] for file_node_set_id in file_node_set_ids : file_node_set_truth_table . append ( exodus_file . get_node_set_variable_truth_table ( file_node_set_id ) ) # populate node set fields for node_set_field_name in node_set_field_names : for node_set_id in node_set_ids : # don't process if field does not exist in file field_exists = file_node_set_truth_table [ file_node_set_ids . index ( node_set_id ) ] [ file_node_set_field_names . index ( node_set_field_name ) ] if not field_exists : continue # process each included timestep model_values = [ None ] * len ( self . timesteps ) for timestep_index in timestep_indices : file_values = list ( exodus_file . get_node_set_variable_values ( node_set_id , node_set_field_name , timestep_index [ 0 ] ) ) model_values [ timestep_index [ 1 ] ] = file_values # add default field value to excluded timestep for timestep_index in excluded_timestep_indices : default_value = self . _get_default_field_value ( node_set_field_name ) node_count = len ( self . get_node_set_members ( node_set_id ) ) field = [ default_value ] * node_count model_values [ timestep_index ] = field # assign all values fields = self . _get_node_set_fields ( node_set_id ) fields [ node_set_field_name ] = model_values # store truth table for side set field info if side_set_field_names : file_side_set_truth_table = [ ] for file_side_set_id in file_side_set_ids : file_side_set_truth_table . append ( exodus_file . get_side_set_variable_truth_table ( file_side_set_id ) ) # populate side set fields for side_set_field_name in side_set_field_names : for side_set_id in side_set_ids : # don't process if field does not exist in file field_exists = file_side_set_truth_table [ file_side_set_ids . index ( side_set_id ) ] [ file_side_set_field_names . index ( side_set_field_name ) ] if not field_exists : continue # process each included timestep model_values = [ None ] * len ( self . timesteps ) for timestep_index in timestep_indices : file_values = list ( exodus_file . get_side_set_variable_values ( side_set_id , side_set_field_name , timestep_index [ 0 ] ) ) model_values [ timestep_index [ 1 ] ] = file_values # add default field value to excluded timestep for timestep_index in excluded_timestep_indices : default_value = self . _get_default_field_value ( side_set_field_name ) side_count = len ( self . get_side_set_members ( side_set_id ) ) field = [ default_value ] * side_count model_values [ timestep_index ] = field # assign all values fields = self . _get_side_set_fields ( side_set_id ) fields [ side_set_field_name ] = model_values # store truth table for element field info if element_field_names : file_truth_table = [ ] for file_element_block_id in file_element_block_ids : file_truth_table . append ( exodus_file . get_element_variable_truth_table ( file_element_block_id ) ) # populate element fields for element_field_name in element_field_names : for element_block_id in element_block_ids : # don't process if field does not exist in file field_exists = file_truth_table [ file_element_block_ids . index ( element_block_id ) ] [ file_element_field_names . index ( element_field_name ) ] if not field_exists : continue # process each included timestep model_values = [ None ] * len ( self . timesteps ) for timestep_index in timestep_indices : file_values = list ( exodus_file . get_element_variable_values ( element_block_id , element_field_name , timestep_index [ 0 ] ) ) model_values [ timestep_index [ 1 ] ] = file_values # add default field value to excluded timestep for timestep_index in excluded_timestep_indices : default_value = self . _get_default_field_value ( element_field_name ) element_count = self . get_element_count ( element_block_id ) field = [ default_value ] * element_count model_values [ timestep_index ] = field # assign all values fields = self . _get_element_block_fields ( element_block_id ) fields [ element_field_name ] = model_values # get global variables for global_variable_name in global_variable_names : # create the variable if not self . global_variable_exists ( global_variable_name ) : self . create_global_variable ( global_variable_name ) else : if duplicate_timesteps : self . _exists_warning ( global_variable_name , 'global variable' ) # get values model_values = self . global_variables [ global_variable_name ] for timestep_index in timestep_indices : file_value = exodus_file . get_global_variable_value ( global_variable_name , timestep_index [ 0 ] ) model_values [ timestep_index [ 1 ] ] = file_value # add info records if ( exodus_file . num_info_records ( ) > 0 ) : self . info_records += exodus_file . get_info_records ( ) # add qa records if ( exodus_file . num_qa_records ( ) > 0 ) : self . qa_records += exodus_file . get_qa_records ( ) # add title if one does not already exist # else add it to an info record if not self . title : self . title = exodus_file . title ( ) else : self . info_records . append ( 'Discarded title from the ' 'following file:' ) self . info_records . append ( filename ) self . info_records . append ( exodus_file . title ( ) ) # run a check on the model to ensure arrays are correct sizes self . _verify ( ) # close the file if SUPPRESS_EXODUS_OUTPUT : save_stdout = sys . stdout sys . stdout = DummyFile ( ) exodus_file . close ( ) if SUPPRESS_EXODUS_OUTPUT : sys . stdout = save_stdout