a boundary condition for sphere geometry

Asked by Sungick Kim

Hi, all.

With a sphere with radius = 1, I want to give some values for nodes near the crust of it.
So I tried with 2 codes below and both gave me same warnings:
*** Warning: Found no facets matching domain for boundary condition.
Can you suggest me a way to make it work?

1st code:
from dolfin import *
sphere = UnitSphere(10)
x = sphere.coordinate()

Q = FunctionSpace(sphere, "CG", 1)

outer= compile_subdomains(" x[0]**2+x[1]**2+x[2]**2 > 0.9**2 - 5*DOLFIN_EPS) && on_boundary")
g = Constant(1.0)
BC = DirichletBC(Q, g, outer)

2nd code:
from dolfin import *
sphere = UnitSphere(10)
x = sphere.coordinate()

Q = FunctionSpace(sphere, "CG", 1)

boundary = BoundaryMesh(sphere)
outer= compile_subdomains("boundary")
g = Constant(1.0)
BC = DirichletBC(Q, g, outer)

Question information

Language:
English Edit question
Status:
Solved
For:
DOLFIN Edit question
Assignee:
No assignee Edit question
Solved by:
Garth Wells
Solved:
Last query:
Last reply:
Revision history for this message
Best Garth Wells (garth-wells) said :
#1

There are some syntax errors in '1st code'. It should be:

from dolfin import *
sphere = UnitSphere(10)

Q = FunctionSpace(sphere, "CG", 1)

outer= compile_subdomains("x[0]*x[0] + x[1]*x[1] +x[2]*x[2] > 0.9*0.9 - 5*DOLFIN_EPS && on_boundary")
g = Constant(1.0)
BC = DirichletBC(Q, g, outer)

Revision history for this message
Sungick Kim (sungick) said :
#2

Thanks Garth Wells, that solved my question.