Esempio n. 1
0
File: fem.py Progetto: jmv2009/tsfc
 def jacobian_at(self, point):
     ps = PointSingleton(point)
     expr = Jacobian(self.mt.terminal.ufl_domain())
     assert ps.expression.shape == (
         expr.ufl_domain().topological_dimension(), )
     if self.mt.restriction == '+':
         expr = PositiveRestricted(expr)
     elif self.mt.restriction == '-':
         expr = NegativeRestricted(expr)
     config = {"point_set": PointSingleton(point)}
     config.update(self.config)
     context = PointSetContext(**config)
     expr = self.preprocess(expr, context)
     return map_expr_dag(context.translator, expr)
Esempio n. 2
0
def translate_cellorigin(terminal, mt, ctx):
    domain = terminal.ufl_domain()
    coords = SpatialCoordinate(domain)
    expression = construct_modified_terminal(mt, coords)
    point_set = PointSingleton((0.0,) * domain.topological_dimension())

    config = {name: getattr(ctx, name)
              for name in ["ufl_cell", "precision", "index_cache"]}
    config.update(interface=ctx, point_set=point_set)
    context = PointSetContext(**config)
    return context.translator(expression)
Esempio n. 3
0
File: fem.py Progetto: jmv2009/tsfc
 def detJ_at(self, point):
     expr = JacobianDeterminant(self.mt.terminal.ufl_domain())
     if self.mt.restriction == '+':
         expr = PositiveRestricted(expr)
     elif self.mt.restriction == '-':
         expr = NegativeRestricted(expr)
     config = {"point_set": PointSingleton(point)}
     config.update(self.config)
     context = PointSetContext(**config)
     expr = self.preprocess(expr, context)
     return map_expr_dag(context.translator, expr)
Esempio n. 4
0
File: fem.py Progetto: peide/tsfc
    def physical_edge_lengths(self):
        expr = ufl.classes.CellEdgeVectors(self.mt.terminal.ufl_domain())
        if self.mt.restriction == '+':
            expr = PositiveRestricted(expr)
        elif self.mt.restriction == '-':
            expr = NegativeRestricted(expr)

        expr = ufl.as_vector([ufl.sqrt(ufl.dot(expr[i, :], expr[i, :])) for i in range(3)])
        expr = preprocess_expression(expr)
        config = {"point_set": PointSingleton([1/3, 1/3])}
        config.update(self.config)
        context = PointSetContext(**config)
        return map_expr_dag(context.translator, expr)
Esempio n. 5
0
def factor_point_set(product_cell, product_dim, point_set):
    """Factors a point set for the product element into a point sets for
    each subelement.

    :arg product_cell: a TensorProductCell
    :arg product_dim: entity dimension for the product cell
    :arg point_set: point set for the product element
    """
    assert len(product_cell.cells) == len(product_dim)
    point_dims = [
        cell.construct_subelement(dim).get_spatial_dimension()
        for cell, dim in zip(product_cell.cells, product_dim)
    ]

    if isinstance(point_set, TensorPointSet):
        # Just give the factors asserting matching dimensions.
        assert len(point_set.factors) == len(point_dims)
        assert all(ps.dimension == dim
                   for ps, dim in zip(point_set.factors, point_dims))
        return point_set.factors

    # Split the point coordinates along the point dimensions
    # required by the subelements.
    assert point_set.dimension == sum(point_dims)
    slices = TensorProductCell._split_slices(point_dims)

    if isinstance(point_set, PointSingleton):
        return [PointSingleton(point_set.point[s]) for s in slices]
    elif isinstance(point_set, PointSet):
        # Use the same point index for the new point sets.
        result = []
        for s in slices:
            ps = PointSet(point_set.points[:, s])
            ps.indices = point_set.indices
            result.append(ps)
        return result

    raise NotImplementedError("How to tabulate TensorProductElement on %s?" %
                              (type(point_set).__name__, ))