parameters: (
          exoFrom,
          exo_to,
          array_type='ctype',
          additionalGlobalVariables=[],
          additionalNodalVariables=[],
          additionalElementVariables=[])
return_statement: return exo_to
docstring: This function transfers variables from exoFrom to exo_to and allows
        additional variables to be added with additionalGlobalVariables,
        additionalNodalVariables, and additionalElementVariables.  Additional
        variables values are set to their defaults so that the user can populate
        them later.
  
        exoFrom: exodus object to transfer from
  
        exo_to: exodus object to transfer to
  
        additionalGlobalVariables: list of global variable names to add.
  
        additionalNodalVaraibles: list of nodal variable names to add.
  
        additionalElementVariables: should be a list of element variable names to add to all blocks or
          tuples (name, blkIds) where name is the element variable to add
          and blkIds is a list of blkIds to add it to.
docstring_summary: This function transfers variables from exoFrom to exo_to and allows
        additional variables to be added with additionalGlobalVariables,
        additionalNodalVariables, and additionalElementVariables.  Additional
        variables values are set to their defaults so that the user can populate
        them later.
docstring_tokens: This function transfers variables from exoFrom to exo_to and allows additional variables to be added with additionalGlobalVariables additionalNodalVariables and additionalElementVariables . Additional variables values are set to their defaults so that the user can populate them later .
function: def transfer_variables(
          exoFrom,
          exo_to,
          array_type='ctype',
          additionalGlobalVariables=[],
          additionalNodalVariables=[],
          additionalElementVariables=[]):
      """
        This function transfers variables from exoFrom to exo_to and allows
        additional variables to be added with additionalGlobalVariables,
        additionalNodalVariables, and additionalElementVariables.  Additional
        variables values are set to their defaults so that the user can populate
        them later.
  
        exoFrom: exodus object to transfer from
  
        exo_to: exodus object to transfer to
  
        additionalGlobalVariables: list of global variable names to add.
  
        additionalNodalVaraibles: list of nodal variable names to add.
  
        additionalElementVariables: should be a list of element variable names to add to all blocks or
          tuples (name, blkIds) where name is the element variable to add
          and blkIds is a list of blkIds to add it to.
      """
      # IDEA: It may make sense to make transfer_variables() strictly transfer
      # variables, and use add_variables() to add new variables.  Alternatively,
      # add_variables() could be called within transfer_variables() to add
      # new variables to the exo_to database.  Either way, we should minimize
      # duplicate code if possible.
  
      debugPrint = False
  
      if not isinstance(additionalGlobalVariables, list):
          raise Exception("ERROR: additionalGlobalVariables is not a list.")
      if not isinstance(additionalNodalVariables, list):
          raise Exception("ERROR: additionalNodalVariables is not a list.")
      if not isinstance(additionalElementVariables, list):
          raise Exception("ERROR: additionalElementVariables is not a list.")
  
      if debugPrint:
          print("Transfer Info records")
      numInfoRecs = exoFrom.num_info_records()
      if numInfoRecs > 0:
          infoRecs = exoFrom.get_info_records()
          exo_to.put_info_records(infoRecs)
      if debugPrint:
          print("Transfer time values")
  
      nSteps = exoFrom.num_times()
      if nSteps == 0:
          return exo_to
  
      timeVals = exoFrom.get_times()
      for step in xrange(nSteps):
          exo_to.put_time(step + 1, timeVals[step])
  
      if debugPrint:
          print("Add Global Variables")
      nNewGlobalVars = len(additionalGlobalVariables)
      nGlobalVars = exoFrom.get_global_variable_number() + nNewGlobalVars
      defaultNewVarVals = []
      for i in xrange(nNewGlobalVars):
          defaultNewVarVals.append(0.0)
      if nGlobalVars > 0:
          exo_to.set_global_variable_number(nGlobalVars)
          gVarNames = exoFrom.get_global_variable_names()
          gVarNames.extend(additionalGlobalVariables)
          for nameIndex in xrange(nGlobalVars):
              globalVarName = gVarNames[nameIndex]
              exo_to.put_global_variable_name(globalVarName, nameIndex + 1)
          for step in xrange(nSteps):
              gValues = exoFrom.get_all_global_variable_values(step + 1)
              if array_type == 'numpy':
                  gValues = exo_to.np.append(gValues, defaultNewVarVals)
              else:
                  gValues.extend(defaultNewVarVals)
              exo_to.put_all_global_variable_values(step + 1, gValues)
  
      if debugPrint:
          print("Add Nodal Variables")
      nNewNodalVars = len(additionalNodalVariables)
      nOrigNodalVars = exoFrom.get_node_variable_number()
      nNodalVars = nOrigNodalVars + nNewNodalVars
      if nNodalVars > 0:
          exo_to.set_node_variable_number(nNodalVars)
          nVarNames = exoFrom.get_node_variable_names()
          nVarNames.extend(additionalNodalVariables)
          for nameIndex in xrange(nNodalVars):
              nodalVarName = nVarNames[nameIndex]
              exo_to.put_node_variable_name(nodalVarName, nameIndex + 1)
              if nameIndex < nOrigNodalVars:
                  for step in xrange(nSteps):
                      nValues = exoFrom.get_node_variable_values(
                          nodalVarName, step + 1)
                      exo_to.put_node_variable_values(
                          nodalVarName, step + 1, nValues)
  
      if debugPrint:
          print("Construct Truth Table for additionalElementVariables")
      blkIds = exoFrom.get_elem_blk_ids()
      numBlks = exoFrom.num_blks()
      newElemVariableNames = []
      newElemVariableBlocks = []
      for item in additionalElementVariables:
          if isinstance(item, tuple):
              newElemVariableNames.append(item[0])
              inBlks = []
              for blkId in item[1]:
                  if blkId in blkIds:
                      inBlks.append(blkId)
              newElemVariableBlocks.append(inBlks)
          elif isinstance(item, str):
              newElemVariableNames.append(item)
              newElemVariableBlocks.append(blkIds)
          else:
              print("Warning additionalElementVariable item ",
                    item, " is not right type to add.")
              print("should be a string or tuple, skipping")
  
      if debugPrint:
          print("Add Element Variables")
      nNewElemVars = len(newElemVariableNames)
      nOrigElemVars = exoFrom.get_element_variable_number()
      nElemVars = nOrigElemVars + nNewElemVars
      if nElemVars > 0:
          exo_to.set_element_variable_number(nElemVars)
          origElemVarNames = exoFrom.get_element_variable_names()
          eVarNames = exoFrom.get_element_variable_names()
          eVarNames.extend(newElemVariableNames)
          truthTable = []
          if nOrigElemVars > 0:
              truthTable = exoFrom.get_element_variable_truth_table()
          if nNewElemVars > 0:
              newTruth = []
              for j in xrange(numBlks):
                  for k in xrange(nOrigElemVars):
                      index = j * nOrigElemVars + k
                      newTruth.append(truthTable[index])
                  for m in xrange(nNewElemVars):
                      if blkIds[j] in newElemVariableBlocks[m]:
                          newTruth.append(True)
                      else:
                          newTruth.append(False)
              truthTable = newTruth
          exo_to.set_element_variable_truth_table(truthTable)
          for nameIndex in xrange(nElemVars):
              elemVarName = eVarNames[nameIndex]
              exo_to.put_element_variable_name(elemVarName, nameIndex + 1)
          truthIndex = 0
          for blkId in blkIds:
              for eVarName in origElemVarNames:
                  if truthTable[truthIndex]:
                      for step in xrange(nSteps):
                          eValues = exoFrom.get_element_variable_values(
                              blkId, eVarName, step + 1)
                          exo_to.put_element_variable_values(
                              blkId, eVarName, step + 1, eValues)
                  truthIndex = truthIndex + 1
              truthIndex = truthIndex + nNewElemVars
  
      # TODO: Transfer Nodeset Variables
  
      # TODO: Transfer Sideset Variables
  
      return exo_to
