Hi,
I am trying to test my code for this aim I am using the method of manufactured solution as follows:
# the exact solution
Ue_x = Expression('Coef_u0*(1 + pow(sin(x[0]/R), 2) * pow(sin(x[1]/R), 2))', Coef_u0 = Coef_u0,
R = R, degree = basedegree + degreeCG) # x-component of displacment
Ue_y = Expression('Coef_u0*(1 + pow(sin(x[0]/R), 2) * pow(sin(x[1]/R), 2))', Coef_u0 = Coef_u0,
R = R, degree = basedegree + degreeCG) # y-component of displacment
Ke_1 = Expression(("(2*Coef_u0/R)*sin(x[0]/R)*sin(x[0]/R)*pow(sin(x[1]/R),2)","(2*Coef_u0/R)*sin(x[1]/R)*sin(x[1]/R)*pow(sin(x[0]/R),2)"), R = R, Coef_u0 = Coef_u0,
degree = basedegree + degreeCurl) # the first row of displacement gradient
Ke_2 = Expression(("(2*Coef_u0/R)*sin(x[0]/R)*sin(x[0]/R)*pow(sin(x[1]/R),2)","(2*Coef_u0/R)*sin(x[1]/R)*sin(x[1]/R)*pow(sin(x[0]/R),2)"), R = R, Coef_u0 = Coef_u0,
degree = basedegree + degreeCurl) # the second row of displacement gradient
def Stress_ES(Ke_1,Ke_2):
def_grad = as_tensor([[1.0 + Ke_1[0], Ke_1[1]], [Ke_2[0], 1.0 + Ke_2[1]]]) # deformation gradient
return mu*def_grad + (2*lam*ln(det(def_grad.T*def_grad)) - mu)*inv(def_grad.T)
Pe_1 = Stress_ES(Ke_1,Ke_2)[0,:] # 1st row of stress
Pe_2 = Stress_ES(Ke_1,Ke_2)[1,:] # 2nd row of stress
PP = Stress_ES(Ke_1,Ke_2)
def Body_f(PP):
return -div(PP)
Be_x = Body_f(PP)[0] # x-component of the body force for the exact solution
Be_y = Body_f(PP)[1] # y-component of the body force for the exact solution
This is a 2D problem which I am trying to calculate the error regarding Displacement (U), Displacement Gradient (K) and Stress (P ) but I am getting this error:
ufl.log.UFLException: Cannot determine geometric dimension from expression.
The source of error which comes to my mind might be:
- The way I have defined Exact Solution for my stress:
Pe_1 and Pe_2
- The way I am extracting row one and row two of my body force:
Be_x = Body_f(PP)[0] and Be_y = Body_f(PP)[1]
Thank you in advance.