def test_square(): square = Square('square') assert (square.dim == 2) assert (len(square.boundary) == 4) square.export('square.h5') # read it again D = Domain.from_file('square.h5')
def test_unit_square(): # Create 2D square domain [0, 1]^2 domain = Square('square') assert isinstance(domain, Square) # BasicDomain's attributes assert domain.dim == 2 assert domain.name == 'square' assert domain.coordinates == (x1, x2) # Domain's attributes assert isinstance(domain.interior, InteriorDomain) assert isinstance(domain.interior.target, ProductDomain) assert all(isinstance(i, Interval) for i in domain.interior.target.domains) assert len(domain.interior.target.domains) == 2 assert len(domain.boundary) == 4 assert domain.dtype == { 'type': 'Square', 'parameters': { 'bounds1': [0, 1], 'bounds2': [0, 1] } } # NCube's attributes assert domain.min_coords == (0, 0) assert domain.max_coords == (1, 1) # Square's attributes assert domain.bounds1 == (0, 1) assert domain.bounds2 == (0, 1) # Export to file, read it again and compare with original domain domain.export('domain.h5') D = Domain.from_file('domain.h5') assert D.logical_domain == domain
def test_rectangle(): # Create 2D rectangular domain [1, 5] X [3, 7] domain = Square('rectangle', bounds1=(1, 5), bounds2=(3, 7)) assert isinstance(domain, Square) # BasicDomain's attributes assert domain.dim == 2 assert domain.name == 'rectangle' assert domain.coordinates == (x1, x2) # Domain's attributes assert isinstance(domain.interior, InteriorDomain) assert isinstance(domain.interior.target, ProductDomain) assert all(isinstance(i, Interval) for i in domain.interior.target.domains) assert len(domain.interior.target.domains) == 2 assert len(domain.boundary) == 4 assert domain.dtype == { 'type': 'Square', 'parameters': { 'bounds1': [1, 5], 'bounds2': [3, 7] } } # NCube's attributes assert domain.min_coords == (1, 3) assert domain.max_coords == (5, 7) # Square's attributes assert domain.bounds1 == (1, 5) assert domain.bounds2 == (3, 7) # Export to file, read it again and compare with original domain domain.export('domain.h5') D = Domain.from_file('domain.h5') assert D.logical_domain == domain