Changeset 3243


Ignore:
Timestamp:
Jun 27, 2006, 12:13:45 PM (18 years ago)
Author:
jack
Message:

Fixed unit teset.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inundation/parallel/test_parallel_sw.py

    r3200 r3243  
    206206            assert_(len(l2norm_seq) == len(linfnorm_seq))
    207207            # Anything smaller than tol we consider to be 0.
    208             tol = pow(10, -1 * double_precision())
     208            # This usualy comes out to be 10^-14 (DBL_DIG = 10^-15)
     209            # * 10 to cater for rounding error in computation.
     210            tol = pow(10, -1 * (double_precision() - 1))
    209211            for x in range(len(l1norm_seq)):
    210212                for y in range(3):
    211                     assert_(abs(((l1norm_seq[x][y] - l1norm_par[x][y]) < tol)))
    212                     assert_(abs(((l2norm_seq[x][y] - l2norm_par[x][y]) < tol)))
    213                     assert_(abs(((linfnorm_seq[x][y] - linfnorm_par[x][y]) < tol)))
     213                    # Calculate relative difference in the norms
     214                    assert_(abs(l1norm_seq[x][y] - l1norm_par[x][y])/l1norm_seq[x][y] < tol)
     215                    assert_(abs(l2norm_seq[x][y] - l2norm_par[x][y])/l2norm_seq[x][y] < tol)
     216                    assert_(abs(linfnorm_seq[x][y] - linfnorm_par[x][y])/linfnorm_seq[x][y] < tol)
    214217                    if x > 0:
    215                         assert_(abs(((l1norm_seq[x][y] - l1norm_seq[x-1][y]) < tol)))
    216                         assert_(abs(((l2norm_seq[x][y] - l2norm_seq[x-1][y]) < tol)))
    217                         assert_(abs(((linfnorm_seq[x][y] - linfnorm_seq[x-1][y]) < tol)))
    218                         assert_(abs(((l1norm_par[x][y] - l1norm_par[x-1][y]) < tol)))
    219                         assert_(abs(((l2norm_par[x][y] - l2norm_par[x-1][y]) < tol)))
    220                         assert_(abs(((linfnorm_par[x][y] - linfnorm_par[x-1][y]) < tol)))
     218                        # Verify that the quantity is being conserved across iterations.
     219                        assert_(abs(l1norm_seq[x][y] - l1norm_seq[x-1][y]) < tol)
     220                        assert_(abs(l2norm_seq[x][y] - l2norm_seq[x-1][y]) < tol)
     221                        assert_(abs(linfnorm_seq[x][y] - linfnorm_seq[x-1][y]) < tol)
     222                        assert_(abs(l1norm_par[x][y] - l1norm_par[x-1][y]) < tol)
     223                        assert_(abs(l2norm_par[x][y] - l2norm_par[x-1][y]) < tol)
     224                        assert_(abs(linfnorm_par[x][y] - linfnorm_par[x-1][y]) < tol)
    221225        pypar.finalize()
    222226
Note: See TracChangeset for help on using the changeset viewer.