Problem with finding the boundary

Asked by Roman Moritz

Hello,
Ive tried to define the inner circle of a tire as a dirichlet boundary like that:

def Restboundary2(x,on_boundary):
 tol = 1E-6
 return on_boundary and sqrt(x[0]**2+x[1]**2)< sqrt((0.22+tol)**2)

u_i=Constant((0,-(9810*(1E-6)),0))
bci=DirichletBC(V,u_i,Restboundary2)

with 0.22 the inner radius.
when i start solving i get the error:

"Found no facets matching domain for boundary condition."

when i try the same with a neumann boundary

class NeumannBoundary2(SubDomain):
 def inside(self, x ,on_boundary):
  tol = 1E-6
  return on_boundary and sqrt(x[0]**2+x[1]**2)< sqrt((0.22+tol)**2)
boundary_parts= MeshFunction("uint",mesh,mesh.topology().dim()-1)
boundary_parts.set_all(4)
nm_boundary2=NeumannBoundary2()
nm_boundary2.mark(boundary_parts,2)

and plot the boundary parts i can see that it finds the boundary as i want it.

so does anybody has an idea whats wrong??

thanks

Question information

Language:
English Edit question
Status:
Solved
For:
FEniCS Project Edit question
Assignee:
No assignee Edit question
Solved by:
Anders Logg
Solved:
Last query:
Last reply:
Revision history for this message
Best Anders Logg (logg) said :
#1

On Fri, Feb 15, 2013 at 12:06:05PM -0000, Roman Moritz wrote:
> New question #221951 on FEniCS Project:
> https://answers.launchpad.net/fenics/+question/221951
> Ive tried to define the inner circle of a tire as a dirichlet boundary like that:
> def Restboundary2(x,on_boundary):
> tol = 1E-6
> return on_boundary and sqrt(x[0]**2+x[1]**2)< sqrt((0.22+tol)**2)
> u_i=Constant((0,-(9810*(1E-6)),0))
> bci=DirichletBC(V,u_i,Restboundary2)
> with 0.22 the inner radius.
> when i start solving i get the error:
> "Found no facets matching domain for boundary condition."
> when i try the same with a neumann boundary
> class NeumannBoundary2(SubDomain):
> def inside(self, x ,on_boundary):
> tol = 1E-6
> return on_boundary and sqrt(x[0]**2+x[1]**2)< sqrt((0.22+tol)**2)
> boundary_parts= MeshFunction("uint",mesh,mesh.topology().dim()-1)
> boundary_parts.set_all(4)
> nm_boundary2=NeumannBoundary2()
> nm_boundary2.mark(boundary_parts,2)
> and plot the boundary parts i can see that it finds the boundary as i want it.
> so does anybody has an idea whats wrong??
> thanks

Very strange... What you do with the Neumann boundary is exactly the
same thing that happens inside DirichletBC when it extracts a
MeshFunction for the markers using SubDomain.mark:

  // Mark everything as sub domain 1
  sub_domains = 1;

  // Mark the sub domain as sub domain 0
  sub_domain->mark(sub_domains, 0);

Does it work if you create your DirichletBC by

  bci = DirichletBC(V, u_i, boundary_parts, 2)

?

--
Anders

Revision history for this message
Roman Moritz (r-moritz) said :
#2

Thanks Anders Logg, that solved my question.