def to_discrete(f, g, isprimal): d, ch, c = f.degree, f.grid, f.components assert g.dimension == ch.dimension cells = g.cells[d, isprimal] sym = ch.coords + ch.cell_coords(ch.dimension) integration = [None, integration_1d, integration_2d] integrate = integration[ch.dimension](*sym)[d](c) λ = sy.lambdify(ch.cell_coords(d), integrate, 'numpy') if ch.dimension == 1: if d == 0: x0 = cells a = λ(x0) elif d == 1: x0, x1 = cells a = λ(x0, x1) elif ch.dimension == 2: return g.P(f, isprimal) # if d == 0: # x0, y0 = cells # a = λ(x0, y0) # elif d == 1: # (x0, y0), (x1, y1) = cells # a = λ(x0, y0, x1, y1) # elif d == 2: # (x0, y0), (x1, y1), (x2, y2), (x3, y3) = cells # a = (λ(x0, y0, x1, y1, x2, y2) + # λ(x0, y0, x2, y2, x3, y3)) return decform(d, isprimal, g, a)
def P(self, deg, isprimal, func): return decform(deg, isprimal, self, self.dec.P[deg, isprimal](func))
def rand(self, deg, isprimal): ''' Create a random form. ''' return decform(deg, isprimal, self, np.random.rand(self.N[deg, isprimal]))
def P(form, isprimal, g): proj = projection_2d(g.cells) a = proj[form.degree, isprimal](form.lambdify) return decform(form.degree, isprimal, g, a)