A simpler example where the same error happens with
mpirun -np 4
you can run the attached code, it is very shorter. I am sorry that i sent
so many lines of code before.
On Mon, Oct 12, 2015 at 5:15 PM, Giorgos Grekas <[email protected]> wrote:
> I provide backtrace to the file bt.txt and my code. For my code you need
> to run the file runMe.py.
>
>
> On Mon, Oct 12, 2015 at 4:40 PM, Jan Blechta <[email protected]>
> wrote:
>
>> PETSc error code 1 does not seem to indicate an expected problem,
>> http://www.mcs.anl.gov/petsc/petsc-dev/include/petscerror.h.html. It
>> seems as an error not handled by PETSc.
>>
>> You could provide us with your code or try investigating the problem
>> with debugger
>>
>> $ mpirun -n 3 xterm -e gdb -ex 'set breakpoint pending on' -ex 'break
>> PetscError' -ex 'break dolfin::dolfin_error' -ex r -args python
>> your_script.py
>> ...
>> Break point hit...
>> (gdb) bt
>>
>> and post a backtrace here.
>>
>> Jan
>>
>>
>> On Mon, 12 Oct 2015 15:16:48 +0300
>> Giorgos Grekas <[email protected]> wrote:
>>
>> > Hello,
>> > i am using ncg from tao solver and i wanted to test my code validity
>> > in a pc with 4 processors
>> > before its execution in a cluster. When i run my code with 2 processes
>> > (mpirun -np 2) everything
>> > looks to work fine but when i use 3 or more processes i have the
>> > following error:
>> >
>> >
>> > Error: Unable to successfully call PETSc function
>> > 'VecAssemblyBegin'. *** Reason: PETSc error code is: 1.
>> > *** Where: This error was encountered inside
>> >
>> /home/ggrekas/.hashdist/tmp/dolfin-wphma2jn5fuw/dolfin/la/PETScVector.cpp.
>> > *** Process: 3
>> > ***
>> > *** DOLFIN version: 1.7.0dev
>> > *** Git changeset: 3fbd47ec249a3e4bd9d055f8a01b28287c5bcf6a
>> > ***
>> >
>> -------------------------------------------------------------------------
>> >
>> >
>> >
>> ===================================================================================
>> > = BAD TERMINATION OF ONE OF YOUR APPLICATION PROCESSES
>> > = EXIT CODE: 134
>> > = CLEANING UP REMAINING PROCESSES
>> > = YOU CAN IGNORE THE BELOW CLEANUP MESSAGES
>> >
>> ===================================================================================
>> > YOUR APPLICATION TERMINATED WITH THE EXIT STRING: Aborted (signal 6)
>> > This typically refers to a problem with your application.
>> > Please see the FAQ page for debugging suggestions
>> >
>> >
>> >
>> >
>> >
>> > So, is it an issue that i must report to the tao team?
>> >
>> > Thank you in advance.
>>
>>
>
# Begin demo
from dolfin import *
#from scipy import optimize
import numpy as np
import matplotlib.pyplot as plt
import time
class MyOptimizationProblem(OptimisationProblem):
def __init__(self, u, Pi, DPi, DDPi):
OptimisationProblem.__init__(self)
self._Pi = Pi
self._DPi = DPi
self._DDPi = DDPi
self._u = u
self._niter = 0
# Objective function
def f(self, x):
self._u.vector()[:] = x
self._niter += 1
aPi = assemble(self._Pi)
print self._niter, aPi
return aPi
# Gradient of the objective function
def F(self, b, x):
self._u.vector()[:] = x
assemble(self._DPi, tensor=b)
# Hessian of the objective function
def J(self, A, x):
self._u.vector()[:] = x
assemble(self._DDPi, tensor=A)
# Optimization options for the form compiler
#parameters["form_compiler"]["precision"] = 100
parameters["form_compiler"]["cpp_optimize"] = True
ffc_options = {"optimize": True, \
"eliminate_zeros": True, \
"precompute_basis_const": True, \
"precompute_ip_const": True}
parameters["mesh_partitioner"] = "SCOTCH"
# Create mesh and define function space
#mesh = UnitCubeMesh(16, 12, 12)
k=10
epsilon = None
nx, ny = 100, 100
mesh = UnitSquareMesh(nx, ny)
boundary_parts = MeshFunction("size_t", mesh, mesh.topology().dim()-1)
class LeftBoundary(SubDomain):
def inside(self, x, on_boundary):
tol = 1E-14 # tolerance for coordinate comparisons
return on_boundary and abs(x[0]) < tol
Gamma_0 = LeftBoundary()
Gamma_0.mark(boundary_parts, 0)
class RightBoundary(SubDomain):
def inside(self, x, on_boundary):
tol = 1E-14 # tolerance for coordinate comparisons
return on_boundary and abs(x[0] - 1) < tol
Gamma_1 = RightBoundary()
Gamma_1.mark(boundary_parts, 1)
class UpDown(SubDomain):
def inside(self, x, on_boundary):
tol = 1E-14 # tolerance for coordinate comparisons
return on_boundary and (abs(x[1]) < tol or abs(1 - x[1]) < tol)
Gamma_2 = UpDown()
Gamma_2.mark(boundary_parts, 2)
V = VectorFunctionSpace(mesh, "Lagrange", 1)
W = FunctionSpace(mesh, "Lagrange", 1)
# Mark boundary subdomians
left = CompiledSubDomain("near(x[0], side) && on_boundary", side = 0.0)
right = CompiledSubDomain("near(x[0], side) && on_boundary", side = 1.0)
c = Expression(("0.0", "0.0"))
r = Expression(("0.5", "0.0"))
bcl = DirichletBC(V, c, left)
bcr = DirichletBC(V, r, right)
bcs = [bcl, bcr]
#bcs = [DirichletBC(V, c, boundary_parts, 0),
# DirichletBC(V, r, boundary_parts, 1)]
# Define functions
du = TrialFunction(V) # Incremental displacement
v = TestFunction(V) # Test function
u = Function(V) # Displacement from previous iteration
#T = Constant((0.1, 0.0, 0.0)) # Traction force on the boundary
# Kinematics
d = u.geometric_dimension()
I = Identity(d) # Identity tensor
F = variable(I + grad(u) ) # Deformation gradient
C = F.T*F # Right Cauchy-Green tensor
# Invariants of deformation tensors
Ic = tr(C)
J = det(F)
J2 = sqrt(J**2 + 1e-5)
# Elasticity parameters
E, nu = 10.0, 0.3
mu, lmbda = Constant(E/(2*(1 + nu))), Constant(E*nu/((1 + nu)*(1 - 2*nu)))
# Stored strain energy density (compressible neo-Hookean model)
psi = (mu/2)*(Ic - 2) - mu*ln(J2) + (lmbda/2)*(ln(J2))**2
print k, epsilon, 'n = ', nx, ny
u0 = Function(V)
for bc in bcs:
bc.apply(u0.vector() )
k_f = Constant('10000')
k_p = Constant(str(1.0/k) )
#k_f = Constant('50.0')
#k_p = Constant('1.0')
Pi = k_p*psi*dx + k_f*dot(u, u)*ds(0, subdomain_data=boundary_parts) + \
k_f*dot(u-u0, u-u0)*ds(1, subdomain_data=boundary_parts)
F = derivative(Pi, u, v)
# Compute Jacobian of F
DF = derivative(F, u, du)
start_time = time.time()
#u_array = initialization(psi, V, bcs, du, v, u)
i = 0
solver = PETScTAOSolver()
# Set some parameters
solver.parameters['linear_solver']='superlu_dist'
solver.parameters["method"] = "cg"
#solver.parameters["monitor_convergence"] = True
solver.parameters["report"] = True
max_iter = u.vector().array().shape[0]
solver.parameters["maximum_iterations"] = max_iter
#solver.parameters["function_absolute_tol"] = 1e-7
#solver.parameters["function_relative_tol"] = 1e-7
solver.parameters["gradient_absolute_tol"] = 1e-5
#solver.parameters["gradient_relative_tol"] = 1e-5
PETScOptions.set('tao_cg_type', 'prp')
PETScOptions.set('tao_cg_eta', '0.9')
#PETScOptions.set('tao_ls_type', 'armijo')
PETScOptions.set('tao_ls_type', 'more-thuente')
PETScOptions.set('tao_max_funcs', max_iter)
PETScOptions.set('tao_delta_min', '1e-7')
PETScOptions.set('tao_delta_max', '100')
# solver.parameters["line_search"] = 'gpcg'
# solver.parameters["line_search"] = 'unit'
parameters.parse()
# Solve the problem
optProblem = MyOptimizationProblem(u, Pi, F, DF)
solver.solve(optProblem, u.vector())
print 'time to create-solve problem = ', time.time()-start_time, 'seconds'
# Plot and hold solution
print 'Energy = ', assemble(Pi), 'k = ', k, 'n = ', nx, ny
_______________________________________________
fenics-support mailing list
[email protected]
http://fenicsproject.org/mailman/listinfo/fenics-support