hi all,
im trying to create a laminated rode that is being defined by two subdomains, each domain for each material. those materials are defer by their moduoel young. this rode is being stretched on the left side of the rode. i want to represent this rode in paraview and see in different color each material. how can i achieve that part? what i specifically need in the part of the two color plotting , the rest i got
the relevant parts of the subdomains
class Omega_0(SubDomain):
def inside(self, x, on_boundary):
return x[1] <= 0.5 + DOLFIN_EPS
class Omega_1(SubDomain):
def inside(self, x, on_boundary):
return x[1] > 0.5 - DOLFIN_EPS
subdomain_0 = Omega_0()
subdomain_1 = Omega_1()
materials = MeshFunction(‘size_t’, mesh, mesh.topology().dim())
materials.set_all(0)
subdomain_1.mark(materials, 1)
class Boundaryleft(SubDomain):
def inside(self, x, on_boundary):
return on_boundary and near(x[0], 0, DOLFIN_EPS)
class Boundaryright(SubDomain):
def inside(self, x, on_boundary):
return on_boundary and near(x[0], 1, DOLFIN_EPS)
ADDED
facets = MeshFunction(“size_t”, mesh, 2)
facets.set_all(0)
Boundaryleft().mark(facets, 1)
Boundaryright().mark(facets, 2)
class K(fe.UserExpression):
def init(self, materials, k_0, k_1, **kwargs):
super().init(**kwargs)
self.materials = materials
self.k_0 = k_0
self.k_1 = k_1
def eval_cell(self, values, x, cell):
if self.materials[cell.index] == 0:
values[0] = self.k_0
else:
values[0] = self.k_1
kappa = K(materials, 1.0e7, 2.0e4, degree=0)
File(“Materials.pvd”)<< materials
vtkfile_subdomains = File(‘subdomains.pvd’)
vtkfile_subdomains << materials