surface_fractal_terrain::surface_fractal_terrain(double sidelen, int size, double hscale, double h, int seed) { rand_generator.seed(seed); if ((size & (size - 1)) != 0) { throw_exception("size should be the power of 2."); } std::vector<std::vector<double> > height; generate_heightmap(height, size, hscale, h); generate_mesh(height, size, sidelen); }
int main(int argc, char **argv) { double t_start, t_end; int *ptr_gen_array, elem_per_node; float *local_array; int i, num_procs, local_rank, name_len; char proc_name[MPI_MAX_PROCESSOR_NAME]; MPI_Comm comm_new; gen_time = 0.0; proc_time = 0.0; comm_time = 0.0; total_time = 0.0; // Parse the arguments if( parse_arguments(argc, argv) ) return 1; // Initialize MPI MPI_Init(&argc, &argv); MPI_Get_processor_name(proc_name, &name_len); // Initially create the topology if( type == ring ) { create_ring_topology(&comm_new, &local_rank, &num_procs); } else { create_2dmesh_topology(&comm_new, &local_rank, &num_procs); } t_start = MPI_Wtime(); if( type == ring ) { local_array = generate_2d(&comm_new, local_rank, num_procs, proc_name, &elem_per_node); } else { local_array = generate_mesh(&comm_new, local_rank, num_procs, proc_name, &elem_per_node); } if( type == ring ) { one_d_partitioning(&comm_new, local_array, local_rank, num_procs); } else { two_d_partitioning(&comm_new, local_array, local_rank, num_procs); } t_end = MPI_Wtime(); total_time = t_end - t_start; if( computerStats ) { printf("%d\tg\t%s\t%d\t%f\n", n, s_local_coords, num_procs, gen_time); printf("%d\tp\t%s\t%d\t%f\n", n, s_local_coords, num_procs, proc_time); printf("%d\tc\t%s\t%d\t%f\n", n, s_local_coords, num_procs, comm_time); printf("%d\tt\t%s\t%d\t%f\n", n, s_local_coords, num_procs, total_time); } free(local_array); MPI_Comm_free(&comm_new); MPI_Finalize(); // Exit MPI return 0; }
void HexFixture::generate_mesh(const CoordinateMapping & coordMap) { std::vector<EntityId> element_ids_on_this_processor; const size_t p_size = m_bulk_data.parallel_size(); const size_t p_rank = m_bulk_data.parallel_rank(); const size_t num_elems = m_nx * m_ny * m_nz ; m_nodes_to_procs.clear(); for (int rank = 0; rank < static_cast<int>(p_size); ++rank) { fill_node_map(rank); } const EntityId beg_elem = 1 + ( num_elems * p_rank ) / p_size ; const EntityId end_elem = 1 + ( num_elems * ( p_rank + 1 ) ) / p_size ; for ( EntityId i = beg_elem; i != end_elem; ++i) { element_ids_on_this_processor.push_back(i); } generate_mesh(element_ids_on_this_processor, coordMap); }