Beispiel #1
0
    def inner(self, vec):
        """ Computes the inner product with vec. """
        assert isinstance(vec, DolfinPrimalVector)
        events.increment("Inner product")

        v = self.riesz_map.dual_map(self.data.vector())
        return v.inner(self.data.vector())
Beispiel #2
0
    def dual(self):
        """ Returns the dual representation. """

        events.increment("Primal -> dual map")
        if isinstance(self.data, dolfin.Function):
            V = self.data.function_space()

            dual_vec = self.riesz_map.dual_map(self.data.vector())
            dual = dolfin.Function(V, dual_vec)

            return DolfinDualVector(dual, riesz_map=self.riesz_map)
        else:
            return self
Beispiel #3
0
    def primal(self):
        """ Returns the primal representation. """
        events.increment("Dual -> primal map")

        if isinstance(self.data, dolfin.Function):
            V = self.data.function_space()

            dual = dolfin.Function(V)
            self.riesz_map.primal_map(dual.vector(), self.data.vector())

            return DolfinPrimalVector(dual, riesz_map=self.riesz_map)
        elif isinstance(self.data, dolfin.MultiMeshFunction):
            V = self.data.function_space()

            dual = dolfin.MultiMeshFunction(V)
            self.riesz_map.primal_map(dual.vector(), self.data.vector())

            return DolfinPrimalVector(dual, riesz_map=self.riesz_map)
        else:
            return self
Beispiel #4
0
    def inner(self, vec):
        """ Computes the inner product with vec. """
        assert isinstance(vec, DolfinPrimalVectorSet)
        events.increment("Inner product")

        return sum([ss.inner(vec) for ss, vec in zip(self.vector_list, vec.vector_list)])
Beispiel #5
0
    def primal(self):
        """ Returns the primal representation. """
        events.increment("Dual -> primal map")

        return NumpyPrimalVector(self.data.copy())
Beispiel #6
0
    def inner(self, vec):
        """ Computes the inner product with vec. """
        assert isinstance(vec, NumpyPrimalVector)
        events.increment("Inner product")

        return float(np.dot(self.data, vec.data))
Beispiel #7
0
    def primal(self):
        """ Returns the primal representation. """
        events.increment("Dual -> primal map")

        return NumpyPrimalVector(self.data.copy())
Beispiel #8
0
    def inner(self, vec):
        """ Computes the inner product with vec. """
        assert isinstance(vec, NumpyPrimalVector)
        events.increment("Inner product")

        return float(np.dot(self.data, vec.data))