#!/usr/bin/env python """Test a run of the sequential shallow water domain against a run of the parallel shallow water domain. WARNING: This assumes that the command to run jobs is mpirun. Tested with MPICH and LAM (Ole) """ #------------------------------------------------------------------------------ # Import necessary modules #------------------------------------------------------------------------------ import unittest import os import sys import pypar from Numeric import allclose, array, zeros, Float, take, nonzero from anuga.pmesh.mesh_interface import create_mesh_from_regions from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular_cross from anuga.abstract_2d_finite_volumes.pmesh2domain import pmesh_to_domain_instance from anuga.utilities.numerical_tools import ensure_numeric from anuga.utilities.util_ext import double_precision from anuga.utilities.norms import l1_norm, l2_norm, linf_norm from anuga.shallow_water import Domain from anuga.shallow_water import Reflective_boundary from anuga.shallow_water import Dirichlet_boundary from anuga.shallow_water import Time_boundary from anuga.shallow_water import Transmissive_boundary from anuga_parallel.parallel_api import distribute, myid, numprocs #-------------------------------------------------------------------------- # Setup parameters #-------------------------------------------------------------------------- mesh_filename = "merimbula_10785_1.tsh" #mesh_filename = "test-100.tsh" yieldstep = 1 finaltime = 20 quantity = 'stage' nprocs = 4 #-------------------------------------------------------------------------- # Setup procedures #-------------------------------------------------------------------------- class Set_Stage: """Set an initial condition with constant water height, for xself.x0)&(x 0: # Verify that the quantity is being conserved across iterations. assert_(abs(l1norm_seq[x][y] - l1norm_seq[x-1][y]) < tol) assert_(abs(l2norm_seq[x][y] - l2norm_seq[x-1][y]) < tol) assert_(abs(linfnorm_seq[x][y] - linfnorm_seq[x-1][y]) < tol) assert_(abs(l1norm_par[x][y] - l1norm_par[x-1][y]) < tol) assert_(abs(l2norm_par[x][y] - l2norm_par[x-1][y]) < tol) assert_(abs(linfnorm_par[x][y] - linfnorm_par[x-1][y]) < tol) if myid == 0: print 'Parallel test OK'