def test_single_hex_cell_2(self): normals = [ np.array([1.2, .8, 0.]), np.array([1.2, .2, 1.3]), -np.array([1.2, .8, 0.]), -np.array([1.2, .2, 1.3]), ] for normal in normals: single_cell = hexmesh.HexMesh() single_cell.build_mesh(1, 1, 1, 1., 1., 1., lambda x, i, j, k: np.eye(3)) single_cell.divide_cell_by_plane(0, np.array([.5, .5, .5]), normal) assert (single_cell.get_number_of_cells() == 2)
def test_single_hex_cell_3(self): normals = [ np.array([1.2, .8, 0.]), np.array([1.2, .2, 1.3]), -np.array([1.2, .8, 0.]), -np.array([1.2, .2, 1.3]), ] for normal in normals: single_cell = hexmesh.HexMesh() single_cell.build_mesh(3, 3, 3, 1., 1., 1., lambda x, i, j, k: np.eye(3)) cell_index = single_cell.find_cell_near_point( np.array([.5, .5, .5])) single_cell.divide_cell_by_plane(cell_index, np.array([.5, .5, .5]), normal) assert (single_cell.get_number_of_cells() == 28)
def test_single_hex_cell_1(self): normals = [ np.array([1., 0., 0.]), np.array([0., 1., 0.]), np.array([0., 0., 1.]), -np.array([1., 0., 0.]), -np.array([0., 1., 0.]), -np.array([0., 0., 1.]), ] for normal in normals: single_cell = hexmesh.HexMesh() single_cell.build_mesh(1, 1, 1, 1., 1., 1., lambda x, i, j, k: np.eye(3)) single_cell.divide_cell_by_plane(0, np.array([.5, .5, .5]), normal) assert (single_cell.get_number_of_cells() == 2) assert (abs(single_cell.get_cell_volume(0) - .5) < 1.e-12) assert (abs(single_cell.get_cell_volume(1) - .5) < 1.e-12)
def test_write_single(self): two_cells = hexmesh.HexMesh() two_cells.build_mesh(2, 2, 2, 1., 1., 1., lambda x, i, j, k: np.eye(3)) two_cells.build_frac_from_faces([5]) output_file = open("test_output", 'wb') two_cells.save_mesh(output_file) output_file.close() input_file = open("test_output") loaded_mesh = mesh.Mesh() loaded_mesh.load_mesh(input_file) assert(two_cells.get_number_of_faces() == loaded_mesh.get_number_of_faces()) assert(two_cells.get_number_of_cells() == loaded_mesh.get_number_of_cells())
""" Two Phase Buckely-Leverett problem. """ import mimpy.mesh.hexmesh as hexmesh import mimpy.models.twophase as twophase import numpy as np mesh = hexmesh.HexMesh() def res_k(point, i, j, k): return 1.e-12 * np.eye(3) * 1.e-3 mesh.build_mesh(300, 1, 1, 80., 1., 1., res_k) res_twophase = twophase.TwoPhase() res_twophase.set_mesh(mesh) res_twophase.apply_flux_boundary_from_function( 0, lambda p: np.array([0., 0., 0.])) res_twophase.apply_pressure_boundary_from_function(1, lambda p: 0.) res_twophase.apply_flux_boundary_from_function( 2, lambda p: np.array([0., 0., 0.])) res_twophase.apply_flux_boundary_from_function( 3, lambda p: np.array([0., 0., 0.])) res_twophase.apply_flux_boundary_from_function( 4, lambda p: np.array([0., 0., 0.])) res_twophase.apply_flux_boundary_from_function( 5, lambda p: np.array([0., 0., 0.]))