int main(int argc, char** args) { CTester c(argc, args); test_mesh(); test_eangles(); test_matrix(); }
static void test(buffer *buf) { const double *const x_base[D]=INITD(testx,testx+1,testx+2); const unsigned x_stride[D]= INITD(D*sizeof(double),D*sizeof(double),D*sizeof(double)); struct findpts_local_data fld; rand_mesh(); test_mesh(); findpts_local_setup(&fld,elx,nr,NEL,mr,BBOX_TOL,MAX_HASH_SIZE, NPT_MAX,NEWT_TOL); findpts_local(&testp[0].code , sizeof(struct pt_data), &testp[0].el , sizeof(struct pt_data), testp[0].r , sizeof(struct pt_data), &testp[0].dist2, sizeof(struct pt_data), x_base, x_stride, NEL*MULD(TN,TN,TN), &fld, buf); findpts_local_free(&fld); print_ptdata(); }
static void test(const struct comm *const comm) { const double *x_base[D]; const unsigned x_stride[D] = INITD(sizeof(struct pt_data), sizeof(struct pt_data), sizeof(struct pt_data)); struct findpts_data *fd; struct pt_data *pt; unsigned d; if(id==0) printf("Initializing mesh\n"); rand_mesh(); test_mesh(); pt = testp.ptr; if(id==0) printf("calling findpts_setup\n"); fd=findpts_setup(comm,elx,nr,NEL,mr,BBOX_TOL, LOC_HASH_SIZE,GBL_HASH_SIZE, NPT_MAX,NEWT_TOL); if(id==0) printf("calling findpts\n"); x_base[0]=pt->x, x_base[1]=pt->x+1; #if D==3 x_base[2]=pt->x+2; #endif findpts(&pt->code , sizeof(struct pt_data), &pt->proc , sizeof(struct pt_data), &pt->el , sizeof(struct pt_data), pt->r , sizeof(struct pt_data), &pt->dist2, sizeof(struct pt_data), x_base , x_stride, testp.n, fd); for(d=0; d<D; ++d) { if(id==0) printf("calling findpts_eval (%u)\n",d); findpts_eval(&pt->ex[d], sizeof(struct pt_data), &pt->code , sizeof(struct pt_data), &pt->proc , sizeof(struct pt_data), &pt->el , sizeof(struct pt_data), pt->r , sizeof(struct pt_data), testp.n, mesh[d], fd); } findpts_free(fd); print_ptdata(comm); }
static void mesh_run (mpi_context_t * mpi, p4est_connectivity_t * connectivity, int uniform, int compute_tree_index, int compute_level_lists, p4est_connect_type_t mesh_btype) { int mpiret; unsigned crc; long local_used[4], global_used[4]; p4est_t *p4est; p4est_ghost_t *ghost; p4est_mesh_t *mesh; user_data_t *ghost_data; p4est = p4est_new (mpi->mpicomm, connectivity, sizeof (user_data_t), init_fn, NULL); if (!uniform) p4est_vtk_write_file (p4est, NULL, P4EST_STRING "_mesh_new"); /* refinement */ if (uniform) { p4est_refine (p4est, 1, refine_uniform, init_fn); } else { p4est_refine (p4est, 1, refine_normal, init_fn); p4est_vtk_write_file (p4est, NULL, P4EST_STRING "_mesh_refined"); } /* balance */ p4est_balance (p4est, P4EST_CONNECT_FULL, init_fn); if (!uniform) p4est_vtk_write_file (p4est, NULL, P4EST_STRING "_mesh_balanced"); /* partition */ p4est_partition (p4est, 0, NULL); if (!uniform) { p4est_vtk_write_file (p4est, NULL, P4EST_STRING "_mesh_partition"); } crc = p4est_checksum (p4est); /* print and verify forest checksum */ P4EST_GLOBAL_STATISTICSF ("Tree %s checksum 0x%08x\n", uniform ? "uniform" : "adapted", crc); /* create ghost layer and mesh */ ghost = p4est_ghost_new (p4est, P4EST_CONNECT_FULL); ghost_data = P4EST_ALLOC (user_data_t, ghost->ghosts.elem_count); p4est_ghost_exchange_data (p4est, ghost, ghost_data); mesh = p4est_mesh_new_ext (p4est, ghost, compute_tree_index, compute_level_lists, mesh_btype); test_mesh (p4est, ghost, mesh, compute_tree_index, compute_level_lists, mesh_btype, ghost_data, uniform); /* compute memory used */ local_used[0] = (long) p4est_connectivity_memory_used (p4est->connectivity); local_used[1] = (long) p4est_memory_used (p4est); local_used[2] = (long) p4est_ghost_memory_used (ghost); local_used[3] = (long) p4est_mesh_memory_used (mesh); mpiret = sc_MPI_Allreduce (local_used, global_used, 4, sc_MPI_LONG, sc_MPI_SUM, mpi->mpicomm); SC_CHECK_MPI (mpiret); P4EST_GLOBAL_PRODUCTIONF ("Total %s memory used %ld %ld %ld %ld\n", uniform ? "uniform" : "adapted", global_used[0], global_used[1], global_used[2], global_used[3]); /* destroy ghost layer and mesh */ P4EST_FREE (ghost_data); p4est_mesh_destroy (mesh); p4est_ghost_destroy (ghost); /* destroy the p4est structure */ p4est_destroy (p4est); }