Beispiel #1
0
void compute_wedge_y(Grid* A, Grid* B, int x, int y, int s) {
	assert(s > 0);


	if (s <= CUT_OFF) {

		// compute height of wedge
		int h = (s + 1) / 2;

		if (DEBUG) printf("Computing wedge %d/%d/%d/Y ...\n", x, y, s);

		// just compute the wedge
		for(int l=0; l<h; l++) {

			// compute one plain of the pyramid
			for(int i = x-l; i<=x+l; i++) {
				//printf("Level %d - bounds x: %d,%d - bounds y: %d,%d\n", h, x-l, x+l, y-(h-l)+1, y+(h-l)-1 );
				for(int j = y-(h-l)+1; j<=y+(h-l)-1; j++) {
					update(A,B,i,j);
				}
			}

			// switch plains
			Grid* C = A;
			A = B;
			B = C;
		}

		return;
	}

	if (DEBUG) printf("Decomposing wedge %d/%d/%d/Y ...\n", x, y, s);

	// decompose into 2 pyramids and 4 wedges

	// compute coordinates offset of sub-wedges
	int d = (s-1)/2;
	int h = (d+1)/2;

	// compute bottom wedges (parallel)
	#pragma omp task
	compute_wedge_y(A, B, x, y-h, d);
	#pragma omp task
	compute_wedge_y(A, B, x, y+h, d);
	#pragma omp taskwait

	// reverse pyramid
	compute_reverse(A, B, x, y, d);

	// compute pyramid on top
	compute_pyramid(A, B, x, y, d);

	// compute remaining two wedges (parallel)
	#pragma omp task
	compute_wedge_y(A, B, x-h, y, d);
	#pragma omp task
	compute_wedge_y(A, B, x+h, y, d);
	#pragma omp taskwait
}
Beispiel #2
0
void jacobi_recursive(Grid* A, Grid* B, int num_iter) {

	#pragma omp parallel
	{
		#pragma omp single
		{
			// compute full pyramid
			if (DEBUG) printf("\nProcessing main pyramid ...\n");
			compute_pyramid(A, B, N/2, N/2, N-2);
			if (DEBUG) printf("\nProcessing x wedge ...\n");
			compute_wedge_x(A, B, N/2,0, N-2);
			if (DEBUG) printf("\nProcessing y wedge ...\n");
			compute_wedge_y(A, B, 0, N/2, N-2);
			if (DEBUG) printf("\nProcessing reverse pyramid ...\n");
			compute_reverse(A, B, 0, 0, N-2);
		}
	}

}
Beispiel #3
0
void compute_reverse(Grid* A, Grid* B, int x, int y, int s) {
	assert(s % 2 == 1 && "Only odd sizes are supported!");

	// check for terminal case
	if (s <= CUT_OFF) {

		// compute height of pyramid
		int h = (s + 1) / 2;
		if (DEBUG) printf("Computing reverse pyramid at (%d,%d) with size %d  ...\n", x, y, s);

		// just compute the pyramid
		for(int l=0; l<h; l++) {

			// compute one plain of the pyramid
			for(int i = x-l; i<=x+l; i++) {
				for(int j = y-l; j<=y+l; j++) {
					update(A,B,i,j);
				}
			}

			// switch plains
			Grid* C = A;
			A = B;
			B = C;
		}

		// done
		return;
	}

	if (DEBUG) printf("Decomposing reverse pyramid at (%d,%d) with size %d ...\n", x, y, s);

	// cut into 6 smaller pyramids + 4 wedges

	// compute size of pyramids
	int d = (s-1)/2;
	int h = (d+1)/2;

	int ux = x - h;
	int lx = x + h;
	int uy = y - h;
	int ly = y + h;

	// compute tip
	compute_reverse(A, B, x, y, d);

	// compute reverse pyramid in the center
	compute_pyramid(A, B, x, y, d);

	// compute 4 wedges (parallel)
	#pragma omp task
	compute_wedge_y(A, B, ux, y, d);
	#pragma omp task
	compute_wedge_y(A, B, lx, y, d);
	#pragma omp task
	compute_wedge_x(A, B, x, uy,  d);
	#pragma omp task
	compute_wedge_x(A, B, x, ly, d);

	#pragma omp taskwait

	// compute 4 base-pyramids (parallel)
	#pragma omp task
	compute_reverse(A, B, lx, ly,  d);
	#pragma omp task
	compute_reverse(A, B, lx, uy,  d);
	#pragma omp task
	compute_reverse(A, B, ux, ly,  d);
	#pragma omp task
	compute_reverse(A, B, ux, uy,  d);

	#pragma omp taskwait

}
Beispiel #4
0
  bool AnalyticFormFactor::compute(ShapeName shape, real_t tau, real_t eta, vector3_t transvec,
                                    std::vector<complex_t>& ff,
                                    shape_param_list_t& params, real_t single_layer_thickness,
                                    RotMatrix_t & rot
                                    #ifdef USE_MPI
                                      , woo::MultiNode& world_comm, std::string comm_key
                                    #endif
                                    ) {

    #ifdef FF_VERBOSE
      std::cout << "-- Computing form factor analytically ... " << std::endl;
    #endif
//    #ifdef TIME_DETAIL_1
      woo::BoostChronoTimer compute_timer;
      compute_timer.start();
//    #endif // TIME_DETAIL_1

    switch(shape) {
      case shape_cube:            // cube
        if(!compute_cube(nqx_, nqy_, nqz_, ff, params, tau, eta, transvec)) {
          std::cerr << "error: something went wrong while computing FF for a cube"
            << std::endl;
          return false;
        } // if
        break;
      case shape_box:            // cube or box
        if(!compute_box(nqx_, nqy_, nqz_, ff, shape, params, tau, eta, transvec)) {
          std::cerr << "error: something went wrong while computing FF for a box"
                << std::endl;
          return false;
        } // if
        break;
      case shape_cylinder:        // standing cylinder
        if(!compute_cylinder(params, tau, eta, ff, transvec)) {
          std::cerr << "error: something went wrong while computing FF for a cylinder"
                << std::endl;
          return false;
        } // if
        break;
      case shape_sphere:          // simple sphere
        if(!compute_sphere(params, ff, transvec)) {
          std::cerr << "error: something went wrong while computing FF for a sphere"
                << std::endl;
          return false;
        } // if
        break;
      case shape_prism3:          // triangular prism (prism with 3 sides)
        if(!compute_prism(params, ff, tau, eta, transvec)) {
          std::cerr << "error: something went wrong while computing FF for a prism3"
                << std::endl;
          return false;
        } // if
        break;
      case shape_prism6:          // hexagonal prism (prism with 6 sides)
        if(!compute_prism6(params, ff, tau, eta, transvec)) {
          std::cerr << "error: something went wrong while computing FF for a prism6"
                << std::endl;
          return false;
        } // if
        break;
      case shape_sawtooth_down:      // downwards sawtooth
        if(!compute_sawtooth_down()) {
          std::cerr << "error: something went wrong while computing FF for a sawtooth down"
                << std::endl;
          return false;
        } // if
        break;
      case shape_sawtooth_up:        // upwards sawtooth
        if(!compute_sawtooth_up()) {
          std::cerr << "error: something went wrong while computing FF for a sawtooth up"
                << std::endl;
          return false;
        } // if
        break;
      case shape_prism3x:          // triangular grating in x direction
        if(!compute_prism3x(params, ff, tau, eta, transvec)) {
          std::cerr << "error: something went wrong while computing FF for a prism3x"
                << std::endl;
          return false;
        } // if
        break;
      case shape_pyramid:          // pyramid
        if(!compute_pyramid(params, ff, tau, eta, transvec)){
          std::cerr << "error: something went wrong while computing FF for a pyramid"
                << std::endl;
          return false;
        } // if
        break;
      case shape_trunccone:        // truncated cone
        if(!compute_truncated_cone(params, tau, eta, ff, transvec)) {
          std::cerr << "error: something went wrong while computing FF for a truncated cone"
                << std::endl;
          return false;
        } // if
        break;
      default:
        std::cerr << "error: invalid shape. given shape is not supported" << std::endl;
        return false;
    } // switch

    #ifdef TIME_DETAIL_1
      compute_timer.stop();
      std::cout << "**               FF compute time: " << compute_timer.elapsed_msec() << " ms."
            << std::endl;
    #endif // TIME_DETAIL_1

    return true;
  } // AnalyticFormFactor::compute()