Determining whether Mixed Element or Mixed Function

Hello,

I am working on vibroacoustic simulation where elastic plate and air domain are coupled. After doing some research, I’ve noticed that there are two ways to define test functions and trial functions for each domain: one is by using mixed element, and the other one is by using mixed function.

I have tried to find some information regarding how to decide which approach to take, but I couldn’t, and I am wondering if anyone could clarify which approach is suitable or advantageous for which case.

Thank you in advance!!

The mixedelement will merge everything into a single dofmap, making the access to do efficient block preconditioning harder.

If you use the ufl.MixedFunctionSpace you can get ufl to set up a block structured problem that one can exploit the structure (see for instance:
SNES solver interface for standard, block and nest systems by jorgensd · Pull Request #3648 · FEniCS/dolfinx · GitHub) or the tests that have changed in that PR.

MixedFunctionSpace is also very useful when you have function spaces living on different meshes (a mesh and submesh of entities of the original mesh).

2 Likes

Thank you, dokken!!

It seems like I should probably use mixed functionspace since it’s easier to access each block, and also I am dealing with different meshes.

Now, my current understanding is that mixed functionspace is simpy superior to mixedelement, but is there cases where mixedelement is actually advantageous, such as, for instance, the performance for less complicated models on a single mesh?

Thank you in advance for your advice!!

The current API, pre the aforementioned pull request (and a similar one for LinearProblem) is easier for mixedelement than for mixedfunctionspace.

It will hopefully change soon and then I think for most cases I would use mixedfunctionspace.

There might be a few problems (with direct solvers on small grids) where the data locality in the mixed map might result in a speedup

Dear dokken,

Thank you for the very insightful answer to my question.
I will pay some attention in choosing which one to use for the time being, and I am looking forward to the future updates as well.

Thank you as always!!

@dokken
Dear dokken,

I have a follow-up question regarding the use of Mixed Element and Mixed Function.
I am modifying the below code using Mixed Function instead of Mixed Element.

Upon calling fem.form, this error rises: ArityMismatch: Adding expressions with non-matching form arguments

Below is the simplified snippet of the code where Mixed Function is defined and error rises.

deg=2
elw = basix.ufl.element("Lagrange", domain.topology.cell_name(), deg)
Vw = fem.functionspace(domain, elw)
elt = basix.ufl.element("Lagrange", domain.topology.cell_name(), deg, shape=(2,))
Vpt = fem.functionspace(domain, elt)
V=ufl.MixedFunctionSpace(Vw,Vpt)
w,u=ufl.TrialFunctions(V)
w_,u_=ufl.TestFunctions(V)

m_form = ufl.inner(w,w_)*dx + ufl.inner(u[0],u_[0])*dx
fem.form(m_form)

Would this be a case where only Mixed Element is allowed, or is there a way to do with Mixed Function?

Thank you in advance.

You have to use ufl.extract_block(m_form) prior to calling fem.form(…)

1 Like

Thank you very much–ufl.extract_blocks worked perfect!!