Function value at the boundary

Hello. Is it possible to somehow look through the print () function, what is the value of the left and right borders?

Again, your question is fairly generic, with very little context and no code to illustrate your use-case.

There are various ways to access the data on a facet of a mesh. For instance by getting the entity_dofs or entity_closure_dofs and use them to access values in a function u, print(u.vector()[dof] for dof in entity_dofs_of_facet).

The easiest way to debug a DirichletBC is visually using bc.apply on a function, see: Boundary conditions on edges or nodes - #6 by dokken

u0 = Expression('exp(t+x[0])', degree=1, t=t)
mesh = IntervalMesh(128, 0, 1)
V = FunctionSpace(mesh, 'CG', 2)


def boundary(x, on_boundary):
    return on_boundary
bc = DirichletBC(V, u0, boundary)

Here is the code, I want to know what is the value on the borders of the grid. How to do it?

The easiest way (for meshes more complex than an interval) is to inspect this visually (writing to pvd or xdmf, and using a GUI such as Paraview or Visit), as I already stated in:

otherwise you can use the following:

from dolfin import *
t = 5

u0 = Expression('exp(t+x[0])', degree=1, t=t)
mesh = IntervalMesh(128, 0, 1)
V = FunctionSpace(mesh, 'CG', 2)


def boundary(x, on_boundary):
    return on_boundary
bc = DirichletBC(V, u0, boundary)


u_bc = Function(V)

bc.apply(u_bc.vector())

b_values = bc.get_boundary_values()
x = V.tabulate_dof_coordinates()
for dof, value in b_values.items():
    print(x[dof], value)

returning

mpirun -n 3 python3 mwe3.py 
[ 0.] 148.4131591025766
[ 1.] 403.4287934927351

Thank you
/////////////////////////////////////////