How to create test and trial functions for MixedFunctionSpace?

Hi,

First of all, you mention using various methods and getting various errors without more details. That might be helpful for people trying to reproduce the issue.

To answer the main question, the way you define test and trial functions from a MixedFunctionSpace is correct.

Some comments on your code :
1- I recommend using MeshView instead of SubMesh, using directly the cell MeshFunction regions :

submeshfluid = MeshView.create(regions, 1)
submeshsolid = MeshView.create(regions, 2)

2- I don’t see why do you define fluid_regions and solid_regions. Since these MeshFunctions are both set to zero, it doesn’t make sense in the Measures dxf and dxs you define later. Plus note that this way of define the Measure is deprecated (you should get a warning saying exactly that). If you want to define the Measures corresponding to these submeshes, you should use :

dxf = Measure("dx", domain=submeshfluid)
dxs = Measure("dx", domain=submeshsolid)

Same remark for the ds measures for the submeshes boundaries :

dsf = Measure("ds", domain=submeshfluid, subdomain_data = fluid_boundaries)
dss = Measure("ds", domain=submeshsolid, subdomain_data = solid_boundaries)

3- The Jacobian has to be defined by blocks. Note that it can be automatically computed by the solve function using solve(F == 0, w, bcs), but if you want to define it manually then I suggest you have a look to this recent post.

2 Likes