Found no facets matching domain for boundary condition

Hi,

I’m rather new to FeniCS and to FEM so have a hard time currently.

During solving of a first problem I get the error:

*** Warning: Found no facets matching domain for boundary condition.

All information in the web did not help me up to now.

I try to solve the time dependent heat convection-diffusion equation with different boundary conditions at different positions of the domain (Dirichlet and Neumann and Robin). I reduced the original code to something that might not make physical sense but looks as follows:

"""
Time dependent Thermal Convection-Diffusion Equation

  rho*cp*grad(T,t)+rho*cp*v*grad(T,x)=div(lambda*grad(T,x),x)
                   T = Tc    on Gamma G 
                   T = Tc/2. on Gamma F

Temperatures in degree Celsius              

Boundaries:
  x: 0 --> Thick
  y: 0 --> LengthT (y-Axis inverted)

  x=0.0                         x = Thick
  0 0 0 0 0 0 0 0 0 0 0 0 0 ... 0
  4                             1
  4                             1
  4                             1
  ...                           ...
  4                             1
  4                             1  y = LengthM
  4                             2
  4                             2
  ...                           ...
  4                             2
  4                             2
  3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3  y = LengthT

"""

from fenics import *
import matplotlib.pyplot as plt

#=============================================================
# some problem parameters

rho   = 7000           # kg/m**3
lmbda = 50             # W/m K  
cp    = 500            # J/kg K
thd   = lmbda/(rho*cp) # thermal diffusivity

Tc     = 1550 # degree Celsius

Thick    = 0.2         # thickness
CenterX  = Thick/2.0
LengthM  = 0.6         # length from 0.0 to of first boundary 
npThick  = 20
LengthT  = 3.0         # total length
npLength = 300

#=============================================================
# mesh, functionspace and boundaries

p0   = Point(0.0,0.0)
p1   = Point(Thick,LengthT)
mesh = RectangleMesh(p0,p1,npThick,npLength,'left')
V    = FunctionSpace(mesh, 'P', 1)

class BoundaryG(SubDomain): # Boundary 0
    tol = 1E-8
    def inside(self, x, on_boundary):        
        if on_boundary and near(x[1],0.0,self.tol): return True
        else:                                       return False

class BoundaryF(SubDomain): # Boundary 1 (original Boundary 3 - all others removed)
    tol = 1E-8
    def inside(self, x, on_boundary): 
        if  on_boundary and \
            near(x[1]>LengthT,self.tol): return True
        else:                           return False

boundary_markers = MeshFunction('size_t', mesh,dim=mesh.topology().dim()-1) #mesh.geometric_dimension()-1)

sdG = 0
sdF = 1

bG  = BoundaryG()
bG.mark(boundary_markers,sdG)

bF = BoundaryF()
bF.mark(boundary_markers,sdF)

ds = Measure('ds',domain=mesh,subdomain_data=boundary_markers)

boundary_file = File("t_modell/boundaries.pvd")
boundary_file << boundary_markers

#=============================================================
# boundary conditions

u  = TrialFunction(V)
v  = TestFunction(V)

# default bc is Neumann

bcond = {
         0:{'Dirichlet':Constant(Tc)},
         1:{'Dirichlet':Constant(Tc/2.0)}
        }

bcs           = []

for i in bcond:
    bc = DirichletBC(V,bcond[i]['Dirichlet'],boundary_markers,i)
    bcs.append(bc)

#=============================================================
# Define variational problem

f0 = Constant(0)                               # symmetry
fD = Constant(thd)                             # thermal diffusivity
ts = Expression(('0.0','0.01/60.0'), degree=1) # transport speed in y direction 0.01 m/min

# weak problem
a = fD * dot(grad(u),grad(v)) * dx + dot(ts,grad(u)) * v * dx
L = f0 * v * dx

#=============================================================
# solve time dependent problem

tFinal    = 60.0  # final simulation time
dt        = 1.0   # time step size

# Define initial value
fI  = Constant(1000)   # Initial Values
u_n = interpolate(fI, V)

# Create VTK file for saving solution
vtkfile = File('t_modell/solution.pvd')

# Time-stepping
u = Function(V)
t = 0
while t < tFinal:

    # Update current time
    t += dt
    print(t,"s /",tFinal,'s')

    # Compute solution
    solve(a == L, u, bcs)

    # Save to file and plot solution
    vtkfile << (u, t)
    plot(u)

    # Update previous solution
    u_n.assign(u)

# Hold plot
import matplotlib.pyplot as plt
plt.show()

Can anyone help me and point to the lines that are not correct?

Arrrgh … found the error myself by checking bF.inside(x,True). After a few changes the expression near(x[1]>LengthT,self.tol) delivered always False. After correction all is ok.

1 Like