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

Found no facets matching domain for boundary condition , newton iteration did not converge

0 votes

I just want to understand the cause of the error . What I got from the error message is that the newton iterations are not converging . What could be the reason for the for this error? Is it because the problem formulation is wrong. Also I got the error "Found no facets matching domain for boundary condition." Is this error due to improper boundary conditions ? Or these errors are due to some fundamental mistake I am doing in writing the code. Please let me know.

from dolfin import *
import numpy, sys

# create mesh
mesh = UnitSquare(5,5)

V = FunctionSpace(mesh,"Lagrange",1) # Function space for u ( Temperature)
Q = FunctionSpace(mesh,"Lagrange",1)  # Function space for \mu ( materi#property
L = FunctionSpace(mesh,"Lagrange",1)  # Function space for \lembda 


M = MixedFunctionSpace([V,Q,L]) # M is mixed function space

# Define the test function space
TestFunction = TestFunction(M)
(v,q,w) = split(TestFunction)

# split the mixed function space into components
# Define the trial function space
solution = Function(M)
(u,mu,lmd) = split(solution)
PrescribedU=Expression("0.25*(pow(x[0],2)+pow(x[1],2))-x[0]*x[1]*0.5-x[0]+0.5*x[1]")

# projecting analytical solution on the function space
u_m = interpolate(PrescribedU,V)

F=inner(nabla_grad(lmd),nabla_grad(v))*mu*dx \
        +inner(nabla_grad(lmd),nabla_grad(u))*q*dx\
        +inner(nabla_grad(w),nabla_grad(u))*mu*dx+inner(v,u-u_m)*dx

def boundary_u(x,on_boundary):
    on_boundary and (near(x[0],0.0) or near(x[0],1.0) \
            or near(x[1],0.0) or near(x[1],1.0))

def boundary_lmd(x,on_boundary):
    on_boundary and (near(x[0],0.0) or near(x[0],1.0) \
            or near(x[1],0.0) or near(x[1],1.0))

# \mu boundaries
def boundary_mu(x,on_boundary):
    on_boundary and (near(x[1],0.0) or near(x[0],1.0))

# u is prescribed on entire boundary
bcs_u = DirichletBC(M.sub(0),PrescribedU , boundary_u)
# \mu prescribed where vector(a).vector(n) < 0 ,i.e inflow boudaries
# inflow boundaries are x[0]=1. and x[1]=0.
# a = Expression("0.5*(x[0]-x[1])-1","(x[1]-x[0])*0.5+0.5")
PrescribedMU= Expression("(2/(exp(2)-1))*(exp(2*x[0])+2*x[1])")
bcs_mu=DirichletBC(M.sub(1),PrescribedMU,boundary_mu)

# \lmd is 0. on entire boundary
bcs_lmd=DirichletBC(M.sub(2),Constant(0.0),boundary_lmd)

bcs=[bcs_u ,bcs_mu , bcs_lmd]


#solution = Function(M)
solve(F==0,solution, bcs)

Error message is as follows:

Newton iteration 6: r (abs) = nan (tol = 1.000e-10) r (rel) = nan (tol = 1.000e-09)
Warning: Found no facets matching domain for boundary condition.
Warning: Found no facets matching domain for boundary condition.

[0]PETSC ERROR: --------------------- Error Message ------------------------------------
[0]PETSC ERROR: Floating point exception!
[0]PETSC ERROR: Infinite or not-a-number generated in norm!
[0]PETSC ERROR: ------------------------------------------------------------------------
[0]PETSC ERROR: Petsc Release Version 3.2.0, Patch 5, Sat Oct 29 13:45:54 CDT 2011
[0]PETSC ERROR: See docs/changes/index.html for recent updates.
[0]PETSC ERROR: See docs/faq.html for hints about trouble shooting.
[0]PETSC ERROR: See docs/index.html for manual pages.
[0]PETSC ERROR: ------------------------------------------------------------------------
[0]PETSC ERROR: Unknown Name on a linux-gnu named linuxGeek by mohit Mon Jan 6 17:05:55 2014
[0]PETSC ERROR: Libraries linked from /build/buildd/petsc-3.2.dfsg/linux-gnu-c-opt/lib
[0]PETSC ERROR: Configure run at Tue Dec 4 14:42:55 2012

Error: Unable to solve nonlinear system with NewtonSolver.
Reason: Newton solver did not converge. Bummer.
Where: This error was encountered inside NewtonSolver.cpp.
Process: 0

asked Jan 6, 2014 by mt.fan FEniCS Novice (260 points)

1 Answer

+4 votes
"Found no facets matching domain for boundary condition."

This is a coding error - you're missing return keyword

def boundary_u(x,on_boundary):
    return on_boundary and (near(x[0],0.0) or near(x[0],1.0) \
            or near(x[1],0.0) or near(x[1],1.0))

def boundary_lmd(x,on_boundary):
    return on_boundary and (near(x[0],0.0) or near(x[0],1.0) \
            or near(x[1],0.0) or near(x[1],1.0))

# \mu boundaries
def boundary_mu(x,on_boundary):
    return on_boundary and (near(x[1],0.0) or near(x[0],1.0))

Then Newton solver fails because of infinity in second iteration hence your problem is probably singular.

answered Jan 6, 2014 by Jan Blechta FEniCS Expert (51,420 points)

Thanks ..this helped

...