Dear all,
I try to add heat flux(Neumann condition) to a surface, while this suface is large and I only want to input heat flux to specific area.
Previous, I have successfully add Dirchlet boundary conditions, as shown in below
bc_list = []
for i, (x_c, y_c) in enumerate(zip(x_co, y_co), start=1):
var_name = f"bc_facets{i}"
tag= mesh.locate_entities_boundary(
domain, fdim, lambda x: (x[0]-x_c)**2 + (x[1]-y_c)**2 <= 324 )
globals()[var_name] = tag
bc_list.append(globals()[var_name])
# rubbing elements
bc_disc = mesh.locate_entities_boundary(
domain, fdim , lambda x: np.isclose(x[2], 20) )
bc_all = find_common_e(bc_disc, bc_list)
Through above codes, I can add dirichlet boundary condition. My variation form like below:
a = (rho*c)/dt * u * v *dx + k* dot(grad(u), grad(v)) *dx
- k * dot(grad(u)*v, n)*ds
# g is the heat flux, should applied to specific areas of the surface(21)
L = f *v *dx + (rho*c)/dt * u_n * v * dx + g* v *ds(21)
From tutorial about Combining Dirichlet and Neumann conditions, the neumann condition g can be expressed as
x = SpatialCoordinate(mesh)
g = -4 * x[1]
f = Constant(mesh, default_scalar_type(-6))
L = f * v * dx - g * v * ds
Then, how should I define my g? which should fuifill requirement like
g = 100 * ( (x[0]+214)**2 + (x[1]+27)**2 <= 324 && x[2] ==20 )
But above g, the python is not support.
Thanks for your help!