How to use the devito.ir.support.space.IntervalGroup function in devito

To help you get started, we’ve selected a few devito examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github devitocodes / devito / devito / ir / support / space.py View on Github external
def wrapper(self, o):
            if not isinstance(o, IntervalGroup):
                o = IntervalGroup(as_tuple(o))
            return func(self, o)
        return wrapper
github opesci / devito / devito / ir / support / space.py View on Github external
>>> IntervalGroup.generate('intersection', ig0, ig1, ig2)
        IntervalGroup[x[2,-2]<0>, y[3,-3]<0>, z[1,-1]<0>]
        """
        mapper = {}
        for ig in interval_groups:
            for i in ig:
                mapper.setdefault(i.dim, []).append(i)
        intervals = []
        for v in mapper.values():
            # Create a new Interval through the concatenation v0.key(v1).key(v2)...
            interval = v[0]
            for i in v[1:]:
                interval = getattr(interval, op)(i)
            intervals.append(interval)
        relations = set().union(*[ig.relations for ig in interval_groups])
        return IntervalGroup(intervals, relations=relations)
github opesci / devito / devito / ir / support / space.py View on Github external
def drop(self, d):
        return IntervalGroup([i._rebuild() for i in self if i.dim not in as_tuple(d)],
                             relations=self.relations)
github devitocodes / devito / devito / ir / support / space.py View on Github external
>>> IntervalGroup.generate('intersection', ig0, ig1, ig2)
        IntervalGroup[x[2,-2]<0>, y[3,-3]<0>, z[1,-1]<0>]
        """
        mapper = {}
        for ig in interval_groups:
            for i in ig:
                mapper.setdefault(i.dim, []).append(i)
        intervals = []
        for v in mapper.values():
            # Create a new Interval through the concatenation v0.key(v1).key(v2)...
            interval = v[0]
            for i in v[1:]:
                interval = getattr(interval, op)(i)
            intervals.append(interval)
        relations = set().union(*[ig.relations for ig in interval_groups])
        return IntervalGroup(intervals, relations=relations)
github devitocodes / devito / devito / ir / support / space.py View on Github external
def negate(self):
        return IntervalGroup([i.negate() for i in self], relations=self.relations)
github devitocodes / devito / devito / ir / support / space.py View on Github external
def relaxed(self):
        return IntervalGroup.generate('union', IntervalGroup(i.relaxed for i in self))
github devitocodes / devito / devito / ir / support / space.py View on Github external
def drop(self, d):
        # Dropping
        dims = set().union(*[i._defines for i in as_tuple(d)])
        intervals = [i._rebuild() for i in self if not i.dim._defines & dims]

        # Clean up relations
        relations = [tuple(i for i in r if i in intervals) for r in self.relations]

        return IntervalGroup(intervals, relations=relations)
github opesci / devito / devito / autodiff.py View on Github external
def shift_interval_group(interval_group, mapper):
    new_intervals = []
    for interval in interval_group:
        if interval.dim in mapper:
            new_intervals.append(Interval(interval.dim,
                                          interval.lower+mapper[interval.dim],
                                          interval.upper+mapper[interval.dim]))
        else:
            new_intervals.append(interval)
    return IntervalGroup(new_intervals)
github opesci / devito / devito / ir / support / space.py View on Github external
    @classmethod
    def merge(cls, *others):
        if not others:
            return IterationSpace(IntervalGroup())
        elif len(others) == 1:
            return others[0]
        intervals = IntervalGroup.generate('merge', *[i.intervals for i in others])
        directions = {}
        for i in others:
            for k, v in i.directions.items():
                if directions.get(k, Any) in (Any, v):
                    # No direction yet, or Any, or simply identical to /v/
                    directions[k] = v
                elif v is not Any:
                    # Clash detected
                    raise ValueError("Cannot merge `IterationSpace`s with "
                                     "incompatible directions")
        sub_iterators = {}
        for i in others:
            for k, v in i.sub_iterators.items():