/[escript]/trunk/finley/test/python/convection.py
ViewVC logotype

Diff of /trunk/finley/test/python/convection.py

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

revision 1876 by gross, Fri Oct 3 03:57:52 2008 UTC revision 1877 by ksteube, Tue Oct 14 02:58:39 2008 UTC
# Line 27  from math import pi, ceil Line 27  from math import pi, ceil
27    
28    
29  def removeRestartDirectory(dir_name):  def removeRestartDirectory(dir_name):
30     if os.path.isdir(dir_name):     if dom.onMasterProcessor() and os.path.isdir(dir_name):
31         for root, dirs, files in os.walk(dir_name, topdown=False):         for root, dirs, files in os.walk(dir_name, topdown=False):
32             for name in files: os.remove(os.path.join(root,name))             for name in files: os.remove(os.path.join(root,name))
33             for name in dirs: os.remove(os.path.join(root,name))             for name in dirs: os.remove(os.path.join(root,name))
34         os.rmdir(dir_name)         os.rmdir(dir_name)
35         print "Restart files %s have been removed."%dir_name         print "Restart files %s have been removed."%dir_name
36       dom.MPIBarrier()
37    
38    
39  import sys  import sys
# Line 143  if restart: Line 144  if restart:
144     else:     else:
145        dt_a=None        dt_a=None
146        a=None        a=None
147     if dom.getMPIRank()==0: nusselt_file=open("nusselt.csv","a")     if dom.onMasterProcessor(): nusselt_file=open("nusselt.csv","a")
148  else:  else:
149    if DIM==2:    if DIM==2:
150      dom=Rectangle(int(ceil(L*NE/H)),NE,l0=L,l1=H,order=2, useFullElementOrder=True,optimize=True)      dom=Rectangle(int(ceil(L*NE/H)),NE,l0=L,l1=H,order=2, useFullElementOrder=True,optimize=True)
# Line 166  else: Line 167  else:
167    stress=Tensor(0,Function(dom))    stress=Tensor(0,Function(dom))
168    x2=ReducedSolution(dom).getX()    x2=ReducedSolution(dom).getX()
169    p=-RA*(x2[DIM-1]-0.5*x2[DIM-1]**2)    p=-RA*(x2[DIM-1]-0.5*x2[DIM-1]**2)
170    if dom.getMPIRank() ==0: nusselt_file=open("nusselt.csv","w")    if dom.onMasterProcessor(): nusselt_file=open("nusselt.csv","w")
171    t=0    t=0
172    t_out=0    t_out=0
173    n_out=0    n_out=0
# Line 231  while t<T_END: Line 232  while t<T_END:
232      se=sp.getMechanicalPower()      se=sp.getMechanicalPower()
233      print "Xse:",inf(se),sup(se)      print "Xse:",inf(se),sup(se)
234      Nu=1.+integrate(se)/(RA*vol)      Nu=1.+integrate(se)/(RA*vol)
235      if dom.getMPIRank() ==0: nusselt_file.write("%e %e\n"%(t,Nu))      if dom.onMasterProcessor(): nusselt_file.write("%e %e\n"%(t,Nu))
236      heat.setValue(v=interpolate(v,ReducedSolution(dom)),Q=DI/RA*se)      heat.setValue(v=interpolate(v,ReducedSolution(dom)),Q=DI/RA*se)
237      print "Xnusselt number = ",Nu, "dt =",dt      print "Xnusselt number = ",Nu, "dt =",dt
238      if n>0:      if n>0:
# Line 264  while t<T_END: Line 265  while t<T_END:
265           new_restart_dir="restart_%s_"%c           new_restart_dir="restart_%s_"%c
266    
267           print "Write restart files to ",new_restart_dir           print "Write restart files to ",new_restart_dir
268           if not os.path.isdir(new_restart_dir): os.mkdir(new_restart_dir)           if dom.onMasterProcessor() and not os.path.isdir(new_restart_dir): os.mkdir(new_restart_dir)
269         dom.MPIBarrier()
270           sp.getStress().dump(os.path.join(new_restart_dir,"stress.nc"))           sp.getStress().dump(os.path.join(new_restart_dir,"stress.nc"))
271           sp.getVelocity().dump(os.path.join(new_restart_dir,"v.nc"))           sp.getVelocity().dump(os.path.join(new_restart_dir,"v.nc"))
272           sp.getPressure().dump(os.path.join(new_restart_dir,"p.nc"))           sp.getPressure().dump(os.path.join(new_restart_dir,"p.nc"))

Legend:
Removed from v.1876  
changed lines
  Added in v.1877

  ViewVC Help
Powered by ViewVC 1.1.26