The function boundary specifies which points that belong to the part of
the boundary where the boundary condition should be applied:
def boundary(x, on_boundary):
return on_boundary
FEniCS already knows whether the point belongs to the actual boundary
(the mathematical boundary of the domain) and kindly shares this
information with you in the variable on_boundary.
You may choose to use this information, or ignore it completely.
I’m trying to understand this thing, this def can be easily implemented,
in case of homogeneous, like u_D = 0, or u_D = expression, for all
points that belong to u_D.
What if the domain is rectangle where left boundary is the expression,
and all other boundaries are constant set to zero?
# Create classes for defining parts of the boundaries and the interior
# of the domain
class Left(SubDomain):
def inside(self, x, on_boundary):
return near(x[0], 0.0)
class AllBoundaries(SubDomain):
def inside(self, x, on_boundary):
return on_boundary
# Initialize sub-domain instances
left = Left()
allbndry = AllBoundaries()
# Define mesh
mesh = UnitSquareMesh(64, 64)
# Initialize mesh function for boundary domains
boundaries = MeshFunction("size_t", mesh, mesh.topology().dim()-1)
boundaries.set_all(0)
allbndry.set(boundaries,1)
left.mark(boundaries, 2)
This will create a mesh function (a value for each facet) which is 0 in the interior, 1 on all of the boundary, except at the left boundary,where it is 2
Jorgen, many thanks, it seems to be a little bit different than in FEniCS tutorial & its some demo python files, are you referring to somewhat old version of FEniCS like Dolfin or similar ?
I am referring to the latest version of dolfin, located at bitbucket.
If you are referring to dolfinx, located at github, there is indeed a different syntax.
I was referring to FEniCS, that can be imported as python module, and it seems like this Fenics env needs somewhat different syntax, and that’s why I confused on the link you have provided kindly to me. Basically, this syntax is also somewhat relative to Fenics for sure;
Then I can’t understand this syntax and FEniCS tutorial especially boundary conditions formulation, it seems like they use different syntax, and for my ordinary case, I should have used another way & syntax to formulate; thought the tutorial should provide the basic thing that i can do it myself further
As you have provided no links to the tutorials you are using, i cannot help you any further.
There are many different ways of applying boundary conditions, depending on the PDE and complexity of the problem.
In the bitbucket repository i referred to in the previous post, there is a large variety of documented demos illustrating usage