示例#1
0
 def div(self, shift=None):
     space_dims = [d for d in self.dimensions if d.is_Space]
     shift_x0 = make_shift_x0(shift, (len(space_dims), ))
     return Add(*[
         getattr(self, 'd%s' % d.name)(x0=shift_x0(shift, d, None, i))
         for i, d in enumerate(space_dims)
     ])
示例#2
0
 def div(self, shift=None):
     """
     Divergence of the VectorFunction, creates the divergence Function.
     """
     shift_x0 = make_shift_x0(shift, (len(self.space_dimensions), ))
     return sum([
         getattr(self[i], 'd%s' % d.name)(x0=shift_x0(shift, d, None, i))
         for i, d in enumerate(self.space_dimensions)
     ])
示例#3
0
 def grad(self, shift=None):
     from devito.types.tensor import VectorFunction, VectorTimeFunction
     space_dims = [d for d in self.dimensions if d.is_Space]
     shift_x0 = make_shift_x0(shift, (len(space_dims),))
     comps = [getattr(self, 'd%s' % d.name)(x0=shift_x0(shift, d, None, i))
              for i, d in enumerate(space_dims)]
     vec_func = VectorTimeFunction if self.is_TimeDependent else VectorFunction
     return vec_func(name='grad_%s' % self.name, time_order=self.time_order,
                     space_order=self.space_order, components=comps, grid=self.grid)
示例#4
0
 def grad(self, shift=None):
     """
     Gradient of the VectorFunction, creates the gradient TensorFunction.
     """
     func = tens_func(self)
     ndim = len(self.space_dimensions)
     shift_x0 = make_shift_x0(shift, (ndim, ndim))
     comps = [[
         getattr(f, 'd%s' % d.name)(x0=shift_x0(shift, d, i, j))
         for j, d in enumerate(self.space_dimensions)
     ] for i, f in enumerate(self)]
     return func._new(comps)
示例#5
0
 def div(self, shift=None):
     """
     Divergence of the TensorFunction (is a VectorFunction).
     """
     comps = []
     func = vec_func(self)
     ndim = len(self.space_dimensions)
     shift_x0 = make_shift_x0(shift, (ndim, ndim))
     for i in range(len(self.space_dimensions)):
         comps.append(
             sum([
                 getattr(self[j, i],
                         'd%s' % d.name)(x0=shift_x0(shift, d, i, j))
                 for j, d in enumerate(self.space_dimensions)
             ]))
     return func._new(comps)