Hey everyone, I am relatively new to Fenics I don’t really know my way around it.
I have a question about my UserExpression:
class circle_source(UserExpression):
def __init__(self, radius, center, coeff, **kwargs):
super().__init__(**kwargs)
self._radius = radius
self._center = center
self._coeff = coeff
def eval(self, value, x):
if (x[0] - self._center[0])**2 + (x[1] - self._center[1])**2 < self._radius**2:
value = self._coeff
else:
value = 0.0
def value_shape(self):
return ()
Now if I project this on my finite element space and print the vertex values or plot it, they are all pretty close to 0 namely something like 10^(-320), and I don’t know why that is so.
domain = Circle(Point(0.,0.),1.0,60)
mesh = generate_mesh(domain, 10, "cgal")
V = FunctionSpace(mesh, 'CG', 1)
radius = 0.45
center = [0.2,0.5]
coeff = 3.0
coef = circle_source(radius, center, coeff)
coef_FEM = project(coef, V)
plot(coef_FEM)
Does anyone know, what I am doing wrong with my expression.