If I replace superlu with superlu_dist as follows:
from __future__ import print_function
from fenics import *
from mshr import *
import numpy as np
import argparse
import ufl as ufl
dolfin.parameters["form_compiler"]["quadrature_degree"] = 10
####
i, j, k, l = ufl.indices(4)
def my_norm(x):
return (sqrt(np.dot(x, x)))
def ufl_norm(x):
return(sqrt(ufl.dot(x, x)))
def X(z):
x = ufl.SpatialCoordinate(mesh)
return as_tensor([x[0], x[1], z])
def e(omega):
return as_tensor([[1, 0, omega[0]], [0, 1, omega[1]]])
def normal(omega):
return as_tensor(cross(e(omega)[0], e(omega)[1]) / ufl_norm(cross(e(omega)[0], e(omega)[1])) )
def b(omega):
return as_tensor((normal(omega))[k] * (e(omega)[i, k]).dx(j), (i,j))
def g(omega):
return as_tensor([[1+ (omega[0])**2, (omega[0])*(omega[1])],[(omega[0])*(omega[1]), 1+ (omega[1])**2]])
def g_c(omega):
return ufl.inv(g(omega))
def detg(omega):
return ufl.det(g(omega))
def abs_detg(omega):
return np.abs(ufl.det(g(omega)))
def sqrt_detg(omega):
return sqrt(detg(omega))
def sqrt_abs_detg(omega):
return sqrt(abs_detg(omega))
def w():
x = ufl.SpatialCoordinate(mesh)
return as_tensor([-x[1], x[0]])
def sqrt_deth(omega):
return(sqrt((w())[i]*(w())[j]*g(omega)[i, j]))
def calc_normal_cg2(mesh):
n = FacetNormal(mesh)
V = VectorFunctionSpace(mesh, "CG", 2)
u = TrialFunction(V)
v = TestFunction(V)
a = inner(u, v) * ds
l = inner(n, v) * ds
A = assemble(a, keep_diagonal=True)
L = assemble(l)
A.ident_zeros()
nh = Function(V)
solve(A, nh.vector(), L)
return nh
def n(omega):
u = n_overline
return as_tensor(u[k]/sqrt(g(omega)[i,j]*u[i]*u[j]), (k))
def H(omega):
return (0.5 * g_c(omega)[i, j]*b(omega)[j, i])
def K(omega):
return(ufl.det(as_tensor(b(omega)[i,k]*g_c(omega)[k,j], (i, j))))
def Gamma(omega):
return as_tensor(0.5 * g_c(omega)[i,l] * ( (g(omega)[l, k]).dx(j) + (g(omega)[j, l]).dx(k) - (g(omega)[j, k]).dx(l) ), (i, j, k))
def Nabla_v(u, omega):
return as_tensor((u[i]).dx(j) + u[k] * Gamma(omega)[i, k, j], (i, j))
def Nabla_f(f, omega):
return as_tensor((f[i]).dx(j) - f[k] * Gamma(omega)[k, i, j], (i, j))
####
parser = argparse.ArgumentParser()
parser.add_argument("input_directory")
args = parser.parse_args()
#read mesh
mesh=Mesh()
with XDMFFile((args.input_directory) + "/triangle_mesh.xdmf") as infile:
infile.read(mesh)
mvc = MeshValueCollection("size_t", mesh, 2)
with XDMFFile((args.input_directory) + "/line_mesh.xdmf") as infile:
infile.read(mvc, "name_to_read")
n_overline = FacetNormal( mesh )
# Define boundaries and obstacle
boundary = 'on_boundary'
boundary_r = 'on_boundary && sqrt(pow(x[0], 2) + pow(x[1], 2)) < (1.0+2.0)/2.0'
boundary_R = 'on_boundary && sqrt(pow(x[0], 2) + pow(x[1], 2)) > (1.0+2.0)/2.0'
r = 1.0
R = 2.0
kappa = 1.0
alpha = 1000.0
sigma0 = 1.0
C = 0.5
set_log_level(20)
# Define function spaces
P_z = FiniteElement('P', triangle, 1)
P_omega = VectorElement('P', triangle, 3)
element = MixedElement([P_z, P_omega])
Q_z_omega = FunctionSpace(mesh, element)
Q_z = Q_z_omega.sub(0).collapse()
Q_omega = Q_z_omega.sub(1).collapse()
# Create XDMF files for visualization output
xdmffile_z = XDMFFile('z.xdmf')
xdmffile_omega = XDMFFile('omega.xdmf')
#read an object with label subdomain_id from xdmf file and assign to it the ds `ds_inner`
mf = dolfin.cpp.mesh.MeshFunctionSizet(mesh, mvc)
ds_r = Measure("ds", domain=mesh, subdomain_data=mf, subdomain_id=2)
ds_R = Measure("ds", domain=mesh, subdomain_data=mf, subdomain_id=3)
# Define trial and test functions
nu_z, nu_omega = TestFunctions(Q_z_omega)
z_omega = Function(Q_z_omega)
d_z_omega = TrialFunction(Q_z_omega)
sigma = Function(Q_z)
z, omega = split(z_omega)
class grad_r_Expression( UserExpression ):
def eval(self, values, x):
values[0] = C * x[0] / my_norm( x )
values[1] = C * x[1] / my_norm( x )
return (2,)
class grad_R_Expression( UserExpression ):
def eval(self, values, x):
values[0] = 0
values[1] = 0
def value_shape(self):
return (2,)
class sigma_Expression( UserExpression ):
def eval(self, values, x):
values[0] = sigma0
def value_shape(self):
return (1,)
# Define expressions used in variational forms
kappa = Constant(kappa)
sigma.interpolate(sigma_Expression(element=Q_z.ufl_element()))
grad_r = interpolate(grad_r_Expression(element=Q_omega.ufl_element()), Q_omega)
grad_R = interpolate(grad_R_Expression(element=Q_omega.ufl_element()), Q_omega)
# Define functional for variational problem
F_z = ( kappa * ( g_c(omega)[i, j] * (H(omega).dx(j)) * (nu_z.dx(i)) - 2.0 * H(omega) * ( (H(omega))**2 - K(omega) ) * nu_z ) + sigma * H(omega) * nu_z ) * sqrt_detg(omega) * dx \
- ( kappa * (n(omega))[i] * nu_z * (H(omega).dx(i)) ) * sqrt_deth(omega) * ds
F_omega = ( - z * Nabla_v(nu_omega, omega)[i, i] - omega[i] * nu_omega[i] ) * sqrt_detg(omega) * dx + \
( (n(omega))[i] * g(omega)[i, j] * z * nu_omega[j] ) * sqrt_deth(omega) * ds
#Nitche's part of the functional
F_N = alpha * ( \
((n_overline[i] * omega[i] - n_overline[j] * grad_r[j]) * (n_overline[k] * g( omega )[k, l] * nu_omega[l])) * sqrt_deth(omega) * ds_r + \
((n_overline[i] * omega[i] - n_overline[j] * grad_R[j]) * (n_overline[k] * g( omega )[k, l] * nu_omega[l])) * sqrt_deth(omega) * ds_R
)
F = F_z + F_omega + F_N
#boundary conditions
bc_r = DirichletBC(Q_z_omega.sub(0), Expression('C', element = Q_z_omega.sub(0).ufl_element(), C = C), boundary_r)
bc_R = DirichletBC(Q_z_omega.sub(0), Expression('2*C', element = Q_z_omega.sub(0).ufl_element(), C = C), boundary_R)
bcs = [bc_r, bc_R]
#solve
J = derivative(F, z_omega, d_z_omega) # Gateaux derivative in dir. of du
problem = NonlinearVariationalProblem(F, z_omega, bcs, J)
solver = NonlinearVariationalSolver(problem)
params = {'nonlinear_solver': 'newton', 'newton_solver': { 'linear_solver' : 'superlu_dist' }, }
solver.parameters.update(params)
solver.solve()
#print out the solution
z_dummy, omega_dummy = z_omega.split( deepcopy=True )
xdmffile_z.write( z_dummy, 0 )
xdmffile_omega.write( omega_dummy, 0 )
and run, I get
mpirun -np 6 python3 mwe.py /home/fenics/shared/mesh/membrane_mesh/fine_mesh
Process 0: Solving nonlinear variational problem.
Process 2: Solving nonlinear variational problem.Process 4: Solving nonlinear variational problem.
Process 5: Solving nonlinear variational problem.Process 3: Solving nonlinear variational problem.
Process 1: Solving nonlinear variational problem.
Traceback (most recent call last):
File "mwe.py", line 201, in <module>
solver.solve()
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 solve linear system.
*** Reason: Unknown solver method "superlu_dist". Use list_linear_solver_methods() to list available methods.
*** Where: This error was encountered inside LinearSolver.cpp.
*** Process: 4
***
*** DOLFIN version: 2019.1.0
*** Git changeset: 74d7efe1e84d65e9433fd96c50f1d278fa3e3f3f
*** -------------------------------------------------------------------------
Traceback (most recent call last):
File "mwe.py", line 201, in <module>
solver.solve()
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 solve linear system.
*** Reason: Unknown solver method "superlu_dist". Use list_linear_solver_methods() to list available methods.
*** Where: This error was encountered inside LinearSolver.cpp.
*** Process: 0
***
*** DOLFIN version: 2019.1.0
*** Git changeset: 74d7efe1e84d65e9433fd96c50f1d278fa3e3f3f
*** -------------------------------------------------------------------------
Traceback (most recent call last):
File "mwe.py", line 201, in <module>
solver.solve()
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 solve linear system.
*** Reason: Unknown solver method "superlu_dist". Use list_linear_solver_methods() to list available methods.
*** Where: This error was encountered inside LinearSolver.cpp.
*** Process: 5
***
*** DOLFIN version: 2019.1.0
*** Git changeset: 74d7efe1e84d65e9433fd96c50f1d278fa3e3f3f
*** -------------------------------------------------------------------------
Traceback (most recent call last):
File "mwe.py", line 201, in <module>
solver.solve()
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 solve linear system.
*** Reason: Unknown solver method "superlu_dist". Use list_linear_solver_methods() to list available methods.
*** Where: This error was encountered inside LinearSolver.cpp.
*** Process: 1
***
*** DOLFIN version: 2019.1.0
*** Git changeset: 74d7efe1e84d65e9433fd96c50f1d278fa3e3f3f
*** -------------------------------------------------------------------------
Traceback (most recent call last):
File "mwe.py", line 201, in <module>
solver.solve()
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 solve linear system.
*** Reason: Unknown solver method "superlu_dist". Use list_linear_solver_methods() to list available methods.
*** Where: This error was encountered inside LinearSolver.cpp.
*** Process: 2
***
*** DOLFIN version: 2019.1.0
*** Git changeset: 74d7efe1e84d65e9433fd96c50f1d278fa3e3f3f
*** -------------------------------------------------------------------------
Traceback (most recent call last):
File "mwe.py", line 201, in <module>
solver.solve()
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 solve linear system.
*** Reason: Unknown solver method "superlu_dist". Use list_linear_solver_methods() to list available methods.
*** Where: This error was encountered inside LinearSolver.cpp.
*** Process: 3
***
*** DOLFIN version: 2019.1.0
*** Git changeset: 74d7efe1e84d65e9433fd96c50f1d278fa3e3f3f
*** -------------------------------------------------------------------------