void BoxLevelStatistics::computeLocalBoxLevelStatistics(const BoxLevel& box_level) { box_level.cacheGlobalReducedData(); /* * Compute per-processor statistics. Some quantities are readily * available while others are computed in the loop following. * * Aspect ratio uses a generalized formula that goes to 1 when box * has same length on all sides (regardless of dimension), * degenerates to the rectangular aspect ratio in 2D, and grows * appropriately for dimensions higher than 2. */ d_sq.d_values[HAS_ANY_BOX] = (box_level.getLocalNumberOfBoxes() > 0); d_sq.d_values[NUMBER_OF_CELLS] = static_cast<double>(box_level.getLocalNumberOfCells()); d_sq.d_values[NUMBER_OF_BOXES] = static_cast<double>(box_level.getLocalNumberOfBoxes()); d_sq.d_values[MAX_BOX_VOL] = 0; d_sq.d_values[MIN_BOX_VOL] = tbox::MathUtilities<double>::getMax(); d_sq.d_values[MAX_BOX_LEN] = 0; d_sq.d_values[MIN_BOX_LEN] = tbox::MathUtilities<double>::getMax(); d_sq.d_values[MAX_ASPECT_RATIO] = 0; d_sq.d_values[SUM_ASPECT_RATIO] = 0; d_sq.d_values[SUM_SURFACE_AREA] = 0.; d_sq.d_values[SUM_NORM_SURFACE_AREA] = 0.; const BoxContainer& boxes = box_level.getBoxes(); for (RealBoxConstIterator ni(boxes.realBegin()); ni != boxes.realEnd(); ++ni) { const Box& box = *ni; const IntVector boxdims = box.numberCells(); const double boxvol = static_cast<double>(boxdims.getProduct()); const int longdim = boxdims.max(); const int shortdim = boxdims.min(); double aspect_ratio = 0.0; double surfarea = 0.; for (int d = 0; d < d_dim.getValue(); ++d) { surfarea += 2 * double(boxvol) / boxdims(d); double tmp = static_cast<double>(boxdims(d)) / shortdim - 1.0; aspect_ratio += tmp * tmp; } aspect_ratio = 1.0 + sqrt(aspect_ratio); d_sq.d_values[MAX_BOX_VOL] = tbox::MathUtilities<double>::Max(d_sq.d_values[MAX_BOX_VOL], boxvol); d_sq.d_values[MIN_BOX_VOL] = tbox::MathUtilities<double>::Min(d_sq.d_values[MIN_BOX_VOL], boxvol); d_sq.d_values[MAX_BOX_LEN] = tbox::MathUtilities<double>::Max(d_sq.d_values[MAX_BOX_LEN], longdim); d_sq.d_values[MIN_BOX_LEN] = tbox::MathUtilities<double>::Min(d_sq.d_values[MIN_BOX_LEN], shortdim); d_sq.d_values[MAX_ASPECT_RATIO] = tbox::MathUtilities<double>::Max(d_sq.d_values[MAX_ASPECT_RATIO], aspect_ratio); d_sq.d_values[SUM_ASPECT_RATIO] += aspect_ratio; d_sq.d_values[SUM_SURFACE_AREA] += surfarea; } /* * Smallest surface area possible for the number of cells perfectly * distributed in d_mpi. */ const double ideal_surfarea = 2 * d_dim.getValue() * pow(double(box_level.getGlobalNumberOfCells()) / d_mpi.getSize(), double(d_dim.getValue() - 1) / d_dim.getValue()); d_sq.d_values[SUM_NORM_SURFACE_AREA] = d_sq.d_values[SUM_SURFACE_AREA] / ideal_surfarea; }