int main(int argc, char* argv[]) { polymec_init(argc, argv); const struct CMUnitTest tests[] = { cmocka_unit_test(test_int_unordered_set) }; return cmocka_run_group_tests(tests, NULL, NULL); }
int main(int argc, char* argv[]) { polymec_init(argc, argv); const struct CMUnitTest tests[] = { cmocka_unit_test(test_repartition_linear_cloud) }; return cmocka_run_group_tests(tests, NULL, NULL); }
int main(int argc, char* argv[]) { polymec_init(argc, argv); const struct CMUnitTest tests[] = { cmocka_unit_test(test_ctor), cmocka_unit_test(test_fill_ghosts) }; return cmocka_run_group_tests(tests, NULL, NULL); }
int main(int argc, char* argv[]) { polymec_init(argc, argv); const struct CMUnitTest tests[] = { cmocka_unit_test(test_symplectic_central_force), cmocka_unit_test(test_stiffly_accurate_kinetics) }; return cmocka_run_group_tests(tests, NULL, NULL); }
int main(int argc, char* argv[]) { polymec_init(argc, argv); const struct CMUnitTest tests[] = { cmocka_unit_test(test_create_cubed_cylinder_mesh), cmocka_unit_test(test_create_circular_cubed_cylinder_mesh), cmocka_unit_test(test_create_cubed_cylindrical_shell_mesh) }; return cmocka_run_group_tests(tests, NULL, NULL); }
int main(int argc, char* argv[]) { polymec_init(argc, argv); const struct CMUnitTest tests[] = { cmocka_unit_test(test_constructor), cmocka_unit_test(test_distributed_constructor), cmocka_unit_test(test_sort) }; return cmocka_run_group_tests(tests, NULL, NULL); }
int main(int argc, char* argv[]) { polymec_init(argc, argv); const struct CMUnitTest tests[] = { cmocka_unit_test(test_partition_small_linear_cloud), cmocka_unit_test(test_partition_large_linear_cloud), cmocka_unit_test(test_partition_small_planar_cloud), cmocka_unit_test(test_partition_large_planar_cloud), cmocka_unit_test(test_partition_small_cubic_cloud), cmocka_unit_test(test_partition_large_cubic_cloud) }; return cmocka_run_group_tests(tests, NULL, NULL); }
int main(int argc, char* argv[]) { polymec_init(argc, argv); set_log_level(LOG_DEBUG); const struct CMUnitTest tests[] = { cmocka_unit_test(test_exodus_file_query), cmocka_unit_test(test_write_exodus_file), cmocka_unit_test(test_read_exodus_file), cmocka_unit_test(test_read_poly_exodus_file), cmocka_unit_test(test_write_poly_exodus_file) }; return cmocka_run_group_tests(tests, NULL, NULL); }
int main(int argc, char* argv[]) { polymec_init(argc, argv); const struct CMUnitTest tests[] = { cmocka_unit_test(test_brent), cmocka_unit_test(test_newton_solve_system_1), cmocka_unit_test(test_newton_solve_system_1_with_jacobian), cmocka_unit_test(test_newton_solve_system_2), cmocka_unit_test(test_newton_solve_system_2_with_jacobian), cmocka_unit_test(test_newton_solve_system_3), cmocka_unit_test(test_newton_solve_system_3_with_jacobian) }; return cmocka_run_group_tests(tests, NULL, NULL); }
int main(int argc, char* argv[]) { polymec_init(argc, argv); const struct CMUnitTest tests[] = { cmocka_unit_test(test_petsc_krylov_factory), cmocka_unit_test(test_petsc_krylov_matrix), cmocka_unit_test(test_petsc_krylov_vector), cmocka_unit_test(test_petsc_laplace_eqn), cmocka_unit_test(test_hypre_krylov_factory), cmocka_unit_test(test_hypre_krylov_matrix), cmocka_unit_test(test_hypre_krylov_vector), cmocka_unit_test(test_hypre_laplace_eqn) }; return cmocka_run_group_tests(tests, NULL, NULL); }
int main(int argc, char* argv[]) { polymec_init(argc, argv); const struct CMUnitTest tests[] = { cmocka_unit_test(test_repartition_4x1x1_uniform_mesh), cmocka_unit_test(test_repartition_2x2x1_uniform_mesh), cmocka_unit_test(test_repartition_4x4x1_uniform_mesh), cmocka_unit_test(test_repartition_2x2x2_uniform_mesh), cmocka_unit_test(test_repartition_4x4x4_uniform_mesh), cmocka_unit_test(test_repartition_128x1x1_uniform_mesh), cmocka_unit_test(test_repartition_128x128x1_uniform_mesh), cmocka_unit_test(test_repartition_32x32x32_uniform_mesh) }; return cmocka_run_group_tests(tests, NULL, NULL); }
void test_plot(void** state) { // Create a text file containing an Octave script that can be run to // visualize this plot. point_t origin = {0.0, 0.0, 0.0}; sp_func_t* s = sphere_new(&origin, 0.5, OUTWARD_NORMAL); bbox_t bbox = {.x1 = -1.0, .x2 = 1.0, .y1 = -1.0, .y2 = 1.0, .z1 = -1.0, .z2 = 1.0}; generate_octave_script_for_surface(s, 20, &bbox, "test_sphere.m"); } int main(int argc, char* argv[]) { polymec_init(argc, argv); const struct CMUnitTest tests[] = { cmocka_unit_test(test_construct), cmocka_unit_test(test_plot) }; return cmocka_run_group_tests(tests, NULL, NULL); }
int main(int argc, char* argv[]) { polymec_init(argc, argv); const struct CMUnitTest tests[] = { cmocka_unit_test(test_int_array2), cmocka_unit_test(test_int_array3), cmocka_unit_test(test_int_array4), cmocka_unit_test(test_int_array5), cmocka_unit_test(test_int_array6), cmocka_unit_test(test_int_array7), cmocka_unit_test(test_real_array2), cmocka_unit_test(test_real_array3), cmocka_unit_test(test_real_array4), cmocka_unit_test(test_real_array5), cmocka_unit_test(test_real_array6), cmocka_unit_test(test_real_array7) }; return cmocka_run_group_tests(tests, NULL, NULL); }
void test_plot(void** state) { // Create a text file containing an Octave script that can be run to // visualize this plot. point_t x1 = {-0.5, 0.0, 0.0}, x2 = {0.5, 0.0, 0.0}; sp_func_t* s1 = sphere_new(&x1, 0.25, INWARD_NORMAL); sp_func_t* s2 = sphere_new(&x2, 0.25, INWARD_NORMAL); sp_func_t* u = union_new2(s1, s2); bbox_t bbox = {.x1 = -2.0, .x2 = 2.0, .y1 = -2.0, .y2 = 2.0, .z1 = -2.0, .z2 = 2.0}; generate_octave_script_for_surface(u, 40, &bbox, "test_union.m"); } int main(int argc, char* argv[]) { polymec_init(argc, argv); const struct CMUnitTest tests[] = { cmocka_unit_test(test_construct), cmocka_unit_test(test_plot) }; return cmocka_run_group_tests(tests, NULL, NULL); }
void test_partition_linear_mesh(void** state) { // Create a 100x1x1 uniform mesh. int nx = 100, ny = 1, nz = 1; real_t dx = 1.0/nx; bbox_t bbox = {.x1 = 0.0, .x2 = 1.0, .y1 = 0.0, .y2 = dx, .z1 = 0.0, .z2 = dx}; mesh_t* mesh = create_uniform_mesh(MPI_COMM_SELF, nx, ny, nz, &bbox); // Partition it. exchanger_t* distributor = partition_mesh(&mesh, MPI_COMM_WORLD, NULL, 0.05); exchanger_verify(distributor, polymec_error); exchanger_free(distributor); // Check the ghost cells. int rank, nprocs; MPI_Comm_rank(mesh->comm, &rank); MPI_Comm_size(mesh->comm, &nprocs); if (nprocs > 1) { exchanger_t* ex = mesh_exchanger(mesh); int pos = 0, proc, *indices, num_indices; int num_sends = 0, num_receives = 0; while (exchanger_next_send(ex, &pos, &proc, &indices, &num_indices)) num_sends += num_indices; pos = 0; while (exchanger_next_receive(ex, &pos, &proc, &indices, &num_indices)) num_receives += num_indices; assert_true((mesh->num_ghost_cells == 1) || (mesh->num_ghost_cells == 2)); assert_true(num_sends == mesh->num_ghost_cells); assert_true(num_receives == mesh->num_ghost_cells); } else assert_int_equal(0, mesh->num_ghost_cells); // Check the geometry of the mesh. int cell_volumes_are_ok = 1; for (int c = 0; c < mesh->num_cells; ++c) { if (fabs(mesh->cell_volumes[c] - dx*dx*dx) > 1e-12) { cell_volumes_are_ok = 0; break; } } int face_areas_are_ok = 1; for (int f = 0; f < mesh->num_faces; ++f) { if (fabs(mesh->face_areas[f] - dx*dx) > 1e-12) { face_areas_are_ok = 0; break; } } MPI_Allreduce(&cell_volumes_are_ok, &cell_volumes_are_ok, 1, MPI_INT, MPI_MIN, MPI_COMM_WORLD); MPI_Allreduce(&face_areas_are_ok, &cell_volumes_are_ok, 1, MPI_INT, MPI_MIN, MPI_COMM_WORLD); assert_true(cell_volumes_are_ok); assert_true(face_areas_are_ok); // Check the resulting exchanger. exchanger_verify(mesh_exchanger(mesh), polymec_error); // Plot it. real_t p[mesh->num_cells]; for (int c = 0; c < mesh->num_cells; ++c) p[c] = 1.0*rank; silo_file_t* silo = silo_file_new(mesh->comm, "linear_mesh_partition", "linear_mesh_partition", 1, 0, 0, 0.0); silo_file_write_mesh(silo, "mesh", mesh); silo_field_metadata_t* p_metadata = silo_field_metadata_new(); silo_field_metadata_set_label(p_metadata, "P"); silo_field_metadata_set_conserved(p_metadata, false); silo_file_write_scalar_cell_field(silo, "rank", "mesh", p, p_metadata); silo_file_close(silo); // Clean up. mesh_free(mesh); // Superficially check that the file is okay. int num_files, num_procs; assert_true(silo_file_query("linear_mesh_partition", "linear_mesh_partition", &num_files, &num_procs, NULL)); assert_int_equal(1, num_files); assert_int_equal(nprocs, num_procs); } void test_partition_slab_mesh(void** state) { // Create a 50x50x1 uniform mesh. int nx = 50, ny = 50, nz = 1; real_t dx = 1.0/nx; bbox_t bbox = {.x1 = 0.0, .x2 = 1.0, .y1 = 0.0, .y2 = 1.0, .z1 = 0.0, .z2 = dx}; mesh_t* mesh = create_uniform_mesh(MPI_COMM_SELF, nx, ny, nz, &bbox); // Partition it. exchanger_t* distributor = partition_mesh(&mesh, MPI_COMM_WORLD, NULL, 0.05); exchanger_free(distributor); // Check the geometry of the mesh. int cell_volumes_are_ok = 1; for (int c = 0; c < mesh->num_cells; ++c) { if (fabs(mesh->cell_volumes[c] - dx*dx*dx) > 1e-12) { cell_volumes_are_ok = 0; break; } } int face_areas_are_ok = 1; for (int f = 0; f < mesh->num_faces; ++f) { if (fabs(mesh->face_areas[f] - dx*dx) > 1e-12) { face_areas_are_ok = 0; break; } } MPI_Allreduce(&cell_volumes_are_ok, &cell_volumes_are_ok, 1, MPI_INT, MPI_MIN, MPI_COMM_WORLD); MPI_Allreduce(&face_areas_are_ok, &cell_volumes_are_ok, 1, MPI_INT, MPI_MIN, MPI_COMM_WORLD); assert_true(cell_volumes_are_ok); assert_true(face_areas_are_ok); // Plot it. int nprocs, rank; MPI_Comm_size(mesh->comm, &nprocs); MPI_Comm_rank(mesh->comm, &rank); real_t p[mesh->num_cells]; for (int c = 0; c < mesh->num_cells; ++c) p[c] = 1.0*rank; silo_file_t* silo = silo_file_new(mesh->comm, "slab_mesh_partition", "slab_mesh_partition", 1, 0, 0, 0.0); silo_file_write_mesh(silo, "mesh", mesh); silo_file_write_scalar_cell_field(silo, "rank", "mesh", p, NULL); silo_file_close(silo); // Clean up. mesh_free(mesh); // Superficially check that the file is okay. int num_files, num_procs; assert_true(silo_file_query("slab_mesh_partition", "slab_mesh_partition", &num_files, &num_procs, NULL)); assert_int_equal(1, num_files); assert_int_equal(nprocs, num_procs); } void test_partition_box_mesh(void** state) { // Create a 20x20x20 uniform mesh. int nx = 20, ny = 20, nz = 20; bbox_t bbox = {.x1 = 0.0, .x2 = 1.0, .y1 = 0.0, .y2 = 1.0, .z1 = 0.0, .z2 = 1.0}; mesh_t* mesh = create_uniform_mesh(MPI_COMM_SELF, nx, ny, nz, &bbox); // Partition it. exchanger_t* distributor = partition_mesh(&mesh, MPI_COMM_WORLD, NULL, 0.05); exchanger_free(distributor); // Check the geometry of the mesh. real_t dx = 1.0/nx; int cell_volumes_are_ok = 1; for (int c = 0; c < mesh->num_cells; ++c) { if (fabs(mesh->cell_volumes[c] - dx*dx*dx) > 1e-12) { cell_volumes_are_ok = 0; break; } } int face_areas_are_ok = 1; for (int f = 0; f < mesh->num_faces; ++f) { if (fabs(mesh->face_areas[f] - dx*dx) > 1e-12) { face_areas_are_ok = 0; break; } } MPI_Allreduce(&cell_volumes_are_ok, &cell_volumes_are_ok, 1, MPI_INT, MPI_MIN, MPI_COMM_WORLD); MPI_Allreduce(&face_areas_are_ok, &cell_volumes_are_ok, 1, MPI_INT, MPI_MIN, MPI_COMM_WORLD); assert_true(cell_volumes_are_ok); assert_true(face_areas_are_ok); // Plot it. int nprocs, rank; MPI_Comm_size(mesh->comm, &nprocs); MPI_Comm_rank(mesh->comm, &rank); double p[mesh->num_cells]; for (int c = 0; c < mesh->num_cells; ++c) p[c] = 1.0*rank; silo_file_t* silo = silo_file_new(mesh->comm, "box_mesh_partition", "box_mesh_partition", 1, 0, 0, 0.0); silo_file_write_mesh(silo, "mesh", mesh); silo_file_write_scalar_cell_field(silo, "rank", "mesh", p, NULL); silo_file_close(silo); // Clean up. mesh_free(mesh); // Superficially check that the file is okay. int num_files, num_procs; assert_true(silo_file_query("box_mesh_partition", "box_mesh_partition", &num_files, &num_procs, NULL)); assert_int_equal(1, num_files); assert_int_equal(nprocs, num_procs); } int main(int argc, char* argv[]) { polymec_init(argc, argv); const struct CMUnitTest tests[] = { cmocka_unit_test(test_partition_linear_mesh), cmocka_unit_test(test_partition_slab_mesh), cmocka_unit_test(test_partition_box_mesh) }; return cmocka_run_group_tests(tests, NULL, NULL); }