#!/usr/bin/env python import unittest from math import sqrt, pi from flow_1d.generic_1d.generic_domain import * import numpy class Test_Generic_Domain(unittest.TestCase): def setUp(self): self.points = [0.0, 1.0, 2.0, 3.0] self.vertex_values = [[1.0,2.0],[4.0,5.0],[-1.0,2.0]] self.points2 = [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0] def tearDown(self): pass #print " Tearing down" def test_creation(self): domain = Generic_domain(self.points) assert numpy.allclose(domain.neighbours, \ [[-1 , 1],[ 0 , 2],[ 1 ,-1]]) assert numpy.allclose(domain.neighbour_vertices, \ [[-1 , 0],[ 1 , 0],[ 1 ,-1]]) assert numpy.allclose(domain.number_of_boundaries, \ [1, 0, 1]) assert numpy.allclose(domain.surrogate_neighbours, \ [[0, 1],[0, 2],[1, 2]]) assert numpy.allclose(domain.vertices, \ [[ 0., 1.],[ 1., 2.],[ 2., 3.]]) assert numpy.allclose(domain.centroids, [0.5, 1.5, 2.5]) assert numpy.allclose(domain.areas, [ 1., 1., 1.]) assert numpy.allclose(domain.normals, \ [[-1., 1.],[-1., 1.],[-1., 1.]]) #------------------------------------------------------------- if __name__ == "__main__": suite = unittest.makeSuite(Test_Generic_Domain, 'test') #suite = unittest.makeSuite(Test_Shallow_Water, 'test_evolve_first_order') runner = unittest.TextTestRunner() runner.run(suite)