def cell_orientation(self, restriction): """Cell orientation as a GEM expression.""" f = {None: 0, '+': 0, '-': 1}[restriction] # Assume self._cell_orientations tuple is set up at this point. co_int = self._cell_orientations[f] return gem.Conditional( gem.Comparison("==", co_int, gem.Literal(1)), gem.Literal(-1), gem.Conditional(gem.Comparison("==", co_int, gem.Zero()), gem.Literal(1), gem.Literal(numpy.nan)))
def conditional(self, o, condition, then, else_): assert condition.shape == () shape, = set([then.shape, else_.shape]) indices = gem.indices(len(shape)) return gem.ComponentTensor( gem.Conditional(condition, gem.Indexed(then, indices), gem.Indexed(else_, indices)), indices)