Hello,
It appears that after using dolfin.refine()
, my mesh loses its subdomain info, is there anyway to preserve that or at least re-define the subdomain? My example code is shown below, as well as the original mesh with subdomain and the new mesh losing subdomain.
import numpy as np
from dolfin import *
from mshr import *
import matplotlib.pyplot as plt
domain = Rectangle(Point(0., 0.), Point(1., 1.))
domain.set_subdomain(1, Rectangle(Point(0.1,0.1), Point(0.6, .6)))
resolution=10
mesh = generate_mesh(domain, resolution)
mf = MeshFunction("size_t", mesh, 2, mesh.domains())
plt.figure()
plot(mesh,linewidth=0.5)
plot(mf)
plt.savefig('mesh1.png')
plt.show()
cell_markers = MeshFunction("bool", mesh, dim=2)
cell_markers.set_all(False)
for cell in cells(mesh):
p = cell.midpoint()
if p[1] > 0.5:
cell_markers[cell] = True
mesh2 = refine(mesh, cell_markers)
mf2 = MeshFunction("size_t", mesh2, 2, mesh2.domains())
plt.figure()
plot(mesh2,linewidth=0.5)
plot(mf2)
plt.savefig('mesh2.png')
plt.show()