Пример #1
0
    def map_interpolation(self, expr):
        operand = self.rec(expr.operand)

        if isinstance(operand, cl.array.Array):
            from pytential.symbolic.dof_connection import connection_from_dds

            conn = connection_from_dds(self.places, expr.from_dd, expr.to_dd)
            return conn(self.queue, operand).with_queue(self.queue)
        elif isinstance(operand, (int, float, complex, np.number)):
            return operand
        else:
            raise TypeError("cannot interpolate `{}`".format(type(operand)))
Пример #2
0
    def get_connection(self, from_dd, to_dd):
        """Construct a connection from *from_dd* to *to_dd* geometries.

        :param from_dd: a :class:`~pytential.symbolic.primitives.DOFDescriptor`
            or a value that can be converted to one using
            :func:`~pytential.symbolic.primitives.as_dofdesc`.
        :param to_dd: as *from_dd*.

        :returns: an object compatible with the
            :class:`~meshmode.discretization.connection.DiscretizationConnection`
            interface.
        """

        from pytential.symbolic.dof_connection import connection_from_dds
        return connection_from_dds(self, from_dd, to_dd)
Пример #3
0
    def map_interpolation(self, expr):
        if expr.to_dd.discr_stage != sym.QBX_SOURCE_QUAD_STAGE2:
            raise RuntimeError(
                "can only interpolate to QBX_SOURCE_QUAD_STAGE2")

        operand = self.rec(expr.operand)
        if isinstance(operand, (int, float, complex, np.number)):
            return operand
        elif isinstance(operand, np.ndarray) and operand.ndim == 1:
            from pytential.symbolic.dof_connection import connection_from_dds
            conn = connection_from_dds(self.places, expr.from_dd, expr.to_dd)

            operand = cl.array.to_device(self.queue, operand)
            return conn(self.queue, operand).get(self.queue)
        elif isinstance(operand, np.ndarray) and operand.ndim == 2:
            resampler = self.places.get_geometry(expr.from_dd).direct_resampler
            mat = resampler.full_resample_matrix(self.queue).get(self.queue)
            return mat.dot(operand)
        else:
            raise RuntimeError('unknown operand type: {}'.format(
                type(operand)))
Пример #4
0
 def get_connection(self, from_dd, to_dd):
     from pytential.symbolic.dof_connection import connection_from_dds
     return connection_from_dds(self, from_dd, to_dd)