Br = Reflective_boundary(domain)  # Solid reflective wall

domain.set_boundary({
    'outflow': Br,
    'inflow': Br,
    'inner': Br,
    'exterior': Br,
    'open': Br
})

#------------------------------------------------------------------------------
# Evolution
#------------------------------------------------------------------------------
if myid == 0 and verbose: print 'EVOLVE'

barrier()
t0 = time.time()
for t in domain.evolve(yieldstep=yieldstep, finaltime=finaltime):
    if myid == 0:
        domain.write_time()

barrier()

for p in range(numprocs):
    if myid == p:
        print 'Processor %g ' % myid
        print 'That took %.2f seconds' % (time.time() - t0)
        print 'Communication time %.2f seconds' % domain.communication_time
        print 'Reduction Communication time %.2f seconds' % domain.communication_reduce_time
        print 'Broadcast time %.2f seconds' % domain.communication_broadcast_time
    else:
                                      len2=width)

    domain.set_quantity('elevation', -1.0)
    domain.set_quantity('stage', Set_Stage(h=2.0))
else:
    domain = None

#--------------------------------------------------------------------------
# Distribute sequential domain on processor 0 to other processors
#--------------------------------------------------------------------------

if myid == 0 and verbose: print 'DISTRIBUTING DOMAIN'
domain = distribute(domain)

#domain.smooth = False
barrier()
for p in range(numprocs):
    if myid == p:
        print 'Process ID %g' % myid
        print 'Number of triangles %g ' % domain.get_number_of_triangles()
        sys.stdout.flush()

    barrier()

domain.set_flow_algorithm(2.0)

if myid == 0:
    domain.print_algorithm_parameters()
    sys.stdout.flush()

barrier()
#--------------------------------------------------------------------------
if myid == 0:
    domain = create_domain_from_file(mesh_filename)
    domain.set_quantity('stage', Set_Stage(x0, x1, 2.0))
else:
    domain = None

#--------------------------------------------------------------------------
# Distribute sequential domain on processor 0 to other processors
#--------------------------------------------------------------------------

if myid == 0 and verbose: print 'DISTRIBUTING DOMAIN'
domain = distribute(domain)

#domain.smooth = False
barrier()
for p in range(numprocs):
    if myid == p:
        print 'Process ID %g' %myid
        print 'Number of triangles %g ' %domain.get_number_of_triangles()

    barrier()


domain.set_flow_algorithm(2.0)

if myid == 0:
    domain.print_algorithm_parameters()

barrier()
    domain.set_quantity("elevation", -1.0)
    domain.set_quantity("stage", Set_Stage(h=2.0))
else:
    domain = None

# --------------------------------------------------------------------------
# Distribute sequential domain on processor 0 to other processors
# --------------------------------------------------------------------------

if myid == 0 and verbose:
    print "DISTRIBUTING DOMAIN"
domain = distribute(domain)

# domain.smooth = False
barrier()
for p in range(numprocs):
    if myid == p:
        print "Process ID %g" % myid
        print "Number of triangles %g " % domain.get_number_of_triangles()
        sys.stdout.flush()

    barrier()


domain.set_flow_algorithm(2.0)

if myid == 0:
    domain.print_algorithm_parameters()
    sys.stdout.flush()