Plotting two solutions on two domains

More
4 years 6 months ago #2680 by grinver
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?
More
4 years 6 months ago #2681 by mneunteufel
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
Code:
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

File Attachment:

File Name: plot_two_domains.py
File Size:1 KB
Time to create page: 0.100 seconds