Good morning,
I am solving the Poisson with pure Neumann bounday condtions. I formulate the problem as a saddle point problem, in order to deal with the singular system. The code is the following:
from dolfin import *
from mpi4py import MPI
import matplotlib.pyplot as plt
import time
# For parallelization
comm = MPI.COMM_WORLD # comm in the comunicator objec, its methods will be used for comunication
my_rank = comm.Get_rank()
p = comm.Get_size() #number of processes
#Starting CPU time
st_time = time.time()
# Create mesh
N = 40
mesh = UnitCubeMesh(N,N,N)
#mesh = UnitSquareMesh(N, N)
# Build function space with Lagrange multiplier
P1 = FiniteElement("CG", mesh.ufl_cell(), 1)
R = FiniteElement("Real", mesh.ufl_cell(), 0)
W = FunctionSpace(mesh, P1 * R)
# Concerning the number of integration points
q_degree = 4
dx = dx(metadata={'quadrature_degree': q_degree})
# Define variational problem
(u, c) = TrialFunction(W)
(v, d) = TestFunctions(W)
f = Expression('4*pi*pi*cos(2*pi*x[0])', degree=5)
#g = Expression('-4*pi*pi*(2*pi*x[0])', degree=5)
g = Constant(0.0)
a = (inner(grad(u), grad(v)) + c*v + u*d)*dx
L = f*v*dx + g*v*ds
# Whit iterative solver
# Set linear solver parameters
abs_tol = 1E-10
rel_tol = 1E-10
max_iter = 1000
prm = parameters['krylov_solver']
prm['absolute_tolerance'] = abs_tol
prm['relative_tolerance'] = rel_tol
prm['maximum_iterations'] = max_iter
prm["monitor_convergence"] = True
#info(parameters, True)
# Compute solution
w = Function(W)
solve(a == L, w, solver_parameters={'linear_solver':'cg','preconditioner':'hypre_euclid'})
#
(u, c) = w.split()
and the error that I have is the following:
*** -------------------------------------------------------------------------
*** 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 using PETSc Krylov solver.
*** Reason: Solution failed to converge in 10 iterations (PETSc reason DIVERGED_INDEFINITE_PC, residual norm ||r|| = 1.063353e-04).
*** Where: This error was encountered inside PETScKrylovSolver.cpp.
*** Process: 0
***
*** DOLFIN version: 2019.2.0.dev0
*** Git changeset: ubuntu
*** -------------------------------------------------------------------------
can someone help me or have some hint on what I am doing wrong.
Thanks in advance.