I am trying to solve some problem related to hyperelasticity, see simplified code below. It works in 2D, but unfortunately in 3D the form compilation fails: if I set dolfin.parameters["form_compiler"]["optimize"] = True
then python runs out of memory while generating the code; if I set dolfin.parameters["form_compiler"]["optimize"] = False
then gcc runs out of memory while compiling the (1GB) generated code (even with dolfin.parameters["form_compiler"]["cpp_optimize"] = False
and dolfin.parameters["form_compiler"]["cpp_optimize_flags"] = '-O0'
). I am running Kubuntu on a MacBookPro with 16GB of RAM, FEniCS 2016.0.2 from the ppa, and gcc 6.2.0. Any idea how to get the code to compile? Thanks!
import dolfin
##############################################################
#dolfin.parameters["form_compiler"]["optimize"] = True
#dolfin.parameters["form_compiler"]["cpp_optimize"] = False
#dolfin.parameters["form_compiler"]["cpp_optimize_flags"] = '-O0'
#
dim = 2 # 2 or 3
#
degree = 1
quadrature = None
##############################################################
if (dim == 2):
mesh = dolfin.UnitSquareMesh(1, 1)
elif (dim == 3):
mesh = dolfin.UnitCubeMesh(1, 1, 1)
#
dV = dolfin.Measure("dx",
domain=mesh)
dF = dolfin.Measure("dS",
domain=mesh)
#
function_space = dolfin.VectorFunctionSpace(
mesh=mesh,
family="Lagrange",
degree=degree)
#
U = dolfin.Function(function_space)
#
I = dolfin.Identity(dim)
F = I + dolfin.grad(U)
J = dolfin.det(F)
C = F.T * F
Ic = dolfin.tr(C)
Ic0 = dolfin.tr(I)
Cinv = dolfin.inv(C)
#
E = dolfin.Constant(1.0)
nu = dolfin.Constant(0.1)
kappa = E/3/(1-2 * nu)
lmbda = E * nu/(1+nu)/(1-(dim-1) * nu)
mu = E/2/(1+nu)
C1 = mu/2
D1 = kappa/2
#
psi = D1 * (J**2 - 1 - 2 * dolfin.ln(J)) + C1 * (Ic - Ic0 - 2 * dolfin.ln(J))
S = 2 * D1 * (J**2 - 1) * Cinv + 2 * C1 * (I - Cinv)
P = F * S
#
Div_P = dolfin.div(P)
J_V = dolfin.dot(Div_P,Div_P)
#
N = dolfin.FacetNormal(mesh)
Jump_P_N = dolfin.jump(P,N)
J_F = dolfin.dot(Jump_P_N,Jump_P_N)
#
dU_test = dolfin.TestFunction(function_space)
dU_trial = dolfin.TrialFunction(function_space)
#
DJ_V = dolfin.derivative( J_V, U, dU_test )
DDJ_V = dolfin.derivative(DJ_V, U, dU_trial)
DJ_F = dolfin.derivative( J_F, U, dU_test )
DDJ_F = dolfin.derivative(DJ_F, U, dU_trial)
#
A = None
if (quadrature is None):
A = dolfin.assemble(DDJ_V * dV + DDJ_F * dF, tensor=A)
else:
A = dolfin.assemble(DDJ_V * dV + DDJ_F * dF, tensor=A, form_compiler_parameters={'quadrature_degree':quadrature})