def BC1(f): ((x0, y0), (x1,y1), (x2, y2), (x3, y3)) = faces_dual bc = zeros(x0.shape) ma = (y0==ymin) bc[ma] += integrate_1form( ((x0[ma], y0[ma]), (x1[ma], y1[ma])), f)[0] ma = (x1==xmax) bc[ma] += integrate_1form( ((x1[ma], y1[ma]), (x2[ma], y2[ma])), f)[0] ma = (y2==ymax) bc[ma] += integrate_1form( ((x2[ma], y2[ma]), (x3[ma], y3[ma])), f)[0] ma = (x3==xmin) bc[ma] += integrate_1form( ((x3[ma], y3[ma]), (x0[ma], y0[ma])), f)[0] return bc
def BC1(f): ((x0, y0), (x1, y1), (x2, y2), (x3, y3)) = faces_dual bc = zeros(x0.shape) ma = (y0 == ymin) bc[ma] += integrate_1form(((x0[ma], y0[ma]), (x1[ma], y1[ma])), f)[0] ma = (x1 == xmax) bc[ma] += integrate_1form(((x1[ma], y1[ma]), (x2[ma], y2[ma])), f)[0] ma = (y2 == ymax) bc[ma] += integrate_1form(((x2[ma], y2[ma]), (x3[ma], y3[ma])), f)[0] ma = (x3 == xmin) bc[ma] += integrate_1form(((x3[ma], y3[ma]), (x0[ma], y0[ma])), f)[0] return bc
def projection_2d(cells): ''' works for flattened cells ''' P = {(0, True ) : lambda f: f(*cells[0, True ]), (0, False) : lambda f: f(*cells[0, False]), (1, True ) : lambda f: integrate_1form(cells[1, True ], f)[0], (1, False) : lambda f: integrate_1form(cells[1, False], f)[0], (2, True ) : lambda f: integrate_2form(cells[2, True ], f)[0], (2, False) : lambda f: integrate_2form(cells[2, False], f)[0]} return P
def projection_2d(cells): ''' works for flattened cells ''' P = { (0, True): lambda f: f(*cells[0, True]), (0, False): lambda f: f(*cells[0, False]), (1, True): lambda f: integrate_1form(cells[1, True], f)[0], (1, False): lambda f: integrate_1form(cells[1, False], f)[0], (2, True): lambda f: integrate_2form(cells[2, True], f)[0], (2, False): lambda f: integrate_2form(cells[2, False], f)[0] } return P