Hello everyone in this community,
I have been trying to solve a heat transfer problem using my image which I project on the mesh.
I followed the method explained in : Manipulating images
The image array contains a property and when I plot it I get as follows. The one on the left is is correct and what I want:
This image is based on the following method:
l=1
mesh = dl.RectangleMesh(dl.Point(0.,0.),dl.Point(1.*l,1.*l), nx, ny)
ph = np.zeros((nx,ny))
def pixel():
for i in range(len(markers[:,0])):
for j in range(len(markers[0,:])):
for k in dic:
if markers[i][j] == k:
ph[i][j] = 1/(dic[k])
break
else:
ph[i][j] = 0.048
return ph
pixel()
class FE_image(UserExpression):
def eval_cell(self, value, x, ufc_cell):
p = Cell(mesh, ufc_cell.index).midpoint()
i, j = int(p[0](nx)), int(p[1](ny))
value[:] = ph[-(j+1), i]
def value_shape(self):
return ()
y = FE_image()
print(y)
V = FunctionSpace(mesh, āCGā, 1)
u0 = project(y, V)
k_func = Function(V)
k_func.assign(u0)
Here ph is the property array and then using the method mentioned in the previous link to assign them to the mesh and later on project it to the mesh space V. k_func is the space with the values which I plot as shown in the previous image.
Now, for my simulation the domain size of 1x1 is pretty big and so I decrease the value of l from 1 to 7e-2 but this resulted in a weird plot of k_func and captured only a part of it which you can see in the right image
I thought this method would first create a mesh with a domain size and number of elements and then assign the array to the mesh but it is not doing that.
I went through other threads but it was pretty different.
Can someone please guide with this or have any other idea of using an image in fenics?
Thank You!