Exemple #1
0
static bool
local_checkCellDistance(sfc_key_t key,
                        double centre[],
                        double gatherRad,
                        sfc_curve_t ctype,
                        uint32_t bits)
{
	uint32_t cellGridPos[3];
	double cellRealPos[3];
	double gridToRealFac;
	double cellLargestRadius;
	double dx, dy, dz, dist2;
   uint64_t one=UINT64_C(1);

	/*
	 * Calculate the grid scale and the largest radius in the cell,
	 * which is given as the distance between the center of the cell and
	 * one of the corner points.
	 */
	gridToRealFac = 1./(one<<bits);
	cellLargestRadius = 0.5*sqrt(3.)*gridToRealFac;

	/* Get the grid coordinate of the cell and convert it to real-space */
	sfc_curve_calcPos(ctype, key, bits, cellGridPos);
	cellRealPos[0] = (gridToRealFac*cellGridPos[0])+0.5*gridToRealFac;
	cellRealPos[1] = (gridToRealFac*cellGridPos[1])+0.5*gridToRealFac;
	cellRealPos[2] = (gridToRealFac*cellGridPos[2])+0.5*gridToRealFac;

	/* The squared distance between the cell center and the halo center */
	LOCAL_CAL_DXYZ(cellRealPos, centre);
	dist2 = dx*dx + dy*dy + dz*dz;

	/*
	 * If the halo center is further away than the gather radius
	 * enlarged by largest cell radius, then the cell is too far away to
	 * hold any halo particles, hence ignore the cell 
	 */
	if (isgreater(sqrt(dist2), cellLargestRadius+GATHERRAD_FAC*gatherRad))
		return false;

	/* Well... seems we need to deal with this cell after all */
	return true;
}
Exemple #2
0
extern void sfc_boundary_getBox(sfc_boundary_t bound, uint32_t num, uint32_t *p1, uint32_t *p2) {
    uint64_t i;
    uint32_t pos[3], j;
    bool     boundary_exists;

    /* Initialize the coordinates */
    boundary_exists = false;
    for(j = 0; j < num; j++)
        if((bound + j)->num != UINT64_C(0))
            boundary_exists = true;
    if(!boundary_exists) {
        p1[0] = p1[1] = p1[2] = UINT32_C(0);
        p2[0] = p2[1] = p2[2] = (1 << bound->bits) - 1;
        return;
    }
    p1[0] = p1[1] = p1[2] = UINT32_MAX;
    p2[0] = p2[1] = p2[2] = UINT32_C(0);

    /* Loop over all boundaries */
    for(j = 0; j < num; j++) {
        /* Start looping over all boundary keys */
        for(i = UINT64_C(0); i < (bound + j)->num; i++) {
            /* Get the position...*/
            sfc_curve_calcPos((bound + j)->ctype, (bound + j)->bound[i], (bound + j)->bits, pos);
            /* ...and update the corner points if needed */
            p1[0] = (pos[0] < p1[0]) ? pos[0] : p1[0];
            p2[0] = (pos[0] > p2[0]) ? pos[0] : p2[0];
            p1[1] = (pos[1] < p1[1]) ? pos[1] : p1[1];
            p2[1] = (pos[1] > p2[1]) ? pos[1] : p2[1];
            p1[2] = (pos[2] < p1[2]) ? pos[2] : p1[2];
            p2[2] = (pos[2] > p2[2]) ? pos[2] : p2[2];
        }
    }

    return;
}