Hi, I am not able to solve the following error:
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
/tmp/ipykernel_2676/3462195073.py in <module>
5 dw = Constant(0.0005) #5e-4
6 w += dw
----> 7 bcs = [DirichletBC(V.sub(1), Constant(0.), bottom), DirichletBC(V.sub(1), w, top)]
8 u = Function(V)
9 solve(a == l, u, bcs)
/usr/lib/petsc/lib/python3/dist-packages/dolfin/fem/dirichletbc.py in __init__(self, *args, **kwargs)
74 if not hasattr(args[1], "_cpp_object"):
75 if isinstance(args[1], ufl.classes.Expr):
---> 76 expr = project(args[1], args[0]) # FIXME: This should really be interpolaton (project is expensive)
77 else:
78 expr = Constant(args[1])
/usr/lib/petsc/lib/python3/dist-packages/dolfin/fem/projection.py in project(v, V, bcs, mesh, function, solver_type, preconditioner_type, form_compiler_parameters)
130
131 # Assemble linear system
--> 132 A, b = assemble_system(a, L, bcs=bcs,
133 form_compiler_parameters=form_compiler_parameters)
134
/usr/lib/petsc/lib/python3/dist-packages/dolfin/fem/assembling.py in assemble_system(A_form, b_form, bcs, x0, form_compiler_parameters, add_values, finalize_tensor, keep_diagonal, A_tensor, b_tensor, backend)
428 assembler.assemble(A_tensor, b_tensor, x0)
429 else:
--> 430 assembler.assemble(A_tensor, b_tensor)
431
432 return A_tensor, b_tensor
RuntimeError:
*** -------------------------------------------------------------------------
*** DOLFIN encountered an error. If you are not able to resolve this issue
*** using the information listed below, you can ask for help at
***
*** fenics-support@googlegroups.com
***
*** Remember to include the error message listed below and, if possible,
*** include a *minimal* running example to reproduce the error.
***
*** -------------------------------------------------------------------------
*** Error: Unable to successfully call PETSc function 'MatSetValuesLocal'.
*** Reason: PETSc error code is: 63 (Argument out of range).
*** Where: This error was encountered inside ./dolfin/la/PETScMatrix.cpp.
*** Process: 0
***
*** DOLFIN version: 2019.2.0.dev0
*** Git changeset: ubuntu
*** -------------------------------------------------------------------------
Here is the Minimum Working Example -
from dolfin import *
from mshr import *
import matplotlib.pyplot as plt
domain= Rectangle(Point(0.,0.), Point(1., 1.))
mesh = generate_mesh(domain, 30)
E = Constant(200e9) #E = 200 GPa
nu = Constant(0.3)
model = "plane_stress"
mu = E/2/(1+nu)
lmbda = E*nu/(1+nu)/(1-2*nu)
if model == "plane_stress":
lmbda = 2*mu*lmbda/(lmbda+2*mu)
def eps(v):
return sym(grad(v))
def sigma(v):
return lmbda*tr(eps(v))*Identity(2) + 2.0*mu*eps(v)
f = 0.
f = Constant((0, f))
V = VectorFunctionSpace(mesh, 'CG', 1)
W = FunctionSpace(mesh, 'DG', 0)
du = TrialFunction(V)
d = du.geometric_dimension()
u_ = TestFunction(V)
a = inner(sigma(du), eps(u_))*dx
l = inner(f, u_)*dx
def bottom(x, on_boundary):
return near(x[1], 0.)
def top(x, on_boundary):
return near(x[1], 1.)
w = Constant(0.001) #1e-3
bcs = [DirichletBC(V.sub(1), Constant(0.), bottom), DirichletBC(V.sub(1), w, top)]
u = Function(V)
solve(a == l, u, bcs)
u_magnitude = sqrt(dot(u, u))
u_magnitude = project(u_magnitude, W)
print('max u:', u_magnitude.vector().max())
s = sigma(u) - (1./3)*tr(sigma(u))*Identity(d) # deviatoric stress
von_Mises = sqrt(3./2*inner(s, s))
von_Mises = project(von_Mises, W)
von_Mises.vector().max()
print('max vonmises:', von_Mises.vector().max())
#code
sig0 = 450e6 # yield stress = 450 MPa
while von_Mises.vector().max() < sig0:
dw = Constant(0.0005) #5e-4
w += dw
bcs = [DirichletBC(V.sub(1), Constant(0.), bottom), DirichletBC(V.sub(1), w, top)]
u = Function(V)
solve(a == l, u, bcs)
u_magnitude = sqrt(dot(u, u))
u_magnitude = project(u_magnitude, W)
print('max u:', u_magnitude.vector().max())
s = sigma(u) - (1./3)*tr(sigma(u))*Identity(d) # deviatoric stress
von_Mises = sqrt(3./2*inner(s, s))
von_Mises = project(von_Mises, W)
print('max vonmises:',von_Mises.vector().max())
Kindly guide me regarding the above.
Thank You.