Ejemplo n.º 1
0
 def test_build_file_path(self, get_test_data):
     for key in get_test_data.paths.keys():
         case = FOAMCase(get_test_data.paths[key])
         file_paths_test = get_test_data.file_paths[key]
         file_paths = [
             case.build_file_path("U", time, 0)
             for time in get_test_data.times[key]
         ]
Ejemplo n.º 2
0
 def test_parse_faces(self, get_test_data):
     for key in get_test_data.paths.keys():
         case = FOAMCase(get_test_data.paths[key])
         mesh = FOAMMesh(case)
         mesh_path = get_test_data.mesh_paths[key]
         n_points_faces, faces = mesh._parse_faces(case._path + mesh_path)
         n_faces = get_test_data.n_faces[key]
         first_face = get_test_data.first_faces[key]
         assert faces.size()[0] == n_faces
         assert pt.sum(n_points_faces - 4).item() == 0
         assert pt.sum(faces[0] - first_face).item() == 0
Ejemplo n.º 3
0
 def test_parse_points(self, get_test_data):
     for key in get_test_data.paths.keys():
         case = FOAMCase(get_test_data.paths[key])
         mesh = FOAMMesh(case)
         mesh_path = get_test_data.mesh_paths[key]
         points = mesh._parse_points(case._path + mesh_path)
         assert pt.sum(
             pt.abs(
                 points[0, :] - pt.Tensor([0, 0, 0])
             )
         ).item() < FLOAT_TOLERANCE
         n_points = get_test_data.n_points[key]
         assert points.size()[0] == n_points
Ejemplo n.º 4
0
 def test_get_cell_centers(self, get_test_data):
     for key in get_test_data.paths.keys():
         case = FOAMCase(get_test_data.paths[key])
         mesh = FOAMMesh(case)
         centers = mesh.get_cell_centers()
         volumes = mesh.get_cell_volumes()
         assert centers.size()[0] == get_test_data.n_cells
         assert volumes.size()[0] == get_test_data.n_cells
         assert pt.sum(
             centers[0] - get_test_data.first_center
         ).item() < FLOAT_TOLERANCE
         assert pt.sum(
             volumes - get_test_data.cell_volume
         ).item() < FLOAT_TOLERANCE
Ejemplo n.º 5
0
 def test_compute_cell_centers_and_volumes(self, get_test_data):
     for key in get_test_data.paths.keys():
         case = FOAMCase(get_test_data.paths[key])
         mesh = FOAMMesh(case)
         mesh_path = get_test_data.mesh_paths[key]
         centers, volumes = mesh._compute_cell_centers_and_volumes(
             case._path + mesh_path)
         assert centers.size()[0] == get_test_data.n_centers_volumes[key]
         assert volumes.size()[0] == get_test_data.n_centers_volumes[key]
         assert pt.sum(
             centers[0] - get_test_data.first_center
         ).item() < FLOAT_TOLERANCE
         assert pt.sum(
             volumes - get_test_data.cell_volume
         ).item() < FLOAT_TOLERANCE
Ejemplo n.º 6
0
 def test_parse_faces_cylinder(self):
     n_faces = 55059
     first_face =  pt.tensor([1, 2, 14027, 14026], dtype=pt.int32)
     mesh_path = "/constant/polyMesh/"
     paths = [
         "test/test_data/run/of_cylinder2D_ascii/",
         "test/test_data/run/of_cylinder2D_binary/"
     ]
     for path in paths:
         case = FOAMCase(path)
         mesh = FOAMMesh(case)
         n_points_faces, faces = mesh._parse_faces(case._path + mesh_path)
         assert faces.size()[0] == n_faces
         assert pt.sum(n_points_faces[:10, 0] - 4).item() == 0
         assert pt.sum(faces[0, :n_points_faces[0, 0]] - first_face).item() == 0
Ejemplo n.º 7
0
 def test_parse_owners_and_neighbors(self, get_test_data):
     for key in get_test_data.paths.keys():
         case = FOAMCase(get_test_data.paths[key])
         mesh = FOAMMesh(case)
         mesh_path = get_test_data.mesh_paths[key]
         owners, neighbors = mesh._parse_owners_and_neighbors(
             case._path + mesh_path)
         n_owners = get_test_data.n_faces[key]
         n_neighbors = get_test_data.n_neighbors[key]
         first_owners = get_test_data.first_n_owners[key]
         first_neighbors = get_test_data.first_n_neighbors[key]
         assert owners.size()[0] == n_owners
         assert neighbors.size()[0] == n_neighbors
         assert pt.sum(
             owners[:len(first_owners)] - first_owners
         ).item() == 0
         assert pt.sum(
             neighbors[:len(first_neighbors)] - first_neighbors
         ).item() == 0
Ejemplo n.º 8
0
 def test_check_files(self, get_test_data):
     for key in get_test_data.paths.keys():
         case = FOAMCase(get_test_data.paths[key])
         assert case._check_mesh_files() is True
Ejemplo n.º 9
0
 def test_field_names(self, get_test_data):
     for key in get_test_data.paths.keys():
         case = FOAMCase(get_test_data.paths[key])
         field_names = get_test_data.field_names[key]
         assert sorted(field_names) == sorted(case._field_names)
Ejemplo n.º 10
0
 def test_write_times(self, get_test_data):
     for key in get_test_data.paths.keys():
         case = FOAMCase(get_test_data.paths[key])
         write_times = get_test_data.times[key]
         assert write_times == case._time_folders
Ejemplo n.º 11
0
 def test_processors(self, get_test_data):
     for key in get_test_data.paths.keys():
         case = FOAMCase(get_test_data.paths[key])
         assert get_test_data.processors[key] == case._processors
Ejemplo n.º 12
0
 def test_distributed(self, get_test_data):
     for key in get_test_data.distributed.keys():
         case = FOAMCase(get_test_data.paths[key])
         distributed = get_test_data.distributed[key]
         assert distributed == case._distributed