function_tokens: def transfer_variables ( exoFrom , exo_to , array_type = 'ctype' , additionalGlobalVariables = [ ] , additionalNodalVariables = [ ] , additionalElementVariables = [ ] ) : # IDEA: It may make sense to make transfer_variables() strictly transfer # variables, and use add_variables() to add new variables.  Alternatively, # add_variables() could be called within transfer_variables() to add # new variables to the exo_to database.  Either way, we should minimize # duplicate code if possible. debugPrint = False if not isinstance ( additionalGlobalVariables , list ) : raise Exception ( "ERROR: additionalGlobalVariables is not a list." ) if not isinstance ( additionalNodalVariables , list ) : raise Exception ( "ERROR: additionalNodalVariables is not a list." ) if not isinstance ( additionalElementVariables , list ) : raise Exception ( "ERROR: additionalElementVariables is not a list." ) if debugPrint : print ( "Transfer Info records" ) numInfoRecs = exoFrom . num_info_records ( ) if numInfoRecs > 0 : infoRecs = exoFrom . get_info_records ( ) exo_to . put_info_records ( infoRecs ) if debugPrint : print ( "Transfer time values" ) nSteps = exoFrom . num_times ( ) if nSteps == 0 : return exo_to timeVals = exoFrom . get_times ( ) for step in xrange ( nSteps ) : exo_to . put_time ( step + 1 , timeVals [ step ] ) if debugPrint : print ( "Add Global Variables" ) nNewGlobalVars = len ( additionalGlobalVariables ) nGlobalVars = exoFrom . get_global_variable_number ( ) + nNewGlobalVars defaultNewVarVals = [ ] for i in xrange ( nNewGlobalVars ) : defaultNewVarVals . append ( 0.0 ) if nGlobalVars > 0 : exo_to . set_global_variable_number ( nGlobalVars ) gVarNames = exoFrom . get_global_variable_names ( ) gVarNames . extend ( additionalGlobalVariables ) for nameIndex in xrange ( nGlobalVars ) : globalVarName = gVarNames [ nameIndex ] exo_to . put_global_variable_name ( globalVarName , nameIndex + 1 ) for step in xrange ( nSteps ) : gValues = exoFrom . get_all_global_variable_values ( step + 1 ) if array_type == 'numpy' : gValues = exo_to . np . append ( gValues , defaultNewVarVals ) else : gValues . extend ( defaultNewVarVals ) exo_to . put_all_global_variable_values ( step + 1 , gValues ) if debugPrint : print ( "Add Nodal Variables" ) nNewNodalVars = len ( additionalNodalVariables ) nOrigNodalVars = exoFrom . get_node_variable_number ( ) nNodalVars = nOrigNodalVars + nNewNodalVars if nNodalVars > 0 : exo_to . set_node_variable_number ( nNodalVars ) nVarNames = exoFrom . get_node_variable_names ( ) nVarNames . extend ( additionalNodalVariables ) for nameIndex in xrange ( nNodalVars ) : nodalVarName = nVarNames [ nameIndex ] exo_to . put_node_variable_name ( nodalVarName , nameIndex + 1 ) if nameIndex < nOrigNodalVars : for step in xrange ( nSteps ) : nValues = exoFrom . get_node_variable_values ( nodalVarName , step + 1 ) exo_to . put_node_variable_values ( nodalVarName , step + 1 , nValues ) if debugPrint : print ( "Construct Truth Table for additionalElementVariables" ) blkIds = exoFrom . get_elem_blk_ids ( ) numBlks = exoFrom . num_blks ( ) newElemVariableNames = [ ] newElemVariableBlocks = [ ] for item in additionalElementVariables : if isinstance ( item , tuple ) : newElemVariableNames . append ( item [ 0 ] ) inBlks = [ ] for blkId in item [ 1 ] : if blkId in blkIds : inBlks . append ( blkId ) newElemVariableBlocks . append ( inBlks ) elif isinstance ( item , str ) : newElemVariableNames . append ( item ) newElemVariableBlocks . append ( blkIds ) else : print ( "Warning additionalElementVariable item " , item , " is not right type to add." ) print ( "should be a string or tuple, skipping" ) if debugPrint : print ( "Add Element Variables" ) nNewElemVars = len ( newElemVariableNames ) nOrigElemVars = exoFrom . get_element_variable_number ( ) nElemVars = nOrigElemVars + nNewElemVars if nElemVars > 0 : exo_to . set_element_variable_number ( nElemVars ) origElemVarNames = exoFrom . get_element_variable_names ( ) eVarNames = exoFrom . get_element_variable_names ( ) eVarNames . extend ( newElemVariableNames ) truthTable = [ ] if nOrigElemVars > 0 : truthTable = exoFrom . get_element_variable_truth_table ( ) if nNewElemVars > 0 : newTruth = [ ] for j in xrange ( numBlks ) : for k in xrange ( nOrigElemVars ) : index = j * nOrigElemVars + k newTruth . append ( truthTable [ index ] ) for m in xrange ( nNewElemVars ) : if blkIds [ j ] in newElemVariableBlocks [ m ] : newTruth . append ( True ) else : newTruth . append ( False ) truthTable = newTruth exo_to . set_element_variable_truth_table ( truthTable ) for nameIndex in xrange ( nElemVars ) : elemVarName = eVarNames [ nameIndex ] exo_to . put_element_variable_name ( elemVarName , nameIndex + 1 ) truthIndex = 0 for blkId in blkIds : for eVarName in origElemVarNames : if truthTable [ truthIndex ] : for step in xrange ( nSteps ) : eValues = exoFrom . get_element_variable_values ( blkId , eVarName , step + 1 ) exo_to . put_element_variable_values ( blkId , eVarName , step + 1 , eValues ) truthIndex = truthIndex + 1 truthIndex = truthIndex + nNewElemVars # TODO: Transfer Nodeset Variables # TODO: Transfer Sideset Variables return exo_to