def create_quadrature(shape, num_points): """ Generate quadrature rule (points, weights) for given shape with num_points points in each direction. """ if isinstance(shape, int) and shape == 0: return ([()], array([1.0,])) if shape in cellname2dim and cellname2dim[shape] == 0: return ([()], array([1.0,])) quad_rule = FIAT.make_quadrature(reference_cell(shape), num_points) return quad_rule.get_points(), quad_rule.get_weights()
def create_quadrature(cell, num_points): """ Generate quadrature rule (points, weights) for given shape with num_points points in each direction. """ if isinstance(cell, int) and cell == 0: return ([()], array([1.0,])) if isinstance(cell, str): cellname = cell else: cellname = cell.cellname() if cellname == "vertex": return ([()], array([1.0,])) quad_rule = FIAT.make_quadrature(reference_cell(cell), num_points) return quad_rule.get_points(), quad_rule.get_weights()
def __init__(self, L, order): assert L.ref_el == FIAT.ufc_simplex(1) for ell in L.dual.nodes: assert isinstance(ell, FIAT.functional.PointEvaluation) c = numpy.asarray([list(ell.pt_dict.keys())[0][0] for ell in L.dual.nodes]) num_stages = len(c) Q = FIAT.make_quadrature(L.ref_el, 2*num_stages) qpts = Q.get_points() qwts = Q.get_weights() Lvals = L.tabulate(0, qpts)[0, ] # integrates them all! b = Lvals @ qwts # now for A, which means we have to adjust the interval A = numpy.zeros((num_stages, num_stages)) for i in range(num_stages): qpts_i = qpts * c[i] qwts_i = qwts * c[i] Lvals_i = L.tabulate(0, qpts_i)[0, ] A[i, :] = Lvals_i @ qwts_i Aexplicit = numpy.zeros((num_stages, num_stages)) for i in range(num_stages): qpts_i = 1 + qpts * c[i] qwts_i = qwts * c[i] Lvals_i = L.tabulate(0, qpts_i)[0, ] Aexplicit[i, :] = Lvals_i @ qwts_i self.Aexplicit = Aexplicit V = vander(c, increasing=True) rhs = numpy.array([1.0/(s+1) for s in range(num_stages-1)] + [0]) btilde = numpy.linalg.solve(V.T, rhs) super(CollocationButcherTableau, self).__init__(A, b, btilde, c, order)
def create_quadrature(cell, num_points): """ Generate quadrature rule (points, weights) for given shape with num_points points in each direction. """ if isinstance(cell, int) and cell == 0: return ([()], array([ 1.0, ])) if isinstance(cell, str): cellname = cell else: cellname = cell.cellname() if cellname == "vertex": return ([()], array([ 1.0, ])) quad_rule = FIAT.make_quadrature(reference_cell(cell), num_points) return quad_rule.get_points(), quad_rule.get_weights()