예제 #1
0
 def _components(self):
     if self.dof_dset.cdim == 1:
         return (self, )
     else:
         return tuple(CoordinatelessFunction(self.function_space().sub(i), val=op2.DatView(self.dat, j),
                                             name="view[%d](%s)" % (i, self.name()))
                      for i, j in enumerate(np.ndindex(self.dof_dset.dim)))
예제 #2
0
파일: function.py 프로젝트: tlroy/firedrake
    def sub(self, i):
        """Extract the ith sub :class:`Function` of this :class:`Function`.

        :arg i: the index to extract

        See also :meth:`split`.

        If the :class:`Function` is defined on a
        :class:`~.VectorFunctionSpace`, this returns a proxy object
        indexing the ith component of the space, suitable for use in
        boundary condition application."""
        if len(self.function_space()) == 1 and self.function_space().rank == 1:
            fs = self.function_space().sub(i)
            return Function(fs, val=op2.DatView(self.dat, i),
                            name="view[%d](%s)" % (i, self.name()))
        return self.split()[i]