void smooth_parallel(Mesh* mesh, int niter){ //Colouring phase int colour = 0; vertices = mesh->NNodes; populate_vertices( mesh ); while( vertices > 0 ){ std::vector<int> v; slices.push_back(v); select_vertices( mesh, colour ); colour++; } printf("Colours: %d\n", colour); delete[] vertices_in_neighberhood; delete[] to_examine_all; //Execution phase svd_init( mesh->NNodes ); double * quality_cache = new double[mesh->NElements]; bool * vertice_in_cache = new bool[mesh->NElements]; memset(quality_cache, 0, mesh->NElements); memset(vertice_in_cache, false, mesh->NElements); for(int iter = 0; iter < niter; iter++){ for(size_t c = 0; c < colour; c++){ spawn_threads( mesh, c, quality_cache, vertice_in_cache, iter ); } } svd_teardown( mesh->NNodes ); delete[] quality_cache; delete[] vertice_in_cache; }
static void make_healpix_weights (int nside, double *weight) { int lmax = (int)(3.5*nside); double dth1 = 1./(3*nside*nside); double dth2 = 2./(3*nside); int nring = 2*nside; int npix = 12*nside*nside; double **mat, *z=RALLOC(double,nring); int *nir=RALLOC(int,nring); double *b=RALLOC(double,nring); svd_obj svd; int ith, l; ALLOC2D(mat,double,lmax/2+1,nring); for (ith=0; ith<nring; ++ith) { if (ith<nside-1) { nir[ith] = 8*(ith+1); z[ith] = 1 - dth1*(ith+1)*(ith+1); } else { nir[ith]=8*nside; z[ith] = (2*nside-ith-1)*dth2; } } nir[nring-1]/=2; for (l=0; l<=lmax/2; ++l) for (ith=0; ith<nring; ++ith) mat[l][ith]=0; for (ith=0; ith<nring; ++ith) { double p0 = 1; double p1 = z[ith]; mat[0][ith] = p0; for (l=2; l<=lmax; ++l) { double p2 = z[ith]*p1*(2*l-1) - p0*(l-1); p2/=l; if ((l%2)==0) mat[l/2][ith] = p2; p0 = p1; p1 = p2; } } for (l=0; l<=lmax/2; ++l) { double bb=0; for (ith=0; ith<nring; ++ith) bb+=mat[l][ith]*nir[ith]; b[l] = -bb; } b[0] += npix; svd_init(mat,1e-14,lmax/2+1,nring,&svd); svd_solve(&svd,b); svd_destroy(&svd); for (l=0;l<nring;++l) weight[l]=weight[2*nring-l-2] = 1.+b[l]/nir[l]; DEALLOC2D(mat); DEALLOC(b); DEALLOC(z); DEALLOC(nir); }