void prolongate( int level ) { int i,j; const int prolongation_vars[1] = { VAR_POTENTIAL }; int icell; int num_level_cells; int *level_cells; cart_assert( level >= min_level+1 ); start_time( WORK_TIMER ); select_level( level-1, CELL_TYPE_LOCAL | CELL_TYPE_REFINED, &num_level_cells, &level_cells ); #pragma omp parallel for default(none), private(i,icell,j), shared(num_level_cells,level_cells,cell_vars,cell_child_oct) for ( i = 0; i < num_level_cells; i++ ) { icell = level_cells[i]; for ( j = 0; j < num_children; j++ ) { cell_potential( cell_child(icell,j) ) = cell_interpolate( icell, j, VAR_POTENTIAL ); } } cart_free( level_cells ); end_time( WORK_TIMER ); /* update buffers */ start_time( PROLONGATE_UPDATE_TIMER ); update_buffer_level( level, prolongation_vars, 1 ); end_time( PROLONGATE_UPDATE_TIMER ); }
static float interpolate_float_image_bilinearly(float *x, int w, int h, float i, float j) { int ii = i; int jj = j; extension_operator_float p = extend_float_image_constant; float a = p(x, w, h, ii , jj ); float b = p(x, w, h, ii , jj+1); float c = p(x, w, h, ii+1, jj ); float d = p(x, w, h, ii+1, jj+1); return cell_interpolate(a, b, c, d, i-ii, j-jj, 2); }
void compute_accelerations_hydro( int level ) { int i, j; double a2half; int neighbors[num_neighbors]; int L1, R1; double phi_l, phi_r; #ifdef GRAVITY_IN_RIEMANN const int accel_vars[nDim] = { VAR_ACCEL, VAR_ACCEL+1, VAR_ACCEL+2 }; #endif int icell; int num_level_cells; int *level_cells; start_time( GRAVITY_TIMER ); start_time( HYDRO_ACCEL_TIMER ); start_time( WORK_TIMER ); #ifdef COSMOLOGY a2half = abox_from_tcode( tl[level] + dtl[level] ); a2half = -0.5*dtl[level]*cell_size_inverse[level]*a2half*a2half; #else a2half = -0.5*dtl[level]*cell_size_inverse[level]; #endif select_level( level, CELL_TYPE_LOCAL, &num_level_cells, &level_cells ); #ifdef OPENMP_DECLARE_CONST #pragma omp parallel for default(none), private(icell,j,neighbors,L1,R1,phi_l,phi_r), shared(num_level_cells,level_cells,level,cell_vars,a2half), shared(local) #else /* OPENMP_DECLARE_CONST */ #pragma omp parallel for default(none), private(icell,j,neighbors,L1,R1,phi_l,phi_r), shared(num_level_cells,level_cells,level,cell_vars,a2half) #endif /* OPENMP_DECLARE_CONST */ for ( i = 0; i < num_level_cells; i++ ) { icell = level_cells[i]; cell_all_neighbors( icell, neighbors ); for ( j = 0; j < nDim; j++ ) { L1 = neighbors[2*j]; R1 = neighbors[2*j+1]; if ( cell_level(L1) == level && cell_level(R1) == level ) { phi_l = cell_potential_hydro(L1); phi_r = cell_potential_hydro(R1); } else { if ( cell_level(L1) < level ) { phi_l = cell_interpolate( L1, local[cell_child_number(icell)][2*j], VAR_POTENTIAL_HYDRO ); phi_r = cell_potential_hydro(R1); } else { phi_l = cell_potential_hydro(L1); phi_r = cell_interpolate( R1, local[cell_child_number(icell)][2*j], VAR_POTENTIAL_HYDRO ); } } cell_accel( icell, j ) = (float)(a2half * ( phi_r - phi_l ) ); } } cart_free( level_cells ); end_time( WORK_TIMER ); #ifdef GRAVITY_IN_RIEMANN /* this only gets called if we pass gravity on to Riemann solver (and thus need accel in buffer cells) */ start_time( HYDRO_ACCEL_UPDATE_TIMER ); update_buffer_level( level, accel_vars, nDim ); end_time( HYDRO_ACCEL_UPDATE_TIMER ); #endif end_time( HYDRO_ACCEL_TIMER ); end_time( GRAVITY_TIMER ); }