Example #1
0
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)
Example #2
0
File: grid1.py Project: drufat/dec
 def P(self, deg, isprimal, func):
     return decform(deg, isprimal, self, self.dec.P[deg, isprimal](func))
Example #3
0
File: grid1.py Project: drufat/dec
 def rand(self, deg, isprimal):
     '''
     Create a random form.
     '''
     return decform(deg, isprimal, self, np.random.rand(self.N[deg, isprimal]))
Example #4
0
 def P(form, isprimal, g):
     proj = projection_2d(g.cells)
     a = proj[form.degree, isprimal](form.lambdify)
     return decform(form.degree, isprimal, g, a)