Hi, I am updating my code from 2017.2 to 2019.1. I am unable to assign expression in user-defined expression. The same works in 2017.2. Now sure how can i resolve this issue. please find MWC.
from fenics import *
mesh = Mesh('./Mesh/mesh_bimat_int5t_half.xml')
materials = MeshFunction("size_t", mesh, './Mesh/mesh_bimat_int5t_half_physical_region.xml')
Ep=1e3;
EI=2e3;
Ec = Expression('pow(x[0],2)', degree=1)
# define material properties
class K(UserExpression):
def __init__(self, materials, k_0, k_1, k_2, **kwargs):
super().__init__(**kwargs)
self.materials = materials
self.k_0 = k_0
self.k_1 = k_1
self.k_2 = k_2
def eval_cell(self, values, x, cell):
if self.materials[cell.index] ==3:
self.k_2.eval_cell(values,x,cell)
elif self.materials[cell.index] == 1:
values[0] = self.k_0
else:
values[0] = self.k_1
E = K(materials, Ep, EI, Ec, degree=1)
Gc = K(materials, Gcp, GcI, Gcc, degree=1)
nu = K(materials, nup, nuI, nuc, degree=1)
Vp = FunctionSpace(mesh,'DG',0)
E = project(E,Vp)
Gc = project(Gc,Vp)
nu = project(nu,Vp)
#plot(kappa,interactive=True)
#ph_f= File('./Results/materials.pvd')
phiE = File('E.pvd')
phiE << project(E, FunctionSpace(mesh, 'DG', 0))