/[escript]/branches/stage3.1/escript/py_src/util.py
ViewVC logotype

Diff of /branches/stage3.1/escript/py_src/util.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2944 by jfenwick, Thu Feb 4 01:42:47 2010 UTC revision 2945 by jfenwick, Wed Feb 24 00:17:46 2010 UTC
# Line 298  def saveESD(datasetName, dataDir=".", do Line 298  def saveESD(datasetName, dataDir=".", do
298      :keyword <name>: writes the assigned value to the file using <name> as      :keyword <name>: writes the assigned value to the file using <name> as
299                       identifier                       identifier
300      :type <name>: `Data` object      :type <name>: `Data` object
301      :note: The data objects have to be defined on the same domain. They may not      :note: The ESD concept is experimental and the file format likely to
302             be in the same `FunctionSpace` but one cannot expect that all             change so use this function with caution.
303             `FunctionSpace` s can be mixed. Typically, data on the boundary and      :note: The data objects have to be defined on the same domain (but not
304             data on the interior cannot be mixed.             necessarily on the same `FunctionSpace`).
305      :note: When saving a time series the first timestep must be 0 and it is      :note: When saving a time series the first timestep must be 0 and it is
306             assumed that data from all timesteps share the domain. The dataset             assumed that data from all timesteps share the domain. The dataset
307             file is updated in each iteration.             file is updated in each iteration.
# Line 324  def saveESD(datasetName, dataDir=".", do Line 324  def saveESD(datasetName, dataDir=".", do
324      if domain.onMasterProcessor() and not os.path.isdir(dataDir):      if domain.onMasterProcessor() and not os.path.isdir(dataDir):
325          os.mkdir(dataDir)          os.mkdir(dataDir)
326    
327      meshFile = os.path.join(dataDir, datasetName+"_mesh")      meshFile = datasetName+"_mesh"
328      fileNumber = timeStep / deltaT      fileNumber = timeStep / deltaT
329    
330      if dynamicMesh == 0:      if dynamicMesh == 0:
331          # later timesteps reuse mesh from t=0          # later timesteps reuse mesh from t=0
332          if timeStep == 0:          if timeStep == 0:
333              domain.dump(meshFile + ".nc")              domain.dump(os.path.join(dataDir, meshFile + ".nc"))
334      else:      else:
335          meshFile += ".%04d"          meshFile += ".%04d"
336          domain.dump((meshFile + ".nc") % fileNumber)          domain.dump(os.path.join(dataDir, (meshFile + ".nc") % fileNumber))
337    
338      outputString = ""      outputString = ""
339    
# Line 350  def saveESD(datasetName, dataDir=".", do Line 350  def saveESD(datasetName, dataDir=".", do
350    
351      # now add the variables      # now add the variables
352      for varName, d in new_data.items():      for varName, d in new_data.items():
353          varFile = os.path.join(dataDir, datasetName+"_"+varName+".%04d")          varFile = datasetName+"_"+varName+".%04d"
354          d.dump((varFile + ".nc") % fileNumber)          d.dump(os.path.join(dataDir, (varFile + ".nc") % fileNumber))
355          if domain.onMasterProcessor():          if domain.onMasterProcessor():
356              outputString += "V=%s:%s\n" % (varFile, varName)              outputString += "V=%s:%s\n" % (varFile, varName)
357    
358      if domain.onMasterProcessor():      if domain.onMasterProcessor():
359          esdfile = open(datasetName+".esd", "w")          esdfile = open(os.path.join(dataDir, datasetName+".esd"), "w")
360          esdfile.write(outputString)          esdfile.write(outputString)
361          esdfile.close()          esdfile.close()
362    

Legend:
Removed from v.2944  
changed lines
  Added in v.2945

  ViewVC Help
Powered by ViewVC 1.1.26