Hello Regla,

Sometimes, I also do the similar procedure with what you intend to do. Especially if I want to check the simulation result by stopping the simulation process temporally. After I make sure that the result is good, I continue the simulation process.  

#1. If you are doing the simulation with parallel computing, you have to merge first all of the *.sww files part for each processor. You may use the function located in

anuga_core/source/anuga/utilities/sww_merge.py

This is because the merge function doesn't work if the computer is suddenly shut down.


#2. From the *.sww files you can dump all the latest simulation result which are stored as the 'quantity' object including the xmomentum, ymomentum, stage and elevation from each nodes of the mesh (in my case I prefer to dump those quantities as  .txt files). This procedure can be implemented like this.

.....
import numpy as np

f_mesh  = .... #your mesh file

mesh_instance = importMeshFromFile(f_mesh)
domain = pmesh_to_domain_instance(mesh_instance, Domain)



#Function for convert quantity value to node
def dump_value_from_netCDF_to_node_value_file(domain,name,vert):
    triang = domain.get_triangles()
    node_val = np.zeros((len(triang[:,1]),len(triang[1,:])))
    for k in xrange(len(triang[:,1])):
        for j in xrange(len(triang[1,:])):
           node_val[k,j]=vert[triang[k,j]]
    fo = name+'.txt'
    np.savetxt(fo,node_val,delimiter=' ')

#Taking data from netCDF
from anuga.utilities import plot_utils as util

sww_in = .... #your sww file
min_storable_height = 0.001

f_result = util.get_output(sww_in,min_storable_height)
topo = f_result.elev                  # elevation file
n_time = f_result.time.shape[0]       # total of time series

# Take the other quantities at the latest time from SWW file
ntime = ntime - 1
xmomentum = f_result.xmom[ntime]      # 'xmomentum' quantity
ymomentum = f_result.ymom[ntime]      # 'ymomentum' quantity
stage = f_result.stage[ntime]         # 'stage'     quantity


print 'Dumping xmomentum......'

fo_elev_name = 'last_elev'
fo_xmom_name = 'last_xmom'
fo_ymom_name = 'last_ymom'
fo_stage_name= 'last_stage'   


# Dump xmomentum
dump_value_from_netCDF_to_node_value_file(domain,name=fo_xmom_name,vert=xmomentum)

# Dump ymomentum
dump_value_from_netCDF_to_node_value_file(domain,name=fo_ymom_name,vert=ymomentum)

# Dump stage
dump_value_from_netCDF_to_node_value_file(domain,name=fo_stage_name,vert=stage)

# Dump elevation
dump_value_from_netCDF_to_node_value_file(domain,name=fo_elev_name,vert=topo)


#3. The last procedure is using the quantity previously dumped into text file as the initial condition for restarting your simulation process. Note that the mesh file must be same. This procedure can be easily implemented like this
.....
  import numpy as np
 
  #Read the previous data
  stage_last = np.loadtxt('last_stage.txt',delimiter=' ')
  xmom_last = np.loadtxt('last_xmom.txt', delimiter=' ')
  ymom_last = np.loadtxt('last_ymom.txt',delimiter=' ')

  elev_last = np.loadtxt('
last_elev.txt',delimiter=' ')
 
  inistage = stage_last
  xmom = xmom_last
  ymom = ymom_last
 
  # Store the latest quantity as the initial condition of the simulation
  domain.set_quantity('elevation',elev_last)
  domain.set_quantity('stage',inistage)
  domain.set_quantity('xmomentum',xmom)
  domain.set_quantity('ymomentum',ymom)      

.....

So based on my experience, the most important thing is we can take all the quantity stored at each node. Hopefully those procedures can solve your problem ;)



Fariza Dian Prasetyo
Phone: +62-817310788
e-mail: frzdian@gmail.com
 


2014-03-17 20:13 GMT+07:00 Regla <duthit@gmail.com>:
Hello dear all,

I left an Anuga experiment running into my lab during this weekend but there was a power problem.

Can you help me to restart form the last time step computed by the model?

What should I  do??

Thanks,
regla



--
Regla
...ser mãe é uma experiência maravilhosa...o amor é mais incondicional...
“O pessimista queixa-se do vento, o otimista espera que ele mude
e o realista ajusta as velas.”
...
WILLIAM GEORGE WARD, Teólogo inglês, 1812-1882.
"Dê a quem você ama : Asas para voar... Raízes para voltar... Motivos para ficar. "  (Dalai Lama)
“Se um dia tiver que escolher entre o mundo e o amor...
 Lembre-se: Se escolher o mundo ficará sem o amor;
mas se escolher o amor, com ele você conquistará o mundo.”
(Albert Einstein)

"A vida é uma peça de teatro que não permite ensaios... Por isso,
cante,ria, dance, chore e viva intensamente cada momento de sua vida,
antes que a cortina se feche e a peça termine sem aplausos..."* (Charles Chaplin.)
"Dubium sapientiae initium" (Rene Descartes)
_¸.·´(`_¸.·´(`_¸.·´(`_¸.·´(`_¸.·´(`_¸.·´(`_¸.·´(`_¸.·´(`_¸.·´(`_¸.·´(`_¸.·´(`_¸.·´(`_¸.·´(`



------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Anuga-user mailing list
Anuga-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/anuga-user