コード例 #1
0
def _init_table(arguments, domain_type, points, facet0, facet1):
    """Initialize table of basis functions and their derivatives at
    the given quadrature points for each element."""

    # Compute maximum number of derivatives for each element
    num_derivatives = {}
    for v in arguments:
        ufl_element = v.element
        order = len(v.derivatives)
        if ufl_element in num_derivatives:
            num_derivatives[ufl_element] = max(order, num_derivatives[ufl_element])
        else:
            num_derivatives[ufl_element] = order

    # Call FIAT to tabulate the basis functions for each element
    table = {}
    for (ufl_element, order) in num_derivatives.items():
        fiat_element = create_element(ufl_element)
        if domain_type == Measure.CELL:
            table[(ufl_element, None)] = fiat_element.tabulate(order, points)
        elif domain_type == Measure.EXTERIOR_FACET:
            x = map_facet_points(points, facet0)
            table[(ufl_element, None)] = fiat_element.tabulate(order, x)
        elif domain_type == Measure.INTERIOR_FACET:
            x0 = map_facet_points(points, facet0)
            x1 = map_facet_points(points, facet1)
            table[(ufl_element, "+")] = fiat_element.tabulate(order, x0)
            table[(ufl_element, "-")] = fiat_element.tabulate(order, x1)

    return table
コード例 #2
0
def _init_table(arguments, integral_type, points, facet0, facet1):
    """Initialize table of basis functions and their derivatives at
    the given quadrature points for each element."""

    # Compute maximum number of derivatives for each element
    num_derivatives = {}
    for v in arguments:
        ufl_element = v.element
        order = len(v.derivatives)
        if ufl_element in num_derivatives:
            num_derivatives[ufl_element] = max(order,
                                               num_derivatives[ufl_element])
        else:
            num_derivatives[ufl_element] = order

    # Call FIAT to tabulate the basis functions for each element
    table = {}
    for (ufl_element, order) in num_derivatives.items():
        fiat_element = create_element(ufl_element)
        if integral_type == Measure.CELL:
            table[(ufl_element, None)] = fiat_element.tabulate(order, points)
        elif integral_type == Measure.EXTERIOR_FACET:
            x = map_facet_points(points, facet0)
            table[(ufl_element, None)] = fiat_element.tabulate(order, x)
        elif integral_type == Measure.INTERIOR_FACET:
            x0 = map_facet_points(points, facet0)
            x1 = map_facet_points(points, facet1)
            table[(ufl_element, "+")] = fiat_element.tabulate(order, x0)
            table[(ufl_element, "-")] = fiat_element.tabulate(order, x1)

    return table
コード例 #3
0
    def _generate_affine_map(self):
        """Generate psi table for affine map, used by spatial coordinate to map
        integration point to physical element."""

        # TODO: KBO: Perhaps it is better to create a fiat element and tabulate
        # the values at the integration points?
        f_FEA = format["affine map table"]
        f_ip  = format["integration points"]

        affine_map = {1: lambda x: [1.0 - x[0],               x[0]],
                      2: lambda x: [1.0 - x[0] - x[1],        x[0], x[1]],
                      3: lambda x: [1.0 - x[0] - x[1] - x[2], x[0], x[1], x[2]]}

        num_ip = self.points
        w, points = self.quad_weights[num_ip]

        if self.facet0 is not None:
            points = map_facet_points(points, self.facet0)
            name = f_FEA(num_ip, self.facet0)
        elif self.vertex is not None:
            error("Spatial coordinates (x) not implemented for point measure (dP)") # TODO: Implement this, should be just the point.
            #name = f_FEA(num_ip, self.vertex)
        else:
            name = f_FEA(num_ip, 0)

        if name not in self.unique_tables:
            self.unique_tables[name] = array([affine_map[len(p)](p) for p in points])

        if self.coordinate is None:
            ip = f_ip if num_ip > 1 else 0
            r = None if self.facet1 is None else "+"
            self.coordinate = [name, self.gdim, ip, r]
コード例 #4
0
ファイル: tabulate_basis.py プロジェクト: afqueiruga/ffc
def _map_entity_points(cellname, tdim, points, entity_dim, entity):
    # Not sure if this is useful anywhere else than in _tabulate_psi_table!
    if entity_dim == tdim:
        return points
    elif entity_dim == tdim - 1:
        return map_facet_points(points, entity)
    elif entity_dim == 0:
        return (reference_cell_vertices(cellname)[entity], )
コード例 #5
0
ファイル: tabulate_basis.py プロジェクト: FEniCS/ffc
def _map_entity_points(cellname, tdim, points, entity_dim, entity):
    # Not sure if this is useful anywhere else than in _tabulate_psi_table!
    if entity_dim == tdim:
        assert entity == 0
        return points
    elif entity_dim == tdim-1:
        return map_facet_points(points, entity, cellname)
    elif entity_dim == 0:
        return (reference_cell_vertices(cellname)[entity],)
コード例 #6
0
def _map_entity_points(cell, points, entity_dim, entity):
    # Not sure if this is useful anywhere else than in _tabulate_psi_table!
    tdim = cell.topological_dimension()
    if entity_dim == tdim:
        return points
    elif entity_dim == tdim-1:
        return map_facet_points(points, entity)
    elif entity_dim == 0:
        return (reference_cell_vertices(cell.cellname())[entity],)
コード例 #7
0
def _map_entity_points(cell, points, entity_dim, entity):
    # Not sure if this is useful anywhere else than in _tabulate_psi_table!
    tdim = cell.topological_dimension()
    if entity_dim == tdim:
        return points
    elif entity_dim == tdim - 1:
        return map_facet_points(points, entity)
    elif entity_dim == 0:
        return (reference_cell_vertices(cell.cellname())[entity], )
コード例 #8
0
ファイル: representationutils.py プロジェクト: FEniCS/ffc
def map_integral_points(points, integral_type, cell, entity):
    """Map points from reference entity to its parent reference cell."""
    tdim = cell.topological_dimension()
    entity_dim = integral_type_to_entity_dim(integral_type, tdim)
    if entity_dim == tdim:
        assert points.shape[1] == tdim
        assert entity == 0
        return numpy.asarray(points)
    elif entity_dim == tdim - 1:
        assert points.shape[1] == tdim - 1
        return numpy.asarray(map_facet_points(points, entity, cell.cellname()))
    elif entity_dim == 0:
        return numpy.asarray([reference_cell_vertices(cell.cellname())[entity]])
    else:
        error("Can't map points from entity_dim=%s" % (entity_dim,))
コード例 #9
0
def map_integral_points(points, integral_type, cell, entity):
    """Map points from reference entity to its parent reference cell."""
    tdim = cell.topological_dimension()
    entity_dim = integral_type_to_entity_dim(integral_type, tdim)
    if entity_dim == tdim:
        assert points.shape[1] == tdim
        assert entity == 0
        return numpy.asarray(points)
    elif entity_dim == tdim - 1:
        assert points.shape[1] == tdim - 1
        return numpy.asarray(map_facet_points(points, entity, cell.cellname()))
    elif entity_dim == 0:
        return numpy.asarray([reference_cell_vertices(cell.cellname())[entity]])
    else:
        raise RuntimeError("Can't map points from entity_dim=%s" % (entity_dim, ))