evaluate_basis_all?


13
views
0
9 days ago by
The following does not work (taken from https://fenicsproject.org/qa/8627/how-to-evaluate-basis-function-at-points-of-cell/)


from __future__ import print_function

from dolfin import *
from ffc.fiatinterface import create_quadrature
import ufl
import ffc
from ufl import Argument,AbstractCell,AbstractDomain

n = 10
shape = ufl.quadrilateral
degree = 2
scheme = 'default'
family='DG'
(points, weights) = create_quadrature(str(shape), degree, scheme)
mesh = UnitSquareMesh(n,n)
V = VectorFunctionSpace(mesh=mesh,family=family,degree=degree)
V.element
# family = 'Quadrature'
# quad_element = FiniteElement(family = family,
# cell = shape,
# degree = degree,
# quad_scheme = scheme)
# family='DG'
phi = [Argument(V,p) for p in range(degree)]
# V.extract_sub_space(1)
f = interpolate(Expression('3*x[0]*x[0]*x[1]-2*x[1]*x[1]*x[0]',degree=degree), V)
el = V.element()

# Where to evaluate
x = np.array([0.33, 0.55])

# Find the cell with point
x_point = Point(*x)
cell_id = mesh.bounding_box_tree().compute_first_entity_collision(x_point)
cell = Cell(mesh, cell_id)
coordinate_dofs = cell.get_vertex_coordinates()

# Array for values. Here it is simply a single scalar
values = np.zeros(1, dtype=float)
for i in range(el.space_dimension()):
el.evaluate_basis(i, values, x, coordinate_dofs, cell.orientation())
print (i, values)
Community: FEniCS Project
Please login to add an answer/comment or follow this question.

Similar posts:
Search »