def create_quadrature_points_and_weights(integral_type, cell, degree, rule):
    "Create quadrature rule and return points and weights."
    if integral_type == "cell":
        (points, weights) = create_quadrature(cell, degree, rule)
    elif integral_type == "exterior_facet" or integral_type == "interior_facet":
        # Since quadrilaterals use OuterProductElements, the degree is usually
        # a tuple, though not always. For example, in the constant times dx case
        # the degree is always a single number.
        if cell.cellname() == "quadrilateral" and isinstance(degree, tuple):
            assert len(degree) == 2 and degree[0] == degree[1]
            degree = degree[0]
        (points, weights) = create_quadrature(cellname2facetname[cell.cellname()], degree, rule)
    elif integral_type in ("exterior_facet_top", "exterior_facet_bottom", "interior_facet_horiz"):
        (points, weights) = create_quadrature(cell.facet_horiz, degree[0], rule)
    elif integral_type in ("exterior_facet_vert", "interior_facet_vert"):
        if cell.topological_dimension() == 2:
            # extruded interval, so the vertical facet is a line, not an OP cell
            (points, weights) = create_quadrature(cell.facet_vert, degree[1], rule)
        else:
            (points, weights) = create_quadrature(cell.facet_vert, degree, rule)
    elif integral_type == "vertex":
        (points, weights) = ([()], numpy.array([1.0,])) # TODO: Will be fixed
    elif integral_type == "custom":
        (points, weights) = (None, None)
    else:
        error("Unknown integral type: " + str(integral_type))
    return (points, weights)
示例#2
0
def _init_quadrature(arguments, domain_type, quadrature_degree, quadrature_rule, cellname, facet_cellname):
    "Initialize quadrature for given monomial."
    # Create quadrature rule and get points and weights
    if domain_type == Measure.CELL:
        (points, weights) = create_quadrature(cellname, quadrature_degree, quadrature_rule)
    else:
        (points, weights) = create_quadrature(facet_cellname, quadrature_degree, quadrature_rule)

    return (points, weights)
def _create_quadrature_points_and_weights(domain_type, cell, degree, rule):
    if domain_type == "cell":
        (points, weights) = create_quadrature(cell.cellname(), degree, rule)
    elif domain_type == "exterior_facet" or domain_type == "interior_facet":
        (points, weights) = create_quadrature(cell.facet_cellname(), degree, rule)
    elif domain_type == "point":
        (points, weights) = ([()], numpy.array([1.0,])) # TODO: Will be fixed
    else:
        error("Unknown integral type: " + str(domain_type))
    return (points, weights)
示例#4
0
def _create_quadrature_points_and_weights(domain_type, cell, degree, rule):
    if domain_type == "cell":
        (points, weights) = create_quadrature(cell.cellname(), degree, rule)
    elif domain_type == "exterior_facet" or domain_type == "interior_facet":
        (points, weights) = create_quadrature(cell.facet_cellname(), degree,
                                              rule)
    elif domain_type == "point":
        (points, weights) = ([()], numpy.array([
            1.0,
        ]))  # TODO: Will be fixed
    else:
        error("Unknown integral type: " + str(domain_type))
    return (points, weights)
示例#5
0
def _create_quadrature_points_and_weights(integral_type, cellname,
                                          facet_cellname, degree, rule):
    if integral_type == "cell":
        (points, weights) = create_quadrature(cellname, degree, rule)
    elif integral_type == "exterior_facet" or integral_type == "interior_facet":
        (points, weights) = create_quadrature(facet_cellname, degree, rule)
    elif integral_type == "point":
        (points, weights) = ([()], numpy.array([
            1.0,
        ]))  # TODO: Will be fixed
    elif integral_type == "custom":
        (points, weights) = (None, None)
    else:
        error("Unknown integral type: " + str(integral_type))
    return (points, weights)
    def __init__(self, ufl_element):
        "Create QuadratureElement"

        # Compute number of points per axis from the degree of the element
        degree = ufl_element.degree()
        if degree is None:
            degree = default_quadrature_degree
        scheme = ufl_element.quadrature_scheme()
        if scheme is None:
            scheme = default_quadrature_scheme
        self._quad_scheme = scheme

        # Create quadrature (only interested in points)
        # TODO: KBO: What should we do about quadrature functions that live on ds, dS?
        # Get cell and facet names.
        cellname = ufl_element.cell().cellname()
        #facet_cellname = ufl_element.cell().facet_cellname()
        points, weights = create_quadrature(cellname, degree, self._quad_scheme)

        # Save the quadrature points
        self._points = points

        # Create entity dofs.
        ufc_cell = reference_cell(ufl_element.cell().cellname())
        self._entity_dofs = _create_entity_dofs(ufc_cell, len(points))

        # The dual is a simply the PointEvaluation at the quadrature points
        # FIXME: KBO: Check if this gives expected results for code like evaluate_dof.
        self._dual = [PointEvaluation(ufc_cell, tuple(point)) for point in points]

        # Save the geometric dimension.
        # FIXME: KBO: Do we need to change this in order to integrate on facets?
        self._geometric_dimension = ufl_element.cell().geometric_dimension()
示例#7
0
    def __init__(self, ufl_element):
        "Create QuadratureElement"

        # Compute number of points per axis from the degree of the element
        degree = ufl_element.degree()
        if degree is None:
            degree = default_quadrature_degree
        scheme = ufl_element.quadrature_scheme()
        if scheme is None:
            scheme = default_quadrature_scheme
        self._quad_scheme = scheme

        # Create quadrature (only interested in points)
        # TODO: KBO: What should we do about quadrature functions that live on ds, dS?
        # Get cell and facet names.
        domain, = ufl_element.domains()  # Assuming single domain
        cellname = domain.cell().cellname()
        #facet_cellname = domain.cell().facet_cellname()
        points, weights = create_quadrature(cellname, degree,
                                            self._quad_scheme)

        # Save the quadrature points
        self._points = points

        # Create entity dofs.
        ufc_cell = reference_cell(cellname)
        self._entity_dofs = _create_entity_dofs(ufc_cell, len(points))

        # The dual is a simply the PointEvaluation at the quadrature points
        # FIXME: KBO: Check if this gives expected results for code like evaluate_dof.
        self._dual = [
            PointEvaluation(ufc_cell, tuple(point)) for point in points
        ]

        # Save the geometric dimension.
        # FIXME: KBO: Do we need to change this in order to integrate on facets?
        #        MSA: Not the geometric dimension, but maybe the topological dimension somewhere?
        self._geometric_dimension = domain.geometric_dimension()