Hi,
A way to do this is defining a unsigned int cell function in order to carachterize the subdomains and then assing each property to its respective subdomains with the class "DiscontinuosTenor" shown above (i took this class from other question at this forum). So, lets say the material 1 have a tensor (or a constant in your case, this is more general) D1 and the material 2 have a tensor D2, the python code to define the domain, mesh and the circle can be as follows:
# class for cicle subdomain
class Circle(SubDomain):
def inside(self, x, on_boundary):
if x[0]*x[0] + y[0]*y[0] < pow(radius,2)
# class for assign tensors to its respective sub-domains
class DiscontinuousTensor(Expression):
def __init__(self, cell_function, tensors):
self.cell_function = cell_function
self.coeffs = tensors
def value_shape(self):
return (2,2)
def eval_cell(self, values, x, cell):
subdomain_id = self.cell_function[cell.index]
local_coeff = self.coeffs[subdomain_id]
local_coeff.eval_cell(values, x, cell)
radius = 0.2
circle = Circle()
domain = mshr.Rectangle(Point(0,0), Point(6,3))-mshr.Circle(Point(3,1.5), 0.2)
mesh = mshr.generate_mesh(domain, 30)
V = FunctionSpace(mesh, 'Lagrange', 1)
# create cell function to mark subdomains of material 2
cf = CellFunction("size_t", mesh)
circle.mark(cf, 1)
# tensors for each material
D1 = Constant(((1, 0),
(0, 1)))
D2 = Constant(((2 , 0.0,),
(0.0, 2)))
C = DiscontinuousTensor(cf, [D1, D2]) # Assign tensors where they belongs
I hope this can help you.