Changeset 8425


Ignore:
Timestamp:
May 8, 2012, 9:59:56 PM (13 years ago)
Author:
steve
Message:

Have a working test_parallel_frac_op unittest

Location:
trunk/anuga_core/source/anuga_parallel
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/anuga_core/source/anuga_parallel/parallel_boyd_box_operator.py

    r8420 r8425  
    9797    def parallel_safe(self):
    9898
    99         print "ZZZZ parallel_boyd"
    10099        return True
    101100
  • trunk/anuga_core/source/anuga_parallel/test_parallel_frac_op.py

    r8424 r8425  
    1515                           
    1616#from anuga.culvert_flows.culvert_routines import boyd_generalised_culvert_model
    17      
     17
     18
     19#------------------------------------------
     20# Import pypar without the initial output
     21#------------------------------------------
     22class NullStream:
     23    def write(self,text):
     24        pass
     25sys.stdout = NullStream()
     26import pypar
     27sys.stdout = sys.__stdout__
     28
     29
    1830from math import pi, pow, sqrt
    1931
     
    2436
    2537from parallel_operator_factory import Inlet_operator, Boyd_box_operator
    26 import pypar
     38
    2739import random
    2840import unittest
     
    3345This test exercises the parallel culvert and checks values
    3446"""
    35 verbose = True
    36 nprocs = 2
     47verbose = False
     48nprocs = 3
    3749   
    3850
     
    170182                                  verbose=False)
    171183       
    172     if inlet0 is not None: inlet0.print_statistics()
    173     if inlet1 is not None: inlet1.print_statistics()
    174     if boyd_box0 is not None: boyd_box0.print_statistics()
     184    if inlet0 is not None and verbose: inlet0.print_statistics()
     185    if inlet1 is not None and verbose: inlet1.print_statistics()
     186    if boyd_box0 is not None and verbose: boyd_box0.print_statistics()
    175187
    176188#    if parallel:
     
    210222    ##-----------------------------------------------------------------------
    211223
    212     for t in domain.evolve(yieldstep = 0.1, finaltime = 38):
    213         if myid == 0:
     224    for t in domain.evolve(yieldstep = 2.0, finaltime = 2.0):
     225        if myid == 0 and verbose:
    214226            domain.write_time()
    215227
     
    219231
    220232
    221         if boyd_box0 is not None: boyd_box0.print_timestepping_statistics()
     233        if boyd_box0 is not None and verbose : boyd_box0.print_timestepping_statistics()
    222234 
    223235        #for i in range(samples):
     
    282294
    283295
    284         #assert(success)
     296        assert(success)
    285297
    286298    return control_data
     
    290302# against the sequential code.
    291303
    292 class Test_parallel_shallow_domain(unittest.TestCase):
    293     def test_parallel_shallow_domain(self):
     304class Test_parallel_frac_op(unittest.TestCase):
     305    def test_parallel_frac_op(self):
    294306        #print "Expect this test to fail if not run from the parallel directory."
    295         result = os.system("mpirun -np %d python test_parallel_shallow_domain.py" % nprocs)
     307        result = os.system("mpirun -np %d python test_parallel_frac_op.py" % nprocs)
    296308        assert_(result == 0)
    297309
     
    307319    if numprocs == 1:
    308320        runner = unittest.TextTestRunner()
    309         suite = unittest.makeSuite(Test_parallel_shallow_domain, 'test')
     321        suite = unittest.makeSuite(Test_parallel_frac_op, 'test')
     322        #print "Running for numproc = 1"
    310323        runner.run(suite)
    311324    else:
    312 
     325        #print "Running for numproc > 1"
    313326        pypar.barrier()
    314327        test_points = []
     
    328341
    329342        if myid == 0:
    330             control_data = run_test(parallel=False, test_points = test_points, verbose = True)
     343            control_data = run_test(parallel=False, test_points = test_points, verbose = verbose)
    331344
    332345            for proc in range(1,numprocs):
     
    337350
    338351        pypar.barrier()
    339         run_test(parallel=True, control_data = control_data, test_points = test_points, verbose = True)
     352        run_test(parallel=True, control_data = control_data, test_points = test_points, verbose = verbose)
    340353
    341354
Note: See TracChangeset for help on using the changeset viewer.