This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

How to match the nodes at the boundaries of two different domains

+2 votes

Hi
I need to mesh two different domains separately and match the nodes at the boundaries of two domains.

I wrote a simple code:

from dolfin import *
import mshr

# Domain
domain1 = mshr.Rectangle(Point(2,4.5), Point(8,5.5))

domain2 = mshr.Rectangle(Point(0,0), Point(10,10))\
          - mshr.Rectangle(Point(2,4.5), Point(8,5.5))

# Mesh
mesh1 = mshr.generate_mesh(domain1, 20)
mesh2 = mshr.generate_mesh(domain2, 20)

# Build multimesh
multimesh = MultiMesh()
multimesh.add(mesh1)
multimesh.add(mesh2)
multimesh.build()

plot(mesh1)
plot(mesh2)

interactive()

Now I can plot the meshes for different domains :
Domain.1:
enter image description here

Domain.2:
enter image description here

But:
1- How can I match (make coincident) the nodes of the domain.1 and domain.2 at the boundaries of the domain.1 and domain.2?
2- How can I plot the mesh for the domain.1 and domain.2 in one figure?

After all I expect to get something like this:
enter image description here

Does anybody know how I can do it in FEniCS?
Thanks

closed with the note: The issue was resolved
asked Jun 5, 2017 by Leo FEniCS Novice (840 points)
closed Jun 6, 2017 by Leo

Maybe you can add markers to the subdomains, but it really depends on what you want to do, so maybe you can give more information on your problem. Docs for a reference: https://fenicsproject.org/olddocs/dolfin/1.4.0/python/demo/documented/subdomains/python/documentation.html

Hi
Thanks for your response. I used the same idea and resolved this issue:

from dolfin import *

mesh = RectangleMesh(Point(0.0, 0.0), Point(0.1, 0.1), 50, 50)

subdomain = CompiledSubDomain("x[1] > 0.04 && x[1] < 0.06 && x[0] > 0.025 && x[0] < 0.075")
mf = MeshFunction("size_t", mesh, 2)
mf.set_all(0)
subdomain.mark(mf, 1)
plot(mf, interactive = True)

Here is the results that is what I expected to get:
enter image description here

Great, then please close the question. Best regs.

...