Plotting two solutions on two domains

Hello,

I couldn’t find documentation for the following situation, so any feedback is appreciated.

Let’s say I have a mesh Omega, divided in two subdomains Omega1 and Omega2. Then I decide to solve for u1 on Omega1 (defining fes1 on material of Omega1) and for u2 on Omega2 (defining fes2 on material of Omega2).
I am able to plot u1 and u2 separately, but I want to be able to plot u1 and u2 at the same time to see their difference at the interface for a convergence scheme I am studying, preferably restricting each solution to its respective subdomain. Is something like this possible?

Hi grinver,

assume that u1 lives on the subdomain “left_dom” and u2 on “right_dom”. Then you can combine both as one CoefficientFunction by

u = CoefficientFunction( [u1 if mat == "left_dom" else u2 for mat in mesh.GetMaterials()] ) Draw(u, mesh, "u")

Attached you’ll find a minimal example.

Best
Michael

https://ngsolve.org/media/kunena/attachments/889/plot_two_domains.py

Attachment: plot_two_domains.py