Hello there! Sorry for bothering you guys, but I would like some advices in what I’m doing now. I’m working with the heat equation, the following problem:
And, I’m just trying to apply a delta dirac function in this circle with other boundary conditions. I’ve done the following in fenics:
nx = ny = 8
mesh = UnitSquareMesh(nx, ny)
V = FunctionSpace(mesh, 'P', 1)
class UnitaryCircle(SubDomain):
def inside(self, x, on_boundary):
r = 0.25 # Radius of the circle
return on_boundary and near((x[0]-0.5)**2 + (x[1]-0.5)**2, r**2)
# First boundary equation
u_D = Expression('1 + x[0]*x[0] + alpha*x[1]*x[1] + beta*t',
degree=2, alpha=alpha, beta=beta, t=0)
unitary_circle = UnitaryCircle()
# Second boundary condition (Delta dirac expression)
b = assemble(Constant(1.0))
point_source = PointSource(V, unitary_circle, Constant(1.0))
point_source.apply(b)
# Mark boundary subdomians
circle = CompiledSubDomain("unitary_circle")
left = CompiledSubDomain("near(x[0], side) && on_boundary", side = 0.0)
right = CompiledSubDomain("near(x[0], side) && on_boundary", side = 1.0)
bcl1 = DirichletBC(V, u_D, left)
bcl2 = DirichletBC(V, u_D, right)
bcr = DirichletBC(V, b, circle)
bcs = [bcl1, bcl2, bcr]
...
solve(a == L, u, bcs)
It is not compiling, I’ve got the following error:
Traceback (most recent call last):
File "/home/jandui/Documents/MATH code/testes_3/heat_test.py", line 42, in <module>
b = assemble(Constant(1.0))
File "/usr/lib/petsc/lib/python3/dist-packages/dolfin/fem/assembling.py", line 202, in assemble
dolfin_form = _create_dolfin_form(form, form_compiler_parameters)
File "/usr/lib/petsc/lib/python3/dist-packages/dolfin/fem/assembling.py", line 64, in _create_dolfin_form
raise TypeError("Invalid form type %s" % (type(form),))
TypeError: Invalid form type <class 'dolfin.function.constant.Constant'>
I would like to know, please if:
-
Is it correct the way I stated the subdomains and the functions? ;
-
Is it correct the way I stated the Delta Dirac Function? I Basically would like to have an “impulse of heat” in this subdomain, and I tired doing it using the Delta Dirac.
-
To state subdomains problem using different spaces, we need to interpolate all functions at the same space ?