This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Membrane held at boundary under gravity

0 votes

Hi,

I've been having trouble getting this modification of the linear elasticity example found here working.

The Code:

from fenics import*
import time

# variables
rho = 1
g = 9.81
p = 1
W1 = 1/2 # where W is neo hookean
# create mesh
comm = mpi_comm_world()
mesh = UnitDiscMesh(comm, 20, 2, 3)

# create function space  
V = VectorFunctionSpace(mesh, 'Lagrange', 1)

# boundary condition
def boundary(x, on_boundary):
    return on_boundary
bc = DirichletBC(V, (0, 0, 0), boundary)

# define cauchy stress and strain
def epsilon(u):
    return 0.5*(nabla_grad(u) + nabla_grad(u).T)

def sigma(u):
    return -p*Identity(d) + 2*W1*(Identity(d) + 2*epsilon(u) + nabla_grad(u)*nabla_grad(u).T)

 #define trial and test functions
u = TrialFunction(V)
v = TestFunction(V)
d = u.geometric_dimension()

# variational problem
b = Constant((0, 0, -rho*g))
t_n = Constant((0, 0, 0))

a = inner(sigma(u), epsilon(v))*dx
L = dot(b, v)*dx +dot(t_n, v)*ds

# solution
u = Function(V)
solve(a == L, u, bc)

I know that the sigma term is the issue, because if I instead use the sigma found in the example the code will run with no issue.

I get the error " Expecting the left-hand side to be a bilinear form (not rank 1).

If I let sigma be -p*Identity(d), then I get the bilinear form error again.
The epsilon term runs fine by itself.

If I try and run `the product of the two gradient of u terms by themselves as the sigma function, I get the error

" raise ArityMismatch("Multiplying expressions with overlapping form argument number {0}, argument is {1}.".format(x.number(), x))
ArityMismatch: Multiplying expressions with overlapping form argument number 1, argument is v_1."

Any help would be appreciated.

asked Jun 11, 2017 by woolyabyss FEniCS Novice (420 points)

1 Answer

+1 vote
 
Best answer

Try something like this:

F = inner(sigma(u), epsilon(v))*dx - dot(b, v)*dx +dot(t_n, v)*ds
a = lhs(F)
L = rhs(F)
answered Jun 11, 2017 by hernan_mella FEniCS Expert (19,460 points)
selected Jun 11, 2017 by woolyabyss

Thanks for the reply,

its now telling me:
Error: Unable to define linear variational problem a(u, v) == L(v) for all v.
*** Reason: Expecting the left-hand side to be a bilinear form (not rank 0).
*** Where: This error was encountered inside LinearVariationalProblem.cpp.

Your problem is nonlinear. You must use a nonlinear solver (see Nonlinear Poisson equation
demo
) instead of simply solve(a == L, u, bc)

...