コード例 #1
0
ファイル: translation_classes.py プロジェクト: xywei/boxtree
            if (!(-dim_bound <= vec.s${i} && vec.s${i} <= dim_bound))
            {
                return -1;
            }
        %endfor

        int result = 0;
        int base = 4 * well_sep_is_n_away + 3;
        int mult = 1;
        %for i in range(dimensions):
            result += (2 * well_sep_is_n_away + 1 + vec.s${i}) * mult;
            mult *= base;
        %endfor
        return result;
    }
    """ + str(InlineBinarySearch("box_id_t")),
                                                      strict_undefined=True)

TRANSLATION_CLASS_FINDER_TEMPLATE = ElementwiseTemplate(
    arguments=r"""//CL:mako//
    /* input: */
    box_id_t *from_sep_siblings_lists,
    box_id_t *from_sep_siblings_starts,
    box_id_t *target_or_target_parent_boxes,
    int ntarget_or_target_parent_boxes,
    coord_t *box_centers,
    int aligned_nboxes,
    coord_t root_extent,
    box_level_t *box_levels,
    int well_sep_is_n_away,
コード例 #2
0
ファイル: refinement.py プロジェクト: nchristensen/pytential
            bool is_close = (
                distance(${ball_center}, source_coords)
                <= (1-expansion_disturbance_tolerance)
                        * center_danger_zone_radii[icenter]);

            if (is_close)
            {
                atomic_or(&panel_refine_flags[center_panel], 1);
                atomic_or(found_panel_to_refine, 1);
                break;
            }
        }
        """,
    name="check_center_closest_to_orig_panel",
    preamble=str(InlineBinarySearch("particle_id_t")))

# Refinement checker for Condition 2.
SUFFICIENT_SOURCE_QUADRATURE_RESOLUTION_CHECKER = AreaQueryElementwiseTemplate(
    extra_args=r"""
        /* input */
        particle_id_t *box_to_center_starts,
        particle_id_t *box_to_center_lists,
        particle_id_t *panel_to_source_starts,
        particle_id_t source_offset,
        particle_id_t center_offset,
        particle_id_t *sorted_target_ids,
        coord_t *source_danger_zone_radii_by_panel,
        int npanels,

        /* output */
コード例 #3
0
ファイル: area_query.py プロジェクト: tarwcz111111111/boxtree
from pyopencl.elementwise import ElementwiseTemplate
from boxtree.tools import InlineBinarySearch

STARTS_EXPANDER_TEMPLATE = ElementwiseTemplate(
    arguments=r"""
        idx_t *dst,
        idx_t *starts,
        idx_t starts_len
    """,
    operation=r"""//CL//
    /* Find my index in starts, place the index in dst. */
    dst[i] = bsearch(starts, starts_len, i);
    """,
    name="starts_expander",
    preamble=str(InlineBinarySearch("idx_t")))

# }}}

# {{{ area query elementwise template


class AreaQueryElementwiseTemplate(object):
    """
    Experimental: Intended as a way to perform operations in the body of an area
    query.
    """
    @staticmethod
    def unwrap_args(tree, peer_lists, *args):
        return (tree.box_centers, tree.root_extent, tree.box_levels,
                tree.aligned_nboxes, tree.box_child_ids, tree.box_flags,
コード例 #4
0
            bool is_close =
                distance(target_coords, source_coords)
                <= tunnel_radius_by_source[source];

            if (is_close && target_status[i] == MARKED_QBX_CENTER_PENDING)
            {
                particle_id_t panel = bsearch(
                    panel_to_source_starts, npanels + 1, source);
                atomic_or(&refine_flags[panel], 1);
                atomic_or(found_panel_to_refine, 1);
            }
        }
    """,
    name="refine_panels",
    preamble=TARGET_ASSOC_DEFINES + str(InlineBinarySearch("particle_id_t")))

# }}}

# {{{ target associator


class QBXTargetAssociationFailedException(Exception):
    """
    .. attribute:: refine_flags
    .. attribute:: failed_target_flags
    """
    def __init__(self, refine_flags, failed_target_flags, message):
        self.refine_flags = refine_flags
        self.failed_target_flags = failed_target_flags
        self.message = message