hi all,
im trying to create a rod with to different E and its seems to be that my rod is being set with only the second E that i set
this is my mesh and materials definition
length, width, height = 1.0, 0.2, 0.2 # Dimensions of the rod
num_elements = 12 # Number of elements along each dimension
E1, E2 = 4E8, 8E6 # Young's moduli for the two halves of the rod
# Create a 3D mesh for the rod
mesh = BoxMesh(Point(0, 0, 0), Point(length, width, height), num_elements, num_elements, num_elements)
# Define boundary
class Omega_0(SubDomain):
def inside(self, x, on_boundary):
return x[0] <= length/2 + DOLFIN_EPS
class Omega_1(SubDomain):
def inside(self, x, on_boundary):
return x[0] > length/2 - DOLFIN_EPS
subdomain_0 = Omega_0()
subdomain_1 = Omega_1()
materials = MeshFunction('size_t', mesh, mesh.topology().dim())
materials.set_all(0)
subdomain_0.mark(materials, 1)
subdomain_1.mark(materials, 2)
'''
this the userexperssion class
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
def value_shape(self):
return ()
E_global = K(materials, E1, E2, degree=0)
and it seems to be that my entire rod is set with E2 , any idea why?