static void compute_box( ZZ *zz, int part, /* Partition whose box is being computed */ struct rcb_tree *treept, /* RCB tree */ int node, /* node of the RCB tree to be examined */ struct rcb_box *boxpt /* extended box */ ) { /* Routine that traverses RCB tree and assigns lo and hi coordinates of box */ struct rcb_tree *nodept = &(treept[node]); if (part >= node) { boxpt->lo[nodept->dim] = nodept->cut; if (nodept->right_leaf > 0) compute_box(zz, part, treept, nodept->right_leaf, boxpt); } else { boxpt->hi[nodept->dim] = nodept->cut; if (nodept->left_leaf > 0) compute_box(zz, part, treept, nodept->left_leaf, boxpt); } }
int Zoltan_RCB_Box( ZZ *zz, /* The Zoltan structure */ int part, /* Partition whose box should be returned */ int *ndim, /* Number of dimensions in the geometry partitioned (and, thus, in the RCB box for the part) */ double *xmin, /* lower x extent of box */ double *ymin, /* lower y extent of box */ double *zmin, /* lower z extent of box */ double *xmax, /* upper x extent of box */ double *ymax, /* upper y extent of box */ double *zmax /* upper z extent of box */ ) { /* Return the bounding box for a processor's subdomain. */ static char *yo = "Zoltan_RCB_Box"; RCB_STRUCT *rcb; /* Pointer to data structures for RCB. */ struct rcb_tree *treept; /* tree of RCB cuts */ struct rcb_box box; /* box data structure */ int i, ierr = ZOLTAN_OK; box.lo[0] = -DBL_MAX; box.lo[1] = -DBL_MAX; box.lo[2] = -DBL_MAX; box.hi[0] = DBL_MAX; box.hi[1] = DBL_MAX; box.hi[2] = DBL_MAX; *ndim = -1; if (zz->LB.Data_Structure == NULL) { ZOLTAN_PRINT_ERROR(zz->Proc, yo, "No Decomposition Data available; use KEEP_CUTS parameter."); ierr = ZOLTAN_FATAL; goto End; } if (zz->LB.Method != RCB) { ZOLTAN_PRINT_ERROR(zz->Proc, yo, "Function can be used only with LB_METHOD == RCB."); ierr = ZOLTAN_FATAL; goto End; } if (part < 0 || part >= zz->LB.Num_Global_Parts) { ZOLTAN_PRINT_ERROR(zz->Proc, yo, "Invalid part number."); ierr = ZOLTAN_FATAL; goto End; } if (zz->LB.Remap) /* Partitions are re-mapped; need to find old part number before going through tree of cuts. */ for (i = 0; i < zz->LB.Num_Global_Parts; i++) if (zz->LB.Remap[i] == part) { part = i; break; } rcb = (RCB_STRUCT *) (zz->LB.Data_Structure); treept = rcb->Tree_Ptr; if (treept[0].dim < 0) { /* RCB tree was never created. */ ZOLTAN_PRINT_ERROR(zz->Proc, yo, "No RCB tree saved; " " Must set parameter KEEP_CUTS to 1."); ierr = ZOLTAN_FATAL; goto End; } if (treept[0].right_leaf > 0) compute_box(zz, part, treept, treept[0].right_leaf, &box); else{ box.lo[0] = box.lo[1] = box.lo[2] = 0; box.hi[0] = box.hi[1] = box.hi[2] = 0; } *ndim = rcb->Num_Dim; End: *xmin = box.lo[0]; *ymin = box.lo[1]; *zmin = box.lo[2]; *xmax = box.hi[0]; *ymax = box.hi[1]; *zmax = box.hi[2]; return ierr; }
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()