Runtime error while executing dirichlet BC

Hi,
I am getting a runtime error,but i dont know what is causing the error.Even the error message does not say something much useful

mesh=UnitSquraeMesh(16,16)
V = VectorElement("Lagrange", mesh.ufl_cell(), 2)
Q = FiniteElement("Lagrange", mesh.ufl_cell(), 1)
TH = V*Q
VQ = FunctionSpace(mesh, TH)
u_D = Constant(10.0)
def boundary(x, on_boundary):
    return on_boundary
bc = DirichletBC(VQ.sub(0), u_D, boundary)

Could you state the error message? It would likely be useful for you to get help even if it’s useless to you.

Cf. Read before posting: How do I get my question answered?

1 Like

Are you trying to apply a constant 10 boundary condition on every dof in both the vector space V and in Q?
If so:

vq = Function(VQ)
vq.vector()[:] = 10
bc = DirichletBC(VQ, vq, boundary)

If not, you need to explain what kind of boundary condition you would like to prescribe

No i just wanted to have 10 as BC in V and not Q.

Then you should try something like:

bc = DirichletBC(VQ.sub(0), Constant((10,10)), boundary)

if you want the vector space to be 10 for each component.

Oh, okay
Btw here (10,10) are the vector components right.?
TYSM for the reply

Yes, as this is a 2D problem with a 2D vector function space, this is each of the components.

1 Like