My geometry has four submeshes and looks like
I need to solve a hyperelasticity problem on the outer 3 meshes and a fluid mechanics problem on the innermost mesh.
I extracted the four submeshes with the following commands:
mesh1 = SubMesh(mesh,cf,8)
mesh2 = SubMesh(mesh,cf,5)
mesh3 = SubMesh(mesh,cf,6)
mesh4 = SubMesh(mesh,cf,7)
I want to introduce a single VectorFunctionSpace
on meshes 2, 3, and 4 and another VectorFunctionSpace
on mesh 5. I do not want to club the outer meshes into a single mesh since they have different material properties. But VectorFunctionSpace
takes only one mesh as an argument. How can I assign a single VectorFunctionSpace
to multiple submeshes?
Another way I thought of doing this is to introduce a VectorFunctionSpace
, V, on the whole mesh, introduce the variable of interest, u=Function(V)
, assign value 0 to u on the innermost mesh when solving the hyperelasticity problem on the outer 3 meshes. But I am having trouble with the assignment. The following set of commands
class expr(UserExpression):
def __init__(self, mesh, marker,f1, **kwargs):
super(expr, self).__init__(kwargs)
self.mesh = mesh
self.marker = marker
self.f1 = f1
def eval_cell(self, value, x, ufc_cell):
cell = Cell(self.mesh, ufc_cell.index)
if self.marker[cell] == 8: # The innermost mesh is tagged 8
value[0] = 0
else:
value[0] = self.f1(x)
def value_shape(self):
return ()
new_u = expr(mesh, cf, u, degree = 0)
new_u1 = project(new_u, V)
produces the error:
ValueError: setting an array element with a sequence.
How to overcome this error?